Binance MCP Server for AI assistants. Execute trades, fetch live market data, and generate technical indicators (RSI/MACD) securely through Streamable HTTP.
Binance Streamable MCP Server
This project is a high-performance, secure Model Context Protocol (MCP) server designed to connect AI assistants (like Claude) with your Binance Spot and Futures accounts. Built on FastAPI and FastMCP, it provides advanced financial and trading tools, robust security features, terminal-aesthetic dashboards, and intelligent proxy/IP management for handling API key whitelisting requirements.
Key Features
- Multi-Market Support: Connects directly to Binance Spot and USDT-M Futures.
- Streamable HTTP MCP Transport: Seamless remote Claude.ai integration over standard HTTPS.
- Market Data Retrieval: Real-time prices, order books, OHLCV (candlesticks), and 24h tickers.
- On-Demand Technical Analysis: Built-in calculation of advanced indicators including RSI, MACD, and Bollinger Bands using
pandas-ta. - High Security & Hardening:
- AES-256-GCM encrypted API key management via admin dashboard.
- Multi-layered security middleware (rate limiting, HTTPS enforcement, MCP token verification).
- Dynamic Public IP Tracking: Multi-provider discovery system to pinpoint the real server IP, essential for Binance API Key IP Whitelisting (especially on platforms with dynamic exit nodes like Heroku).
Technical Stack
- Framework: FastAPI, Uvicorn, Streamable Starlette Sessions, Jinja2 Templates
- MCP Protocol: FastMCP (
mcplibrary) - Exchange SDK:
python-binance - Data & Math:
pandas,pandas-ta - Security:
pycryptodomex,itsdangerous
Environment Variables (.env)
These are the core environment variables to configure your server. For VPS, create a .env file in the root directory. For Heroku, set these in the "Settings > Config Vars" tab.
| Variable | Description |
|--------------------------|-------------------------------------------------------------------------------------------------|
| ADMIN_PASSWORD | A secure password for accessing the /admin web dashboard. |
| ADMIN_SESSION_SECRET | A long, random string used to sign dashboard session cookies. |
| MCP_SECURITY_TOKEN | A fixed bearer token your AI client uses to connect to the MCP server. |
| BINANCE_TESTNET | Set to true to use Binance testnet networks, or false for actual production. |
(Note: Actual Binance API keys are securely entered inside the web dashboard and stored encrypted; they are not hardcoded in the .env file.)
🚀 Deployment Instructions
Option 1: Deploying to Heroku (Recommended for ease of use)
The repository already contains the required Procfile and runtime.txt to seamlessly run on Heroku as a Web Dyno.
-
Create Heroku App:
- Log into the Heroku Dashboard and create a new project.
- Alternatively, use the CLI:
heroku create your-binance-mcp
-
Configure Environment Variables:
- Go to your app's Settings > Config Vars and click Reveal Config Vars.
- Add the following variables:
ADMIN_PASSWORD= (Your complex dashboard password)ADMIN_SESSION_SECRET= (A random string, e.g., generated withopenssl rand -hex 32)MCP_SECURITY_TOKEN= (A secure token for Claude.ai to use)BINANCE_TESTNET= (true / false)
-
Deploy Code:
- Link your GitHub repository in the Deploy tab OR use the Heroku CLI:
git push heroku main
- Link your GitHub repository in the Deploy tab OR use the Heroku CLI:
-
App Initialization & Whitelisting:
- Once deployed, visit your app URL:
https://your-binance-mcp.herokuapp.com/ - Log in with your
ADMIN_PASSWORD. - The dashboard will display the server's detected Public IP.
- Important: Go to your Binance account, log in, create a new API key (or edit an existing one), and whitelist this displayed IP. Give the key reading/trading permissions as you desire.
- Back in the server dashboard, input the Binance API Key and Secret, then save. They will be encrypted on the server.
- Once deployed, visit your app URL:
Option 2: Deploying to a VPS (Ubuntu / Debian Linux)
For tighter control over IP stability and costs, deploying directly to a Virtual Private Server (VPS) is ideal.
-
Clone the Repository:
git clone <your-repository-url> cd newbinance -
System Requirements & Python Environment: Ensure Python 3.10+ is installed (
python3 --version).sudo apt update sudo apt install python3-pip python3-venv python3 -m venv venv source venv/bin/activate -
Install Dependencies:
pip install -r requirements.txt -
Set Up the
.envFile:nano .envPaste your configurations:
ADMIN_PASSWORD=your_secure_password ADMIN_SESSION_SECRET=your_super_secret_key_string MCP_SECURITY_TOKEN=your_mcp_api_token BINANCE_TESTNET=false -
Run the Server Manager (Systemd): To keep the server running continuously and restart on crashes, set up an systemd service.
sudo nano /etc/systemd/system/binance-mcp.serviceAdd the following configuration (replace
/path/to/newbinanceandyour_user):[Unit] Description=Binance MCP Server After=network.target [Service] User=your_user Group=www-data WorkingDirectory=/path/to/newbinance Environment="PATH=/path/to/newbinance/venv/bin" ExecStart=/path/to/newbinance/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1 Restart=always [Install] WantedBy=multi-user.targetEnable and start the service:
sudo systemctl daemon-reload sudo systemctl start binance-mcp sudo systemctl enable binance-mcp -
Expose with Nginx (Reverse Proxy): Install Nginx to provide an HTTPS endpoint for your domain:
sudo apt install nginxConfigure an Nginx server block filtering port 80/443 onto 8000, and use Certbot (
sudo apt install certbot python3-certbot-nginx) to secure it with SSL. Claude requires an HTTPS link to connect via Streamable MCP. -
Final Steps:
- Log into your VPS public URL.
- Whitelist the standard VPS IP on Binance.
- Configure the keys inside the dashboard securely!
Using the Server with Claude
- In Claude Desktop or Claude Web App settings, add a new MCP Server using the remote HTTP mode.
- The URL will be
https://<your-server-url>/mcp. - Provide the authentication header with a Bearer token:
Authorization: Bearer YOUR_MCP_SECURITY_TOKEN. - Ask Claude queries like "Get the current MACD and RSI analysis for BTCUSDT on the spot market using a 4h interval."