CoolFace
Apppublic

olasogba/meridian-support

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
App README

Meridian Electronics — Customer Support Chatbot

A production-style customer support assistant for Meridian Electronics, built on top of an existing internal MCP server. The bot can:

  • —Browse and search the product catalog
  • —Authenticate returning customers via email + 4-digit PIN
  • —Show a logged-in customer their order history
  • —Place a new order with an explicit two-step confirmation

Architecture

   ┌─────────┐    HTTPS     ┌────────────────┐    Streamable HTTP     ┌─────────────┐
   │ Browser │ ───────────▶ │ Gradio + Agent │ ────────────────────▶ │ Order MCP   │
   │ (chat)  │              │  (this app)    │                        │  server     │
   └─────────┘              └────────────────┘                        └─────────────┘
                                    │
                                    │ uses
                                    ▼
                            OpenAI Responses API
                                (gpt-4o-mini)
  • —Agent — OpenAI Agents SDK, model gpt-4o-mini (cheap mini-tier).
  • —Tools — every MCP tool is wrapped in a Python @function_tool. The wrappers carry session state (Session dataclass) and inject the authenticated customer ID for privileged calls. The LLM never sees a customer_id parameter for orders or history; it cannot impersonate.
  • —Order placement is a two-phase flow: prepare_order re-fetches live prices and stages a pending order on the session; place_order takes no arguments and submits whatever was staged. The agent must obtain explicit customer confirmation between the two calls.
  • —MCP transport — Streamable HTTP. A fresh client session is opened per tool call (stateless, easy to reason about, latency is fine for chat).
  • —UI — Gradio chat. Session state lives in gr.State, isolated per browser session.

Files

FilePurpose
app.pyGradio UI + agent run loop
agent_setup.pyBuilds the Agent with the system prompt and tools
tools.pySession-aware function tools that wrap MCP calls
mcp_client.pyStreamable-HTTP client wrapper
prompts.pySystem prompt for "Meri"
config.pyEnv-driven configuration
discover.pyStandalone script to dump the MCP server's tool schema
_smoke_test.pyEnd-to-end agent test (no UI)

Run locally

bash
uv sync
cp .env.example .env   # then edit and set OPENAI_API_KEY
uv run python app.py

Open http://127.0.0.1:7860.

Environment

  • —OPENAI_API_KEY — required.
  • —MODEL — defaults to gpt-4o-mini.
  • —MCP_SERVER_URL — defaults to the Meridian MCP server.

On Hugging Face Spaces, set OPENAI_API_KEY as a Space Secret (Settings → Variables and secrets → New secret).

Security notes

  • —Authentication is by email + 4-digit PIN against the MCP server.
  • —The bot only ever calls privileged tools with the customer ID it captured from a successful PIN verification. UUIDs typed into the chat are ignored.
  • —Order details are gated: my_order_details checks the order belongs to the authenticated customer before fetching it.
  • —PINs and full API keys are never logged.

Limitations / future work

  • —No persistent conversation history across sessions.
  • —Price extraction from MCP get_product text uses a regex; a structured response from the MCP server would be safer.
  • —No rate limiting on the chat endpoint.
  • —Single-region MCP server; a regional outage would take the bot down.
  • —gpt-4o-mini will occasionally over-confirm or hallucinate a SKU; tightening the system prompt or moving to gpt-4.1-mini would help.