M
Market Data MCP
by @Alby1228
MCP server by Alby1228
Created 2/3/2026
Updated about 12 hours ago
README
Repository documentation and setup instructions
Market-Data-MCP
基于 Spring Boot 的 MCP HTTP 服务,封装 Binance Spot 市场数据能力(最新价/深度/K线/交易对信息),内置权重限流、退避与 Redis 缓存。
功能概览
spot.getTickerPrice:获取最新价(可传symbol)spot.getDepth:获取深度(symbol必填,limit可选)spot.getKlines:获取 K 线(symbol、interval必填)spot.getExchangeInfo:获取交易对信息(可传symbol)
启动前配置
编辑 src/main/resources/application.yml:
spring.data.redis.url:请填写 Redis 连接串- 例如:
redis://:password@localhost:6379/0 - 留空会导致 Redis 连接失败
- 例如:
- 其他可选配置:Binance base URL、权重阈值、缓存 TTL
启动方式
mvn spring-boot:run
默认端口:8080
MCP 调用方式
1) 列出工具
请求:
curl -s -X POST http://localhost:8080/mcp/tools/list
响应示例::
{
"tools": [
{
"name": "spot.getTickerPrice",
"description": "获取现货最新价(支持指定 symbol 或全市场)",
"inputSchema": {
"type": "object",
"properties": { "symbol": { "type": "string", "description": "交易对,例如 BTCUSDT(可选)" } },
"required": []
}
}
]
}
2) 调用工具
请求:
curl -s -X POST http://localhost:8080/mcp/tools/call \
-H "Content-Type: application/json" \
-d '{
"name": "spot.getKlines",
"arguments": {
"symbol": "BTCUSDT",
"interval": "1m",
"limit": 100
}
}'
响应示例:
{
"success": true,
"data": [
[1700000000000, "35000.0", "35100.0", "34950.0", "35050.0", "12.34", 1700000059999, "431234.56", 120, "6.12", "214000.00", "0"]
]
}
端点与参数说明
spot.getTickerPrice
- 参数:
symbol(可选)
spot.getDepth
- 参数:
symbol(必填)limit(可选,默认100,可选值:5/10/20/50/100/500/1000/5000)
spot.getKlines
- 参数:
symbol(必填)interval(必填,常用:1m/5m/1h/1d,需为 Binance 官方允许值)startTime(可选,毫秒)endTime(可选,毫秒)limit(可选,范围 1-1000)
spot.getExchangeInfo
- 参数:
symbol(可选)
限流与错误处理
- 会读取
X-MBX-USED-WEIGHT-*头并进行本地限速。 - 当 Binance 返回
429/418时遵循Retry-After退避。 - 触发限流时返回
429,字段包含retryAfterMillis。
常见问题
- 为什么启动后报 Redis 连接错误?
- 请检查
spring.data.redis.url是否正确配置。
- 请检查
Quick Setup
Installation guide for this server
Installation Command (package not published)
git clone https://github.com/Alby1228/Market-Data-MCP
Manual Installation: Please check the README for detailed setup instructions and any additional dependencies required.
Cursor configuration (mcp.json)
{
"mcpServers": {
"alby1228-market-data-mcp": {
"command": "git",
"args": [
"clone",
"https://github.com/Alby1228/Market-Data-MCP"
]
}
}
}