ecom-mcp

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.

Category
Visit Server

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:

  1. System prompt — instructs the model to only call create_escalation on explicit single-order investigation requests, never during general listing queries
  2. Business layerhasConfirmedAnomaly() 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
  3. Database constraintUNIQUE on escalations.order_id prevents 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.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured