ecom-mcp
An MCP server for e-commerce operations that enables AI agents to investigate stuck orders, surface fulfillment anomalies, and create escalation records via natural language queries.
README
mcp-ecommerce
An MCP server that lets an AI agent investigate stuck orders, surface fulfillment anomalies, and create escalation records — turning a multi-tab ops investigation into a single natural-language query.
Deployed on Railway with a PostgreSQL database. Connect any MCP-compatible client to the hosted URL and start querying immediately — no local setup required to evaluate.
Hosted MCP Server
https://ecom-mcp-production-f5bf.up.railway.app/sse
The server and its PostgreSQL database are both running on Railway. The /sse endpoint is live and accepting MCP client connections.
Connect via the included Groq client
git clone https://github.com/beinghadibadami/ecom-mcp.git
cd ecom-mcp
npm install
cp .env.example .env
# add GROQ_API_KEY and MCP_SERVER_URL=https://ecom-mcp-production-f5bf.up.railway.app
npm run client:remote -- "why is order ord_pick_002 stuck?"
The client prints each tool call and result as it runs, then a [final answer].
MCP Tools
| Tool | Access | Description |
|---|---|---|
get_order |
Read | Full order details and line items for a given order ID |
get_payment_status |
Read | Payment state (captured / failed / refunded / pending) and amount |
get_fulfillment_status |
Read | Current stage, hours in stage, carrier, tracking, and error reason |
list_flagged_orders |
Read | Orders breaching SLA thresholds with hours overdue and escalation status |
create_escalation |
Write | Creates or returns an existing escalation (idempotent). Blocked at the business layer if no confirmed anomaly exists |
Anomaly thresholds (hardcoded in src/constants.ts)
| Stage | Threshold |
|---|---|
| Picking | 8 hours |
| Packing | 4 hours |
| Carrier handoff | 48 hours |
Thresholds are enforced in code — the model never invents or infers them.
Demo Orders (seeded synthetic data)
| Order ID | Scenario |
|---|---|
ord_clean_001 |
Fully delivered, no issues |
ord_pick_002 |
Stuck in picking (~12 h, threshold: 8 h) |
ord_pack_003 |
Stuck in packing (~7 h, threshold: 4 h) |
ord_carrier_004 |
Stuck at carrier handoff (~60 h, threshold: 48 h) |
ord_payfail_005 |
Failed payment, no fulfillment triggered |
ord_escalated_006 |
Stuck in picking, already has an existing escalation |
Architecture
Ops Engineer (natural-language query)
↓
Groq client — llama-3.3-70b-versatile
drives multi-turn tool-call loop (max 10 iterations)
↓ MCP JSON-RPC over SSE
MCP Server (Railway) — SSEServerTransport
↓ pg connection pool
PostgreSQL (Railway) — orders, payments, fulfillments, escalations
Transport is selected by environment: MCP_TRANSPORT=http → SSE (Railway), otherwise stdio (local dev).
Key Product Decisions
Escalation enforcement — 3 layers
A write operation that creates a manager-review ticket needs to be safe. Enforcement works at three independent levels:
- System prompt — instructs the model to only call
create_escalationon explicit single-order investigation requests, never during general listing queries - Business layer —
hasConfirmedAnomaly()re-queries the database before any insert; if no SLA breach or payment failure is confirmed, the function returns a blocked error and nothing is written - Database constraint —
UNIQUEonescalations.order_idprevents duplicates even under concurrent requests
Listing vs. investigation intent
General listing queries ("show me flagged orders") call list_flagged_orders and return evidence only. Specific order queries ("investigate ord_pick_002") follow the full chain and may escalate. This distinction is enforced in the system prompt and backed by the business layer — listing can never accidentally trigger a write.
Idempotency
create_escalation called twice for the same order returns created: false with the existing record. The anomaly gate still runs on the second call, so only genuinely anomalous orders can ever hold an escalation.
Running Tests
Tests use Node's built-in test runner against a live local database — no mocking.
# make sure local DB is running and seeded first
npm test
| Test | What it checks |
|---|---|
| Allowed path | ord_pick_002 (stuck in picking) → created: true |
| Blocked path | ord_clean_001 (delivered, healthy) → isError: true, error contains "blocked" |
| Idempotency | ord_escalated_006 called twice → both return created: false, same escalation ID |
| Payment failure | ord_payfail_005 (failed payment) → created: true |
Out of Scope
Frontend, authentication, real payment provider integrations, and CI/CD are intentionally excluded per the assignment brief.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。