mcp-market-server
mcp-market-server
MCP (Model Context Protocol) 服务器以实时加密货币市场数据和模拟交易引擎的形式,通过标准化的工具调用对外提供服务——任何智能体(Claude Code、自定义多智能体系统)都可以查询 Bybit 并执行模拟交易。
该项目为 Tower Research Capital AI/ML 实习生申请而构建:展示了 MCP 集成、智能体工具调用、风险控制和生产级 Python。
架构
┌─────────────┐ MCP stdio ┌──────────────────┐ REST ┌─────────┐
│ Claude Code │ ◄───────────────► │ FastMCP Server │ ─────────► │ Bybit │
│ / Agent │ │ (tools.py) │ public API │ v5 │
└─────────────┘ └────────┬─────────┘ └─────────┘
│
┌────────▼─────────┐
│ Paper Engine │
│ SQLite + Risk │
└──────────────────┘Related MCP server: KirpyV3 MCP Server
提供的工具
工具 | 说明 |
| 任何交易对/时间框架的 OHLCV K 线 |
| L2 订单簿快照 |
| 最新价格 / 24 小时统计 |
| 模拟市价/限价订单(受风控保护) |
| 取消一笔未成交的模拟订单 |
| 未平仓仓位 + 未实现盈亏 |
| 未成交/已成交订单历史 |
| 按市价平掉仓位 |
| 现金余额、权益、已实现/未实现盈亏 |
风险控制(模拟交易引擎)
每笔订单的最大名义金额(
risk.max_order_notional_usd)最大允许未平仓仓位数(
risk.max_open_positions)每日亏损熔断——当日回撤超过下限时,交易将被禁用
每笔订单和每次决策都会写入审计日志表
设置
cd mcp-market-server
python -m venv .venv && .venv\Scripts\activate # Windows
pip install -e ".[dev]"
cp .env.example .env # optional overrides
pytest # run tests在 Claude Code 中注册
{
"mcpServers": {
"market": {
"command": "python",
"args": ["-m", "mcp_market_server.server"],
"cwd": "/absolute/path/to/mcp-market-server"
}
}
}或使用 CLI:
claude mcp add market -- python -m mcp_market_server.server演示提示词(注册后)
Fetch the last 100 hourly candles for BTCUSDT and summarize the trend.
Place a paper long of 0.01 BTCUSDT with a 2% stop loss and take profit at 3%.
Show my account, then flatten everything if unrealized PnL is worse than -$50.设计说明
仅使用公开端点——无需 API 密钥,也不涉及真实资金。模拟引擎按实时行情价格成交市价单,当价格触发时成交限价单。
SQLite 用于存储订单/仓位/成交/审计记录——零依赖持久化,就像量化交易台记录每一项决策一样。
风险层位于工具和引擎之间——与真实交易台的模式相同:策略提出,风险决定。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Free crypto-futures paper trading and live market data for AI agents. 31 tools; no key for data.
Live crypto + IDX stock market intelligence for AI agents — 19 tools, no API key.
Trade 16 crypto exchanges + MetaTrader 5 from your AI assistant via one MCP connection.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables MCP-compatible AI clients to access live crypto market data and AI-driven quantitative analysis, with structured outputs and full observability.-
- AlicenseBqualityDmaintenanceEnables AI agents to trade crypto with paper money, access market data, view leaderboards, and manage trading bots via an MCP-compatible interface.16MIT
- AlicenseAqualityCmaintenanceProvides live financial data for any LLM agent, including stock quotes, crypto prices, SEC filings, XBRL financials, FX rates, and macro indicators, through ten MCP tools.111MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to retrieve real-time cryptocurrency quotes, portfolio state, risk scores (0-100), and timestamped market context through MCP tools, replacing hallucinated prices with verifiable market data.MIT