A Model Context Protocol (MCP) server that provides comprehensive access to Binance Futures API endpoints. This server implements all major trading, account management, and market data functionality as documented in the Binance Futures API.
- π Quick Start
- β¨ Features
- π¦ Installation
- βοΈ Configuration
- π οΈ Available Tools
- π‘ Example Usage
- π Security
- π API Reference
- π§ Development
- β Error Codes
- π€ Contributing
- π License
β οΈ Disclaimer- π¬ Support
-
Install the package:
pip install binance_futures_mcp
-
Run the server:
uvx binance_futures_mcp --binance-api-key "your_key" --binance-secret-key "your_secret"
-
Configure in your MCP client (see Configuration section for detailed setup)
- 11 essential trading tools across 2 categories (Account Information and Market Data)
- Proper authentication handling (rejects unauthenticated requests)
- Error handling and graceful degradation
- Real-time market data access
Install the package from PyPI:
pip install binance_futures_mcp
For containerized deployment:
# Clone the repository
git clone https://github.com/alexcandrabersiva/bin-mcp.git
cd binance-mcp-server
# Build the Docker image
docker build -t binance-mcp-server .
# Run with environment variables
docker run -e BINANCE_API_KEY="your_api_key" -e BINANCE_SECRET_KEY="your_secret_key" \
binance-mcp-server --binance-api-key "$BINANCE_API_KEY" --binance-secret-key "$BINANCE_SECRET_KEY"
Create a docker-compose.yml
:
version: '3.8'
services:
binance-mcp:
build: .
environment:
- BINANCE_API_KEY=${BINANCE_API_KEY}
- BINANCE_SECRET_KEY=${BINANCE_SECRET_KEY}
command: [
"--binance-api-key", "${BINANCE_API_KEY}",
"--binance-secret-key", "${BINANCE_SECRET_KEY}"
]
Then run:
docker-compose up
For development, you can install from source:
git clone https://github.com/bin-mcp/binance-mcp-server.git
cd binance-mcp-server
pip install -e ".[dev]"
Your Binance API key needs the following permissions:
- Futures Trading: For order placement and management
- Futures Reading: For account and market data access
This server can be integrated with various MCP clients. Here are configuration examples:
Add to your VS Code settings.json
:
{
"mcp": {
"servers": {
"binance": {
"command": "uvx",
"args": ["--from", "binance_futures_mcp", "binance-mcp-server.exe", "--binance-api-key", "your_api_key", "--binance-secret-key", "your_secret_key"]
}
}
}
}
Add to your Cursor configuration file (.cursor/mcp.json
):
{
"servers": {
"binance": {
"command": "uvx",
"args": ["--from", "binance_futures_mcp", "binance-mcp-server.exe", "--binance-api-key", "your_api_key", "--binance-secret-key", "your_secret_key"]
}
}
}
Add to your Windsurf configuration (.windsurf/mcp.json
):
{
"mcpServers": {
"binance": {
"command": "uvx",
"args": ["--from", "binance_futures_mcp", "binance-mcp-server.exe", "--binance-api-key", "your_api_key", "--binance-secret-key", "your_secret_key"]
}
}
}
Add to your Claude Desktop configuration file:
On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"binance": {
"command": "uvx",
"args": ["--from", "binance_futures_mcp", "binance-mcp-server.exe", "--binance-api-key", "your_api_key", "--binance-secret-key", "your_secret_key"]
}
}
}
- No path needed: With PyPI installation, you don't need to specify paths or working directories
- Set API credentials: Replace
your_api_key
andyour_secret_key
with your actual Binance API credentials - Alternative commands: You can also use
uvx binance_futures_mcp
orpython -m binance_mcp
- Security: For production use, consider storing credentials in environment variables
The server provides 11 essential tools organized into the following categories:
(5 tools)
get_account_info
- Get account informationget_balance
- Get account balanceget_position_info
- Get position informationget_position_mode
- Get position mode (Hedge vs. One-way)get_commission_rate
- Get commission rate
(6 tools)
get_exchange_info
- Get exchange trading rulesget_book_ticker
- Get best price/qty on the order bookget_price_ticker
- Get latest price for a symbolget_order_book
- Get order book depthget_klines
- Get candlestick dataget_mark_price
- Get mark price and funding rate
{
"tool": "place_order",
"arguments": {
"symbol": "BTCUSDT",
"side": "BUY",
"order_type": "MARKET",
"quantity": 0.001
}
}
{
"tool": "place_order",
"arguments": {
"symbol": "BTCUSDT",
"side": "BUY",
"order_type": "LIMIT",
"quantity": 0.001,
"price": 50000.0,
"time_in_force": "GTC"
}
}
{
"tool": "get_account_info",
"arguments": {}
}
{
"tool": "get_klines",
"arguments": {
"symbol": "BTCUSDT",
"interval": "1h",
"limit": 100
}
}
{
"tool": "get_24hr_ticker",
"arguments": {
"symbol": "BTCUSDT"
}
}
{
"tool": "get_taker_buy_sell_volume",
"arguments": {
"symbol": "BTCUSDT"
}
}
π Your Binance API key and secret remain completely local to your computer. The MCP server runs entirely on your machine; neither the package author nor any third-party remote service can access your credentials.
- β Store credentials in environment variables (recommended) or local config files
- β Keys are never transmitted unless you publish them
- β Never commit credentials to version control
- β Never share screenshots/logs containing credentials
- β Use API keys with minimal required permissions
- β IP-whitelist your keys when possible
- β Consider using Binance Testnet for development
-
Local Launch: Your editor/terminal launches the MCP server locally:
uvx binance_futures_mcp --binance-api-key $BINANCE_API_KEY --binance-secret-key $BINANCE_SECRET_KEY
-
Keys Stay Local: Your credentials exist only:
- In your environment variables or local config file
- On your computer's command line/process table
- In MCP process memory during HTTPS calls to Binance
-
No Telemetry: The package contains zero telemetry or analytics code
- β‘ Respects Binance's weight-based rate limits
- π Automatic order placement rate limiting
- π Automatic HMAC SHA256 signature generation
- π‘οΈ Comprehensive error handling with clear messages
- β Parameter validation before API calls
This server implements all endpoints documented in the Binance Futures API:
- Base URL:
https://fapi.binance.com
- API Type: Binance USD-S Margined Futures
- Authentication: API Key + HMAC SHA256 Signature
- Rate Limits: Respected automatically
For detailed parameter specifications, see the Binance Futures API Documentation.
binance-mcp-server/
βββ src/
β βββ binance_mcp/
β βββ __init__.py # Package initialization
β βββ __main__.py # CLI entry point
β βββ server.py # Main MCP server implementation
β βββ client.py # Binance API client
β βββ handlers.py # Tool execution handlers
β βββ tools.py # Tool definitions (11 trading tools)
β βββ config.py # Configuration management
βββ Dockerfile # Docker containerization
βββ .dockerignore # Docker build optimization
βββ pyproject.toml # Project configuration
βββ mcp-config.json # MCP client configuration example
βββ README.md # Documentation
- Modular Design: Separated concerns across multiple components
- Authentication: Secure API key handling with environment variables
- Error Handling: Graceful degradation and comprehensive error management
pytest
black src/
ruff check src/
Common Binance API error codes you might encounter:
Code | Description |
---|---|
-1121 |
Invalid symbol |
-2019 |
Margin is insufficient |
-1116 |
Invalid orderType |
-1013 |
Filter failure (PRICE_FILTER, LOT_SIZE, etc.) |
-1102 |
Mandatory parameter was not sent |
-1003 |
Too many requests (rate limit exceeded) |
For a complete list, see the Binance API Error Codes.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
For issues and questions:
- Check the Binance API Documentation
- Review the error codes in the API documentation
- Ensure your API credentials have the correct permissions