Binance MCP Server
Access the Binance Futures API for trading, account management, and market data.
Binance MCP Server
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.
š Table of Contents
- š Quick Start
- ⨠Features
- š¦ Installation
- āļø Configuration
- š ļø Available Tools
- š” Example Usage
- š Security
- š API Reference
- š§ Development
- ā Error Codes
- š¤ Contributing
- š License
- ā ļø Disclaimer
- š¬ Support
š Quick Start
-
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)
⨠Features
- 17 essential trading tools across 2 categories (Account Information and Market Data)
- Smart ticker data caching with 5-minute refresh cycle
- Proper authentication handling (rejects unauthenticated requests)
- Active symbol filtering (excludes delisted tokens)
- Error handling and graceful degradation
- Real-time market data access
- Complete order management suite
- Risk management tools
š¦ Installation
Option 1: PyPI Installation (Recommended)
Install the package from PyPI:
pip install binance_futures_mcp
Option 2: Docker Deployment
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"
Docker Compose (Optional)
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
Development Installation
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]"
āļø Configuration
API Requirements
Your Binance API key needs the following permissions:
- Futures Trading: For order placement and management
- Futures Reading: For account and market data access
MCP Client Setup
This server can be integrated with various MCP clients. Here are configuration examples:
VS Code
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"]
}
}
}
}
Cursor
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"]
}
}
}
Windsurf
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"]
}
}
}
Claude Desktop
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"]
}
}
}
Configuration Notes
- 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
š ļø Available Tools
The server provides 17 essential tools organized into the following categories:
Account Information
(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
Market Data
(12 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_24hr_ticker
- Get 24hr price change statisticsget_top_gainers_losers
- Get top gainers and losersget_market_overview
- Get overall market statisticsget_order_book
- Get order book depthget_klines
- Get candlestick dataget_mark_price
- Get mark price and funding rateget_aggregate_trades
- Get compressed/aggregate trades listget_funding_rate_history
- Get funding rate historyget_taker_buy_sell_volume
- Get taker buy/sell volume ratio
š” Example Usage
Place a Market Order
{
"tool": "place_order",
"arguments": {
"symbol": "BTCUSDT",
"side": "BUY",
"order_type": "MARKET",
"quantity": 0.001
}
}
Place a Limit Order
{
"tool": "place_order",
"arguments": {
"symbol": "BTCUSDT",
"side": "BUY",
"order_type": "LIMIT",
"quantity": 0.001,
"price": 50000.0,
"time_in_force": "GTC"
}
}
Get Account Information
{
"tool": "get_account_info",
"arguments": {}
}
Get Market Data
{
"tool": "get_klines",
"arguments": {
"symbol": "BTCUSDT",
"interval": "1h",
"limit": 100
}
}
Get 24hr Price Statistics
{
"tool": "get_24hr_ticker",
"arguments": {
"symbol": "BTCUSDT"
}
}
Get Taker Buy/Sell Volume Ratio
{
"tool": "get_taker_buy_sell_volume",
"arguments": {
"symbol": "BTCUSDT"
}
}
š Security
API Key Security
š 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.
Key Security Points:
- ā 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
How It Works:
-
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
Rate Limiting & Error Handling
- ā” 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
š API Reference
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.
š§ Development
Project Structure
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 (17 trading tools)
ā āāā cache.py # Smart ticker data caching
ā āāā 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
Architecture Overview
- Modular Design: Separated concerns across multiple components
- Smart Caching: 5-minute ticker cache with background refresh
- Authentication: Secure API key handling with environment variables
- Error Handling: Graceful degradation and comprehensive error management
- Active Symbol Filtering: Excludes delisted tokens automatically
Running Tests
pytest
Code Formatting
black src/
ruff check src/
ā Error Codes
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.
š¤ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
š License
MIT License - see LICENSE file for details.
ā ļø Disclaimer
ā ļø IMPORTANT: This software is for educational and development purposes. Trading cryptocurrencies involves substantial risk. Use at your own risk and never trade with money you cannot afford to lose.
š¬ Support
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
Related Servers
Azure AHDS FHIR MCP Server
An MCP server implementation for interacting with Azure Health Data Services FHIR.
Code Ocean MCP Server
Search and run capsules, execute pipelines, and manage data assets on the Code Ocean platform.
DataWorks
A Model Context Protocol (MCP) server that provides tools for AI, allowing it to interact with the DataWorks Open API through a standardized interface. This implementation is based on the Aliyun Open API and enables AI agents to perform cloud resources operations seamlessly.
Dataloop MCP
Integrate with the Dataloop AI platform for data management and annotation using a Docker-based stdio interface.
Joe Sandbox
Analyze files and extract Indicators of Compromise (IOCs) by interacting with the Joe Sandbox Cloud service.
Kaltura MCP Server
A server for performing secure, read-only operations on the Kaltura API.
Pangea MCP Server
An MCP server for integrating with Pangea's security APIs, including Secure Audit Log.
Honeycomb MCP
Interact with Honeycomb observability data using the Model Context Protocol.
Coolify MCP Server
An MCP server for integrating with Coolify, the self-hostable alternative to Netlify and Vercel.
kubectl MCP Plugin
An MCP server for kubectl, enabling AI assistants to interact with Kubernetes clusters through a standardized protocol.