Skip to main content
Glama
Akash5908

Commerce Ops MCP Server

by Akash5908

Commerce Ops MCP Server

An AI-native, remotely hosted MCP server written in TypeScript that empowers operations teams and AI agents to investigate and resolve e-commerce order exceptions โ€” damaged items, lost shipments, refunds, and replacement dispatches โ€” safely and autonomously.


๐ŸŽฏ Problem & User

User: An operations agent (human or AI) handling post-delivery exceptions in an online commerce business.

Problem: When an order is damaged or lost, the ops agent must:

  1. Investigate the order and understand what happened

  2. Check if a replacement item is available in inventory

  3. Process a partial or full refund safely (without overpaying or duplicating)

  4. Create a replacement shipment if appropriate

Today this requires jumping between systems. This MCP server gives a single, safe interface for the full workflow.


Related MCP server: AgentPay MCP Server

๐Ÿ”„ End-to-End Workflow

AI Agent receives: "Customer Alex's order ORD-1001 arrived damaged"
         โ”‚
         โ–ผ
[get_order_details]  โ”€โ”€โ†’  Order: DAMAGED, $120 total, 0 refunded
         โ”‚
         โ–ผ
[check_inventory]    โ”€โ”€โ†’  SKU-AUDIO-01: 13 units available
         โ”‚
         โ–ผ
[process_refund]     โ”€โ”€โ†’  $50 partial refund applied
  โ”œโ”€ Guardrail โ‘ : Rejects if amount > remaining balance
  โ””โ”€ Guardrail โ‘ก: Rejects duplicate idempotency key
         โ”‚
         โ–ผ
[create_shipment]    โ”€โ”€โ†’  Replacement shipment PENDING
  โ””โ”€ Guardrail โ‘ข: Only allowed for DAMAGED or LOST orders

๐Ÿ› ๏ธ MCP Tools

Tool

Description

Inputs

Guardrails

get_order_details

Fetch order status, items, tracking, refund history

orderId

Returns error if not found

check_inventory

Check available stock for a SKU

sku

Returns error if SKU not found

process_refund

Apply a partial or full refund

orderId, amount, reason, idempotencyKey

โ‘  Amount cap (โ‰ค remaining balance) โ‘ก Idempotency (rejects duplicate keys)

create_shipment

Dispatch a replacement item

orderId, address

โ‘ข Status check (DAMAGED or LOST orders only)


๐Ÿš€ Live Hosted URL

  • MCP SSE Endpoint: https://diligence-mcp-ops.onrender.com/sse

  • Health Check: https://diligence-mcp-ops.onrender.com/health

Note: The Render free tier spins down after 15 min of inactivity. Hit the health check URL first to warm it up.


๐Ÿ—๏ธ Architecture

src/
โ”œโ”€โ”€ index.ts          # Express server โ€” SSE + health endpoints
โ”œโ”€โ”€ server.ts         # MCP server factory โ€” reads tool registry, dispatches
โ”œโ”€โ”€ types/
โ”‚   โ””โ”€โ”€ index.ts      # Shared domain interfaces
โ”œโ”€โ”€ db/
โ”‚   โ””โ”€โ”€ mockData.ts   # Synthetic in-memory data (orders, inventory, refunds)
โ””โ”€โ”€ tools/
    โ”œโ”€โ”€ index.ts      # Tool registry barrel (toolRegistry[], toolHandlerMap)
    โ”œโ”€โ”€ getOrder.ts   # get_order_details tool
    โ”œโ”€โ”€ checkStock.ts # check_inventory tool
    โ”œโ”€โ”€ processRefund.ts  # process_refund tool
    โ””โ”€โ”€ createShipment.ts # create_shipment tool

Each tool exports a definition (JSON schema for ListTools) and a handler (async function for CallTool). Adding a new tool requires touching only one file (tools/index.ts).


๐Ÿงช Local Setup & Verification

# Install dependencies
npm install

# Run automated runtime verification (7 tests)
npm run test

# Start local dev server
npm run dev

# Build for production
npm run build

Expected test output:

๐Ÿงช Running MCP Tool Verification Tests...
1. Testing get_order_details (Valid Order)...      โœ…
2. Testing check_inventory...                      โœ…
3. Testing process_refund (Valid Amount)...        โœ…
4. Testing process_refund (Guardrail: Exceed Max Limit)... โœ…
5. Testing process_refund (Guardrail: Duplicate Key)...    โœ…
6. Testing create_shipment (Valid: DAMAGED order)...       โœ…
7. Testing create_shipment (Guardrail: DELIVERED order)... โœ…
โœ… All runtime verification tests executed successfully!

๐Ÿ“ Product Decisions & Scope

What's in scope

  • Order investigation and status lookup

  • Inventory availability checks for replacements

  • Safe refund processing with two guardrails

  • Replacement shipment creation with eligibility enforcement

  • End-to-end verification via in-memory MCP transport

What's intentionally out of scope

  • Authentication / user management โ€” not required for the assignment; a production version would use API keys or OAuth

  • Persistent storage โ€” in-memory state is sufficient for demo purposes; production would use a database

  • Frontend / UI โ€” the MCP is consumed by AI agents (Claude, Cursor) directly

  • Real payment gateway / inventory system โ€” synthetic data used throughout

  • CI/CD pipeline โ€” single-step Render deploy is sufficient


๐Ÿ”’ Assumptions

  1. All data is synthetic โ€” no real customer data or production credentials

  2. State is in-memory and resets on server restart (by design for demo)

  3. The idempotencyKey is provided by the calling agent; no server-side key generation

  4. A single active SSE connection is assumed (transport is not multiplexed)


โš ๏ธ Known Limitations & Next Steps

Limitation

Next Step

In-memory state โ€” resets on restart

Add a lightweight DB (SQLite / Postgres)

No auth on SSE endpoint

Add API key middleware

Single SSE transport instance

Use session-keyed transport map

Render free tier cold starts (~30s)

Upgrade to paid or use Railway

No pagination on order history

Add cursor-based pagination to get_order_details

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

โ€“Maintainers
โ€“Response time
โ€“Release cycle
โ€“Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Akash5908/diligence-mcp-ops'

If you have feedback or need assistance with the MCP directory API, please join our Discord server