Payment Reconciliation Copilot
Enables read-only investigation of payment transactions by building normalized timelines, detecting anomalies like duplicate charges and stuck refunds, and creating diagnostic escalations for human review. Never executes or modifies payment actions.
README
Payment Reconciliation Copilot
A small, safety-bounded MCP server for operations investigations such as “I was charged twice” and “my refund never arrived.” It turns normalized payment-event data into an auditable timeline, detects defined reconciliation anomalies, and creates a human-review escalation. It never executes, retries, captures, voids, or refunds payments.
Try the hosted service
| Endpoint | URL |
|---|---|
| Welcome | https://transactions-mcp.onrender.com/ |
| Health | https://transactions-mcp.onrender.com/health |
| Streamable HTTP MCP | https://transactions-mcp.onrender.com/mcp |
The hosted deployment contains synthetic data only. Configure any MCP client that supports Streamable HTTP with the /mcp URL. Client configuration syntax varies; conceptually:
{
"mcpServers": {
"payment-reconciliation": {
"url": "https://transactions-mcp.onrender.com/mcp"
}
}
}
After connecting, ask the client or its LLM:
Investigate the duplicate-charge complaint for
ORD-DUP-001. Use the connected tools, propose a resolution, and do not execute a payment action.
What it does
- Finds a transaction from an order ID, customer email, or amount plus date range.
- Returns its normalized event timeline and any payload conflicts.
- Detects duplicate-charge, stuck-refund, and out-of-order-webhook evidence.
- Produces one diagnostic escalation per anomaly for human review.
The design is intentionally read-heavy. Only anomalies and escalations may be written; transactions, provider state, and payment state are never changed by MCP tools.
MCP tools
| Tool | Input | Result | Safety boundary |
|---|---|---|---|
find_transaction |
order_id or customer_email or amount + date_range |
Transaction summary records | Read-only |
get_transaction_timeline |
transaction_id |
Ordered normalized events and linked conflicts | Read-only |
detect_anomaly |
transaction_id |
Existing or newly detected anomaly records | Writes only idempotent anomaly audit records |
propose_resolution |
anomaly_id |
Existing or newly created escalation with reasoning | Writes only one diagnostic escalation; never executes anything |
Data model and idempotency
The database, not application memory, enforces the important guarantees:
| Guarantee | Database constraint | Retry behavior |
|---|---|---|
| First provider event wins | UNIQUE (provider_id, provider_event_id) on transaction_events |
A conflicting later payload is recorded in event_conflicts; the original is never overwritten. |
| One conflict per distinct conflicting payload | UNIQUE (transaction_event_id, conflicting_payload_hash) |
Repeated delivery of the same conflict does not create another row. |
| Same evidence, same anomaly | UNIQUE (transaction_id, type, evidence_hash) on anomalies |
Detection updates only last_seen_at; evidence remains immutable. |
| One escalation per anomaly | UNIQUE (anomaly_id) on escalations |
Retried proposals return the same escalation regardless of status. |
evidence_hash is generated from canonically ordered evidence event IDs and the detection window. This makes detection retries safe while allowing new evidence to produce a separate anomaly.
Demo scenarios
The synthetic seed contains 24 transactions across MockStripe and MockAdyen:
| Scenario | Order ID | Expected result |
|---|---|---|
| Duplicate charge | ORD-DUP-001 |
duplicate_charge from two webhook events sharing one intent_id |
| Stuck refund | ORD-REFUND-001 |
stuck_refund from an attempt without a completion |
| Out-of-order webhook | ORD-ORDER-001 |
out_of_order_webhook |
| Conflicting provider payload | ORD-CONFLICT-001 |
Timeline includes an event_conflicts record |
For the duplicate case, call detect_anomaly twice and then call propose_resolution twice. The anomaly and escalation IDs should remain stable across retries.
Run locally
Prerequisites
- Node.js 20+
- PostgreSQL database dedicated to this synthetic demo
Setup
npm ci
Copy-Item .env.example .env
# Set DATABASE_URL in .env to a disposable local/development Postgres database.
npm run db:migrate
npm run db:seed
Warning:
npm run db:seeddeletes all records in this project’s six tables before rebuilding the deterministic synthetic fixtures. Never run it against real, shared, or production-like data.
Commands
npm run dev # Local development server with tsx watch
npm run build # Emit production JavaScript to dist/
npm run start # Run compiled production server
npx tsc --noEmit # Strict type check
npm run test -- --run # Focused integration suite
npm run db:generate # Generate a Drizzle migration after schema changes
npm run db:migrate # Apply pending migrations
npm run db:seed # Reset and seed the synthetic database
Local endpoints are http://localhost:3000/, /health, and /mcp.
Test and verification
The focused integration suite uses the real disposable Postgres database and resets synthetic fixtures before each test:
npm run test -- --run
It verifies:
find_transactionrejects ambiguous input and does not change mutable records.get_transaction_timelinereturns linked payload conflicts without writes.- Calling
detect_anomalyrepeatedly returns one anomaly for the same evidence. - Calling
propose_resolutionrepeatedly returns one escalation, including after escalation status changes.
For hosted verification, connect an MCP client to the deployed /mcp URL and run the duplicate-charge workflow in Demo scenarios. The deployment was also exercised through an LLM-connected MCP client.
Deployment
The service is deployed to Render as a Node web service. Its production build compiles TypeScript before starting Node:
Build command: npm ci --include=dev && npm run build
Start command: npm run start
Health check: /health
Runtime variables required by the service:
DATABASE_URL=<isolated synthetic/demo PostgreSQL connection string>
NODE_ENV=production
DB_POOL_MAX=3
Do not run the destructive synthetic seed automatically on every deployment. Apply migrations and seed a new isolated demo database deliberately.
Project layout
src/db/ Drizzle schema, pooled client, and deterministic seed
src/reconciliation/ Lookup, timeline, anomaly, and escalation behavior plus tests
src/mcp/ MCP server and tool registrations
src/index.ts Streamable HTTP endpoint, welcome/health routes, shutdown handling
drizzle/ Generated SQL migrations
ASSUMPTIONS_AND_EXCLUSIONS.md
AI_WORKLOG.md
WALKTHROUGH_SCRIPT.md
Submission assets
Safety reminder
This is a synthetic-data demonstration. The public endpoint is unauthenticated by intentional assignment scope, so it must never be pointed at real customer, transaction, or payment-provider data.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。