trading-platform-mcp-server

trading-platform-mcp-server

Enables Claude to monitor and execute Binance trading strategies through a bounded MCP tool interface, with risk controls and audit logging.

Category
访问服务器

README

Trading Platform v2 — Binance Intelligence & Execution

Binance-only trading intelligence and execution platform with Claude connected through MCP. Production-grade Python monorepo.

Architecture

Claude (reasoning layer)
    │  MCP bounded tool interface
    ▼
mcp-server ─────────────────────────────────────────────────
                                                            │
gateway-api (REST + WebSocket, web/mobile clients)          │
    │                                                       │
    ▼                                                       ▼
strategy-service ──► execution (paper / live orders)
    │                      │
    │               private user stream
    ▼                      │
analytics ◄────────────────┘
    │
    ▼
normalizer
    │
    ▼
binance-ingest (WebSocket streams + REST polling)
    │
    ▼
Redis Streams + Redis hot state
    │
    ▼
Postgres (persistent history + all business records)

Services

Service Port Purpose
gateway-api 8000 REST + WebSocket API
binance-ingest 8001 Raw stream ingest
normalizer 8002 Payload normalization + hot state
analytics 8003 Derived metrics + decision snapshots
strategy-service 8004 Strategy CRUD, eval, intents
execution 8005 Risk validation + order routing
mcp-server 8006 Claude MCP tool interface

Phase Status

Phase Description Status
1 Shared foundation (schemas, Redis, DB, utils, infra) ✅ Complete
2 Binance ingest (all stream types + private user stream) 🔲 Next
3 Normalizer (all event types + hot state) 🔲
4 Analytics (10 engines + decision snapshot builder) 🔲
5 Strategy service (CRUD, versioning, eval, simulation) 🔲
6 Execution — paper mode (validation + risk engine) 🔲
7 Execution — live (Binance orders + fill reconciliation) 🔲
8 MCP server (25 bounded tools + OAuth + audit) 🔲
9 Gateway API (all REST + WebSocket routes) 🔲
10 Hardening (tests, observability, incident workflows) 🔲

Quick Start (local dev)

Prerequisites

  • Python 3.12
  • Docker + Docker Compose

1. Install shared package

cd C:\Users\ahsan\trading-platform-v2
pip install -e .

2. Copy and configure env

Copy-Item .env.example .env
# Edit .env with your Binance keys and secrets

3. Start infrastructure

docker compose -f infra/docker-compose.yml up postgres redis -d

4. Run migrations

$env:PYTHONPATH = "C:\Users\ahsan\trading-platform-v2"
alembic -c migrations/alembic.ini upgrade head

5. Start a service (example: gateway-api)

$env:PYTHONPATH = "C:\Users\ahsan\trading-platform-v2"
python -m uvicorn services.gateway_api.main:app --host 0.0.0.0 --port 8000 --reload

6. Run tests

$env:PYTHONPATH = "C:\Users\ahsan\trading-platform-v2"
python -m pytest tests/unit/ -v

Key Design Principles

  1. Claude is the controller — never the direct execution layer
  2. Strategy ≠ Execution — TradeIntent objects cross the boundary, never raw orders
  3. Execution is the only Binance caller — no other service may place orders
  4. Private user streams are truth — fills, balances, positions come from there
  5. Raw ≠ Derived — never mixed in the same API field
  6. MCP is bounded — approval levels and symbol policies enforced on every tool call
  7. Paper = Live pipeline — same validation, different execution path
  8. Everything is auditable — audit_log, mcp_tool_calls, execution_events for every action
  9. Idempotent jobs — job_id + deterministic client_order_id prevent duplicate execution

Redis Key Domains

All keys are built via shared.redis.keys.RedisKeys — never inline strings.

  • market:{type}:{symbol}:* — hot market state
  • analytics:{type}:{symbol}:* — derived analytics
  • account:{user_id}:* — account state
  • risk:{user_id}:* — risk state and limits
  • strategy:{id}:* — active strategy state
  • approval:{user_id}:level — current approval level
  • kill_switch:{account_id} — global kill switch flag
  • pause:user:{account_id} — per-user trading pause
  • pause:symbol:{account_id}:{symbol} — per-symbol pause
  • cooldown:{account_id}:{symbol} — post-loss cooldown
  • job:lock:{job_id} — execution job idempotency lock

Redis Streams

  • stream:binance:raw — raw Binance payloads
  • stream:binance:normalized — canonical NormalizedEvent records
  • stream:analytics:derived — analytics engine outputs
  • stream:strategy:intents — TradeIntent objects
  • stream:execution:events — execution lifecycle events
  • stream:mcp:audit — MCP tool call audit trail

Database

28 tables across 5 domains:

  • Market: symbols, candles, trade_history, funding_history, oi_history, liquidation_events, wall_events, market_snapshots
  • Account: users, exchange_accounts, api_credentials_ref, balances, positions, orders, fills
  • Execution: execution_jobs, execution_events, risk_policies, approval_levels
  • Strategy: strategies, strategy_versions, strategy_runs, strategy_evaluations, strategy_actions, strategy_rollbacks
  • Audit: mcp_sessions, mcp_tool_calls, audit_log, incident_log, account_update_reasons

Approval Levels

Level Value Can Do
L0 l0_readonly Read data only
L1 l1_simulation Run simulations
L2 l2_paper Paper trading
L3 l3_assisted_live Live with confirmation
L4 l4_bounded_auto Bounded auto-execution

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选