MCP Server for Binance Spot Trading
mcp-server-cex-bn
This MCP Server provides comprehensive integration with Binance's spot and futures trading operations.
Features
Spot Trading Operations
- Execute spot trading operations (LIMIT/MARKET orders)
- Monitor account balances
- Track and manage open orders
- Cancel existing orders
Futures Trading Operations
- Create various types of futures orders (LIMIT, MARKET, STOP, TAKE_PROFIT, etc.)
- Manage leverage settings (1-125x)
- Monitor futures positions and account information
- Track funding rates
- Support for both one-way and hedge mode positions
- Advanced order types including trailing stops and reduce-only orders
Tools
API Configuration
configure_api_keys
Securely store your Binance API credentials:
Spot Trading Tools
create_spot_order
Create LIMIT or MARKET orders:
cancel_order
Cancel an existing order:
get_balances
Check your account balances:
get_open_orders
List all open orders:
Futures Trading Tools
create_futures_order
Create various types of futures orders:
set_futures_leverage
Adjust leverage for a trading pair:
get_futures_positions
Get all open futures positions:
get_futures_account
Get detailed futures account information:
get_funding_rate
Get funding rate for a futures symbol:
cancel_futures_order
Cancel an existing futures order:
Futures Trading Details
Position Modes
- One-way Mode: Single position per symbol
- Default mode, simpler position management
- Total position size is the sum of all orders
- Hedge Mode: Separate long and short positions
- Allows holding both long and short positions simultaneously
- Each position has independent margin requirements
Margin Types
- Isolated Margin: Fixed margin per position
- Risk is limited to the allocated margin
- Each position has its own leverage setting
- Cross Margin: Shared margin across positions
- Higher capital efficiency
- Shared risk across all positions
Funding Rate
Perpetual futures contracts use funding rates to keep futures prices aligned with spot prices:
- Positive rate: Longs pay shorts
- Negative rate: Shorts pay longs
- Payments occur every 8 hours
Security Considerations
Spot Trading Security
- Never commit API keys to version control
- Use environment variables or secure key storage
- Restrict API key permissions to only required operations
- Regularly rotate your API keys
Futures Trading Security
- Set appropriate leverage limits based on risk tolerance
- Always use stop-loss orders to limit potential losses
- Monitor liquidation prices carefully
- Regularly check position risks and margin ratios
- Consider using reduce-only orders for risk management
- Be cautious with cross-margin due to shared risk
Rate Limits
- Respect Binance API rate limits
- Default rate limits:
- 1200 requests per minute for order operations
- 100 requests per second for market data
- Implement proper error handling for rate limit errors
Error Handling
Common Error Scenarios
- Invalid API credentials
- Insufficient balance or margin
- Invalid order parameters
- Rate limit exceeded
- Network connectivity issues
Futures-Specific Errors
- InsufficientMarginError: Not enough margin for operation
- InvalidPositionModeError: Wrong position mode setting
- OrderValidationError: Invalid futures order parameters
Example error handling:
Project Structure
Development
- Set up environment variables:
create .env
file in the root directory, and set your Binance API credentials:
- Install dependencies:
Build the server:
For development with auto-rebuild:
Installation
Installing via Smithery
To install Binance Trading Server for Claude Desktop automatically via Smithery:
Installing manually
- Clone the repository
- Install dependencies:
- Configure your Binance API credentials in
.env
- Build and start the server:
Debugging
Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:
The Inspector will provide a URL to access debugging tools in your browser.
mcp-server-bn
This server cannot be installed
This server provides a robust interface for Binance spot trading operations, including secure management of API credentials, execution and management of spot orders, and monitoring of account balances and open orders.