mcp-binance-futures
A Model Context Protocol (MCP) server that enables any compatible AI model to autonomously trade Binance USDT-margined perpetual futures. Includes a separate paper-trading strategy lab that requires no credentials.
README
MCP Binance Futures
A Model Context Protocol (MCP) server that enables any compatible AI model to autonomously trade Binance USDT-margined perpetual futures. Includes a separate paper-trading strategy lab that requires no credentials.
Overview
This project provides two MCP servers:
| Server | File | Credentials Required | Real Orders |
|---|---|---|---|
| Binance Futures | server.py |
Yes | Yes |
| Strategy Lab | strategy_lab_server.py |
No | No (paper only) |
Binance Futures Server
The live trading server exposes tools for:
- Market scanning — ranks top-volume USDT pairs by momentum, RSI, volume spikes, and funding rates
- Position management — open LONG/SHORT with automatic stop-loss and take-profit
- Risk controls — hardcoded safety limits (max loss per trade, per day, max leverage, max positions)
- Autopilot — a single heartbeat tool the AI calls repeatedly to monitor, cut losses, take profits, and open new trades
Strategy Lab (Paper Only)
A zero-credential research environment that uses only public Binance Futures endpoints:
- Multi-method analysis — momentum, mean-reversion, breakout, or adaptive (auto-selects)
- Historical backtesting — replay with fees, slippage, and drawdown tracking
- Persistent paper account — simulated wallet with realistic cost modeling
- Market scanning — rank USDT perpetuals by signal strength
Safety Limits
The live server enforces these immutable constraints:
Max loss per trade: $10
Max loss per day: $50
Max simultaneous pos: 4
Max leverage: 20x
Max margin per trade: $30
Usable balance: 80% of available
The autopilot also enforces:
- Auto-cut at -25% ROE
- Auto-profit at +50% ROE
Requirements
- Python 3.11+
- A Binance account with Futures enabled (for the live server)
- API key and secret with Futures trading permissions
Installation
git clone https://github.com/cociugv/mcp-binance-futures.git
cd mcp-binance-futures
pip install -r requirements.txt
Configuration
Environment Variables
Copy the example environment file and fill in your credentials:
cp .env.example .env
Edit .env with your Binance API credentials:
BINANCE_API_KEY=your_api_key_here
BINANCE_API_SECRET=your_api_secret_here
Security: Never commit
.envto version control. The.gitignorealready excludes it.
For the Strategy Lab (no credentials needed)
The strategy lab uses only unauthenticated public endpoints. Optional environment variables:
STRATEGY_LAB_STATE_FILE=./strategy_lab_state.json
STRATEGY_LAB_STARTING_BALANCE=50
Running the Servers
Live Trading Server
# Load environment variables and start
# Linux/macOS:
export $(cat .env | xargs) && python server.py
# Windows PowerShell:
Get-Content .env | ForEach-Object { if ($_ -match '^([^#].+?)=(.*)$') { [System.Environment]::SetEnvironmentVariable($matches[1], $matches[2]) } }; python server.py
Strategy Lab (Paper Only)
python strategy_lab_server.py
Strategy Lab Runner (Standalone Loop)
# Single heartbeat
python strategy_lab_runner.py --once --target 100 --method adaptive
# Continuous loop every 5 minutes
python strategy_lab_runner.py --target 100 --method adaptive --every-seconds 300
MCP Integration
Registering with an AI Client
Add the server to your MCP client configuration. Example mcp.json:
{
"mcpServers": {
"binance-futures": {
"command": "python",
"args": ["path/to/server.py"],
"env": {
"BINANCE_API_KEY": "your_api_key_here",
"BINANCE_API_SECRET": "your_api_secret_here",
"PYTHONIOENCODING": "utf-8"
}
},
"binance-strategy-lab": {
"command": "python",
"args": ["path/to/strategy_lab_server.py"],
"env": {
"PYTHONIOENCODING": "utf-8"
}
}
}
}
Any AI model that supports MCP can drive these tools — Claude, GPT, Gemini, or any local model with an MCP-compatible client.
Available Tools
Live Server (server.py)
| Tool | Description |
|---|---|
futures_balance |
Account balance, margin usage, and safety limits |
futures_positions |
Active positions with PnL, ROE, liquidation price |
futures_scan |
Scan top pairs for momentum signals |
futures_long |
Open a LONG with automatic SL/TP |
futures_short |
Open a SHORT with automatic SL/TP |
futures_close |
Close a position at market |
futures_set_leverage |
Set leverage for a symbol |
futures_orders |
List open orders |
futures_cancel |
Cancel all orders for a symbol |
futures_price |
Current price and 24h stats |
futures_status |
Daily session status and safety state |
futures_autopilot |
Autonomous heartbeat: monitor, act, scan, instruct |
Strategy Lab (strategy_lab_server.py)
| Tool | Description |
|---|---|
lab_safety |
Execution limits and guarantees |
lab_methods |
Available analysis methods and cost model |
lab_scan |
Rank markets by signal strength |
lab_compare |
Compare all methods on one symbol |
lab_backtest |
Historical replay with fees and slippage |
lab_paper_tick |
One research + paper-trading heartbeat |
lab_paper_status |
Paper wallet and marked positions |
lab_paper_reset |
Reset the simulated ledger |
Architecture
server.py Live trading MCP server (requires credentials)
strategy_lab_server.py Paper-only MCP server (no credentials)
strategy_lab_app.py Application logic shared by MCP and CLI
strategy_lab.py Strategy engine + paper account primitives
binance_public.py Unauthenticated market-data adapter
strategy_lab_runner.py Standalone CLI loop for paper trading
Disclaimer
This software is provided for educational and research purposes. Trading cryptocurrency futures carries significant financial risk. Past performance (including backtests) does not guarantee future results. The authors are not responsible for any financial losses incurred through the use of this software. Use at your own risk.
License
MIT License — see LICENSE for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。