使用说明
MCP网关系统
用于协调多个能力提供者的模型上下文协议(MCP)网关。
重大变更
⚠️ 版本 0.2.0(2025-10-24)- 系统现已设为只读
这个系统已经从一个混合读/写交易客户端转变为一个 只读市场数据分析工具所有订单管理功能均已移除。
发生了什么变化:
- ❌ 所有订单下单、取消和查询方法均已移除
- ❌ 已移除账户信息和交易历史查询功能
- 统一市场数据报告API已推出
- ✅ 所有市场数据分析功能均得到保留并增强
看 CHANGELOG.md 翻译为中文是:“变更日志文件(Markdown 格式)” 以获取完整的迁移指南。
概述
该系统采用分布式MCP(多内容提供者)架构,其中一个Python网关通过gRPC协调多个特定语言的提供者。每个提供者都通过一个统一的接口暴露其工具、资源和提示。
建筑学
AI Clients
├→ Claude Code (STDIO transport)
│ ↓
│ MCP Gateway (Python)
│ ├→ hello-go (Go provider) - Demo tools
│ ├→ hello-rs (Rust provider) - Demo tools
│ └→ binance-rs (Rust provider) - Cryptocurrency trading
│
└→ ChatGPT (SSE transport) 🆕
↓
SSE Gateway (Python)
└→ binance-rs (Rust provider) - Unified market data reports
生产部署
ChatGPT MCP 服务器 (SSE传输):
- **URL(网址)**https://mcp-gateway.thevibe.trading/sse/ 的中文翻译可以是:“https://mcp网关.thevibe交易平台/sse/”。不过,为了更符合中文表达习惯,我们通常会将网址中的域名部分稍作调整,使其更易于理解,但网址本身的形式保持不变。所以,也可以直接说这个网址是“thevibe交易平台的mcp网关上的sse路径”。但考虑到简洁性,上述翻译已经足够清晰
- 状态✅ 在生产环境中运行
- 版本0.2.0(只读市场数据分析)
- 特点/特性融合市场情报报告,配以高级分析功能
- 交通服务器发送事件(SSE)——ChatGPT集成所必需
- 文档见 ChatGPT 集成指南
服务提供商
hello-go(注:这个翻译保持了原英文的直接形式,因为“hello-go”可能是一个特定项目、工具或概念的名称,在中文中没有直接对应的翻译,所以通常保留原样。如果这是一个有特定含义的名称,需要根据具体上下文来翻译或解释。)
- 语言去
- 港口五万五千零五十一
- 工具echo.v1, sum.v1(演示工具)
- 状态✅ 已实施
hello-rs 翻译为中文是“你好-rs”(但通常我们直接说“hello-rs”在中文环境中也可以理解为“你好,rs”或保持原样,因为“rs”可能是一个特定项目、库或系统的名称,直接翻译可能失去其特定含义)。不过,如果“rs”没有特定含义,且为了更自然的表达,可以翻译为“你好,rs(项目/库/系统等)”。但最简洁且保留原意的翻译还是“你好-rs”
- 语言Rust(一种编程语言)
- 港口50052
- 工具(待实施)
- 状态🚧 计划中
币安-rs ⭐ 已准备好投入生产
- 语言Rust(一种编程语言)
- 港口五万五千零五十三
- 状态✅ 全面实施 (只读市场数据分析)
- 版本0.2.0
能力:
-
1. 主要工具新鲜/最新 统一市场数据报告
generate_market_report- 综合市场情报,整合8+个数据板块- 价格概览(24小时统计数据及趋势指标)
- 订单簿指标(价差、微价、不平衡度)
- 流动性分析(墙线、成交量分布、真空区域)
- 市场异常(带有严重程度徽章的检测)
- 微观结构健康(健康评分和部件状态)
- 数据健康状态(WebSocket连接性、新鲜度)
- 性能:60秒缓存,冷启动生成时间小于500毫秒,缓存访问时间小于3毫秒
-
11款个性化分析工具 (旧版,已被统一报告取代):
get_ticker- 24小时价格统计orderbook_l1/orderbook_l2- 订单簿快照get_recent_trades- 贸易历史get_order_flow- 买卖盘压力追踪get_volume_profile- 体积分配(POC/VAH/VAL)detect_market_anomalies- 异常模式检测get_microstructure_health- 市场健康评分get_liquidity_vacuums- 低流量价格区间检测orderbook_health- 实时订单簿健康指标
-
1 资源Markdown格式的数据快照
binance://market/{SYMBOL}- 实时市场概览
-
1 提示AI就绪分析模板
trading-analysis- 带有实时背景的市场分析
特点/特性:
- ✅ 实时WebSocket订单簿流(延迟低于200毫秒)
- ✅ 来自Binance API的实时市场数据
- ✅ 懒惰初始化 & 连接池
- ✅ 渐进式披露(根据需求,从L1深度到L2深度)
- ✅ 支持20个并发符号订阅
- ✅ 测试网与生产环境模式
看 providers/binance-rs/README.md(文件说明:Binance-RS 提供商的README文件) 以获取完整文档。
快速入门
与Claude代码一起使用🤖
MCP网关与Claude Code无缝集成。配置完成后,您可以提出自然语言问题:
You: "Generate a comprehensive market report for Bitcoin"
Claude: [Uses binance.generate_market_report tool]
Response:
# Market Data Report - BTCUSDT
Generated: 2025-10-24 12:00:00 UTC 🟢
## Price Overview
- Current Price: $106,841.00 📈
- 24h Change: +0.43% (+$459.00)
- 24h High/Low: $107,200.00 / $105,800.00
- Volume: 1,234.56 BTC ($131.8M)
## Order Book Metrics
- Spread: 0.01% (1.0 bps)
- Microprice: $106,840.50
- Imbalance: 58% bid-heavy 📊
## Liquidity Analysis
- Buy Wall: $106,500 💪 Strong (125.5 BTC)
- Volume Profile POC: $106,750
[... 5 more sections ...]
You: "Show me ETHUSDT with just price and liquidity sections"
Claude: [Uses generate_market_report with custom options]
Response: [Markdown report with only requested sections]
You: "Analyze trading opportunities for Bitcoin"
Claude: [Uses trading-analysis prompt with live market data]
Response: [Detailed analysis combining report data with AI insights]
为Claude代码设置:
# Configure MCP server (already done in .claude/settings.json)
claude mcp add --transport stdio mcp-gateway -- \
bash -c "cd mcp-gateway && uv run python -m mcp_gateway.main"
# Start your session
claude # MCP gateway starts automatically
与ChatGPT一起使用🤖🆕
MCP网关现已通过SSE传输方式支持ChatGPT。统一市场数据报告提供全面的市场情报!
ChatGPT的设置:
- 启用 开发者模式 在ChatGPT中(需购买Plus/Pro版)
- 首选 设置 → MCP服务器 → 添加服务器
- 配置SSE终端节点:
- 服务器URL:
https://mcp-gateway.thevibe.trading/sse/ - 交通SSE(服务器发送事件)
- 服务器URL:
示例用法:
You: "Generate a full market report for BTCUSDT"
ChatGPT: [Uses binance_generate_market_report tool]
Response: [Complete markdown report with 8 sections: price, orderbook,
liquidity, anomalies, health, etc. - cached for 60s]
You: "Show me just the price and liquidity analysis for ETHUSDT"
ChatGPT: [Uses binance_generate_market_report with options]
Request: {"symbol": "ETHUSDT", "options": {"include_sections": ["price_overview", "liquidity_analysis"]}}
Response: [Customized report with only requested sections]
You: "What's the order book health for BTCUSDT?"
ChatGPT: [Uses binance_orderbook_health tool - legacy individual tool]
Response: [Quick health metrics snapshot]
见 CHATGPT_INTEGRATION.md(文件名可译为“CHATGPT集成指南.md”或保持原样,根据上下文决定是否需要翻译文件名) 请参阅详细的设置指南。
手动设置
先决条件
- Python 3.11+ 配合 uv 使用
- Go 1.21+(用于 hello-go 提供者)
- Rust 1.75+(用于 binance-rs 提供商)
- Protocol Buffers 编译器(protoc)
构建所有提供程序
# Generate protobuf stubs
make proto-gen
# Build Go provider
cd providers/hello-go && go build -o bin/hello-go cmd/server/main.go
# Build Rust providers
make build-binance
运行系统
1号航站楼 - 启动服务提供商:
# hello-go
make run-hello-go
# binance-rs (in another terminal)
make run-binance
2号航站楼 - 起始关口:
make run-gateway
配置
在(系统/配置中)配置提供者 mcp-gateway/providers.yaml:
providers:
- name: hello-go
type: grpc
address: localhost:50051
enabled: true
- name: binance-rs
type: grpc
address: localhost:50053
enabled: true
metadata:
description: "Binance cryptocurrency trading provider"
features: ["orderbook"]
对于 binance-rs,还需要设置环境变量:
export BINANCE_API_KEY="your_api_key"
export BINANCE_API_SECRET="your_api_secret"
export BINANCE_BASE_URL="https://testnet.binance.vision"
API 参考文档
统一市场数据报告
工具: generate_market_report
生成包含8个以上数据部分的全面市场情报报告,同时提供智能缓存和定制化选项。
参数:
{
"symbol": str, # Required: Trading pair (e.g., "BTCUSDT", "ETHUSDT")
"venue": str, # Optional: Exchange venue (default: "binance")
"options": { # Optional: Report customization
"include_sections": list[str], # Sections to include (default: all)
"volume_window_hours": int, # Volume analysis window (default: 24)
"orderbook_levels": int # Order book depth (default: 20)
}
}
可用部分:
"price_overview"- 24小时价格统计及趋势指标"orderbook_metrics"- 点差、微价、买卖不平衡"liquidity_analysis"- 流动性墙、成交量分布图、真空区域"market_microstructure"- 订单流分析(占位符)"market_anomalies"- 带严重性徽章的异常检测"microstructure_health"- 健康评分和组件状态"data_health"- WebSocket连接性和数据新鲜度
回应:
{
"markdown_content": str, # Complete formatted report
"symbol": str, # Trading pair
"generated_at": int, # Unix timestamp (milliseconds)
"data_age_ms": int, # Data freshness indicator
"failed_sections": list[str],# Sections that failed to generate
"generation_time_ms": int # Report generation time
}
示例:
完整报告(所有章节):
await client.generate_market_report(symbol="BTCUSDT")
自定义报告(特定部分):
await client.generate_market_report(
symbol="ETHUSDT",
options={
"include_sections": ["price_overview", "liquidity_analysis"],
"volume_window_hours": 48,
"orderbook_levels": 50
}
)
演出:
- 冷生成时间:<500毫秒
- 缓存检索:<3毫秒
- 缓存TTL:60秒
- 针对缺失数据源的优雅降级
从v0.1.0版本迁移:
如果你正在使用单个工具:
# BEFORE (v0.1.0 - no longer works)
ticker = await client.get_ticker(symbol="BTCUSDT")
account = await client.get_account()
trades = await client.get_my_trades(symbol="BTCUSDT")
# AFTER (v0.2.0 - unified report)
report = await client.generate_market_report(symbol="BTCUSDT")
# Access report.markdown_content for formatted output
见 CHANGELOG.md 翻译为中文是:“更改日志文件(Markdown 格式)” 以获取完整的迁移指南。
测试
# Run all tests
make test
# Test individual provider
cd providers/binance-rs && cargo test
发展
添加新的提供商
- 创建
providers/{name}/目录 - 实施
provider.protogRPC服务 - 添加到
providers.yaml - 更新 Makefile,添加构建/运行目标
协议合同
所有供应商均实施 /pkg/proto/provider.proto:
ListCapabilities- 发现工具/资源/提示Invoke- 执行工具ReadResource- 获取资源GetPrompt- 生成提示Stream- 事件流(可选)
项目结构
mcp-trader/
├── mcp-gateway/ # Python MCP gateway
│ ├── mcp_gateway/
│ │ ├── main.py # FastMCP server (STDIO transport)
│ │ ├── sse_server.py # SSE server for ChatGPT 🆕
│ │ ├── adapters/ # gRPC clients
│ │ ├── tools/ # Search & fetch tools 🆕
│ │ └── validation.py
│ └── providers.yaml # Provider configuration
├── providers/
│ ├── hello-go/ # Go demo provider
│ ├── hello-rs/ # Rust demo provider
│ └── binance-rs/ # Binance market data provider (read-only)
│ └── src/
│ ├── report/ # Unified report generator 🆕
│ └── orderbook/
│ └── analytics/ # Advanced analytics module
├── infra/ # Production deployment 🆕
│ ├── deploy-chatgpt.sh # ChatGPT SSE deployment script
│ ├── binance-provider.service # Systemd service
│ ├── mcp-gateway-sse.service # SSE gateway service
│ └── nginx-mcp-gateway.conf # NGINX reverse proxy
├── pkg/
│ ├── proto/ # Shared protobuf contracts
│ └── schemas/ # JSON schemas
└── Makefile
文档
币安提供商
- 币安服务提供商指南 - 完整的供应商文档
- ChatGPT 集成指南 - 为ChatGPT设置SSE(服务器发送事件)
- 集成测试 - 测试结果
网关与部署
规格
更新日志
- CHANGELOG.md(版本日志文件) - 版本历史和迁移指南
许可证
请参阅LICENSE文件。