The AI Trading MCP rig runs as two separate OS processes that communicate over a local HTTP bridge. The stdio MCP server (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/ai-trading-mcp/llms.txt
Use this file to discover all available pages before exploring further.
npx @backtest-kit/mcp) sits in the agent’s world and holds no trading state whatsoever — every tool call is an HTTP request forwarded to the trading process (@backtest-kit/cli), which owns the engine, the broker, and all live state. This split is intentional: the agent’s attack surface is three verbs; everything consequential lives behind the bridge.
Two Processes, One Contract
stdio MCP server
Spawned by Claude Code via
mcp.servers.json as npx @backtest-kit/mcp. Translates JSON-RPC tool calls into HTTP requests toward 127.0.0.1:60051. Holds no positions, no prices, no session.Trading process
Started by
npm start -- --paper or --live. Owns the backtest-kit engine, broker adapter, GramJS Telegram client, and the MCP HTTP bridge. All state lives here.error field means the engine rejected the call — a symbol not in the whitelist, a duplicate open, nothing to close. That error string is relayed to the agent verbatim as an isError: true tool result, so the model can read and react to it without any prompt-engineering shim.
Process Roles
| Responsibility | stdio MCP server | Trading process |
|---|---|---|
| JSON-RPC ↔ Claude | ✅ | — |
| HTTP forwarding to bridge | ✅ | — |
| Trading state (positions, signals) | — | ✅ |
| Engine (TP/SL, validation, risk) | — | ✅ |
| Broker (paper fills / Binance spot) | — | ✅ |
| GramJS Telegram scraper | — | ✅ |
Audit trail (dump/) | — | ✅ |
get_status renderer | — | ✅ |
The MCP HTTP Bridge
config/setup.config.ts calls serve() from @backtest-kit/mcp as the last statement after wiring all persistence backends:
127.0.0.1:60051 by default. Both the host and port are configurable:
| Variable | Default | Purpose |
|---|---|---|
CC_MCP_HOST | 127.0.0.1 | Bind address for the HTTP bridge |
CC_MCP_PORT | 60051 | Port for the HTTP bridge |
mcp.servers.json) is wired to Claude Code with no extra configuration needed:
The dashboard UI runs on port
:60050. The MCP bridge runs on :60051. Both are local-only — neither is exposed to the network in the default configuration.Persistence and Restart Safety
config/setup.config.ts configures live backends with .usePersist() and backtest counterparts with in-memory or local backends:
| Backend | Live mode | Backtest mode |
|---|---|---|
Storage | usePersist() — disk | useMemory() |
Recent | usePersist() — disk | useMemory() |
Notification | usePersist() — disk | useMemory() |
Memory | usePersist() — disk | useLocal() |
State | usePersist() — disk | useLocal() |
Session | usePersist() — disk | useLocal() |
Dump | useMarkdown() | useMarkdown() |
Markdown | useDummy() | useDummy() |
Log | useJsonl() | useJsonl() |
dump/data/ (signals, storage, notifications, recent, memory, state, sessions) survives a process restart. Restart the trading process and the open position, its TP/SL brackets, and its full history are exactly where they were. The paper trail — every get_status response ever sent to the model — is in dump/mcp/ and dump/images/.
Architecture Diagram
The flow from Telegram through both processes to Claude:The
error field in the HTTP envelope is either an empty string (success) or the exact message the engine produced. The stdio server relays it as an isError tool result — the model sees it as a first-class error it can reason about and act on.