Chikaiduma/meridian-support-bot
0
Meridian Customer Support Chatbot (AI engineer assessment)
Deployable prototype: Gradio UI, OpenAI GPT-4o-mini (low per-conversation cost), and MCP (Streamable HTTP) to Meridian’s order-mcp service (products, customers, orders, cart/checkout via tools).
Architecture
meridian/config.py— environment-based settings (no secrets in code).meridian/mcp_session.py—httpxtimeouts + officialmcpstreamable HTTP client, initialized session per request.meridian/tool_format.py— maps MCP tool JSON Schema to OpenAI function tools.meridian/agent.py— tool loop:list_tools→ OpenAI with tools →call_tooluntil final natural-language reply.meridian/prompts.py— support persona, auth and safety instructions.app.py— Gradio chat; stores full OpenAI message history (including tool traces) in state for correct multi-turn context.
MCP tools (discovered at runtime)
The server exposes: list_products, get_product, search_products, get_customer, verify_customer_pin, list_orders, get_order, create_order. The model chooses tools from the live list_tools result.
Local run
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # set OPENAI_API_KEY; optional OPENAI_BASE_URL (e.g. OpenRouter)
python app.pyOpen the printed URL (default http://127.0.0.1:7860).
Tests
pytestHugging Face Spaces
- Create a Gradio Space (or Docker if you use the provided
Dockerfile). - Set Secrets (or Variables):
OPENAI_API_KEY— required.OPENAI_BASE_URL— optional; leave unset for api.openai.com, or set e.g.https://openrouter.ai/api/v1for OpenRouter (use models likeopenai/gpt-4o-mini).MCP_SERVER_URL— optional; defaults to the assessment server if unset in code.- Main file:
app.py(Gradio default entry works with this layout).
Security notes (for production review)
- API keys only via environment / platform secrets.
- Customer PINs are redacted in server logs for
verify_customer_pin. - MCP is the only path to business data; the app does not talk to a database directly.
- Tune
MAX_TOOL_ROUNDSand timeouts for abuse protection and cost control.
Cost
Default model gpt-4o-mini keeps inference cost low; override with OPENAI_MODEL if your org standardizes on another flash/mini tier.
