e-commerce MCP Server
Enables handling of e-commerce exceptions like stuck packages, missing items, and refund escalations through MCP tools, with safety guardrails and PostgreSQL persistence.
README
AI-Native Commerce Operations MCP Server
This repository contains a Model Context Protocol (MCP) server built in TypeScript, acting as an operational agent for e-commerce exception handling (e.g., stuck packages, missing items, refund escalations).
Features
- MCP Tools: Exposes capabilities to check order details, tracking status, evaluate refund policies, and safely execute remediation actions.
- Safety First: Hardcoded safety guardrail where any refund action above $150 is automatically blocked and flagged for human approval (
PENDING_APPROVAL). - PostgreSQL Persistence: Complete operational schema including tracking order states, remediation actions, refunds with idempotency, and immutable audit logs.
- SSE Transport: Uses standard Express server with Server-Sent Events (SSE) for reliable MCP transport.
Setup Instructions
Prerequisites
- Node.js (v18+)
- Docker & Docker Compose (for local PostgreSQL database)
Installation
- Install dependencies:
npm install - Start the local PostgreSQL database:
docker-compose up -d - Run the database migrations and seed synthetic data:
npm run db:migrate npm run db:seed
Running the Server
Start the MCP server in development mode:
npm run dev
The server will start on port 3000:
- SSE Endpoint:
http://localhost:3000/sse - Messages Endpoint:
http://localhost:3000/messages
You can connect to this server using an MCP client (like Claude Desktop) by configuring it to use the SSE transport with the URL http://localhost:3000/sse.
Testing
Run the vitest test suite to verify the core safety boundaries and business logic:
npm test
Product Decisions & Tradeoffs
- Direct PostgreSQL Client (
pg) over ORMs: To prioritize a "small, coherent solution" and respect the provided raw SQL schema without abstracting it away, we used the standardpgdriver instead of heavy ORMs (Prisma, Drizzle). This keeps the migration and execution path 1-to-1 with the schema. - Express + SSE for Transport: Since the goal is a "remotely accessible" MCP server, Server-Sent Events (SSE) is chosen as it's the standard for remote MCP communication over HTTP, allowing a seamless connection with remote LLM clients without dealing with Stdio complexities over networks.
- Audit Logging Strategy: Audit logs are inserted synchronously alongside the remediation actions within a database transaction. A tradeoff here is slightly longer transaction times in exchange for guaranteed logging correctness.
- Exclusions: As requested by the assignment scope, this solution excludes authentication, frontend applications, and full CI/CD deployment pipelines. The focus is strictly on a robust MCP server and accurate backend database operations.
Available MCP Tools
get_order_details: Fetch full order state, items, and customer risk score.check_tracking_status: Fetch carrier shipment logs and current status.evaluate_refund_policy: Checks refund eligibility based on SLA, customer risk, and tracking status.execute_remediation: Triggers an action (REFUND,REPLACEMENT,CARRIER_CLAIM). Safely catches high-value refunds and enforces an immutable audit trail.
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.