Setup Guide¶
Installation¶
Prerequisites¶
- Python 3.10+ - Required for modern typing and async support
- Binance Account - With API access enabled
- API Credentials - API Key and Secret from Binance
Step 1: Install the Package¶
The easiest way to get started is by installing the official package from PyPI:
💡 Benefits of PyPI Installation: - ✅ Always the latest stable version - ✅ Automatic dependency management
- ✅ Easy updates withpip install --upgrade binance-mcp-server
- ✅ No need to manage source code
Configuration¶
Step 2: Binance API Setup¶
-
Login to Binance: Go to binance.com or binance.us
-
Create API Key:
- Navigate to Account → API Management
- Click "Create API"
-
Choose "System generated" API key
-
Configure Permissions:
-
IP Restrictions (Recommended):
- Add your server's IP address
- Use "Restrict access to trusted IPs only"
Step 3: Environment Variables¶
Set up your API credentials as environment variables:
Configuration Options¶
Variable | Required | Default | Description |
---|---|---|---|
BINANCE_API_KEY |
✅ Yes | None | Your Binance API key |
BINANCE_API_SECRET |
✅ Yes | None | Your Binance API secret |
BINANCE_TESTNET |
❌ No | false |
Use testnet environment |
Running the Server¶
Step 4: Start the Server¶
Command Line Options¶
binance-mcp-server [OPTIONS]
Options:
--api-key, -k TEXT Binance API key (or set BINANCE_API_KEY env var)
--api-secret, -s TEXT Binance API secret (or set BINANCE_API_SECRET env var)
--binance-testnet, -t Use testnet environment (recommended for testing)
--transport [stdio|streamable-http|sse] Transport method (default: stdio)
--port INTEGER Port for HTTP transport (default: 8000)
--host TEXT Host for HTTP transport (default: localhost)
--log-level [DEBUG|INFO|WARNING|ERROR] Set logging level (default: INFO)
--help Show help message
MCP Client Configuration¶
Claude Desktop Configuration¶
Add to your Claude Desktop configuration file:
Other MCP Clients¶
For other MCP clients, use the STDIO transport:
The server will communicate via stdin/stdout for MCP protocol messages.
Verification¶
Step 5: Test Your Setup¶
Test the server connection:
import os
from binance_mcp_server.tools.get_ticker_price import get_ticker_price
# Set environment variables
os.environ["BINANCE_API_KEY"] = "your_key"
os.environ["BINANCE_API_SECRET"] = "your_secret"
os.environ["BINANCE_TESTNET"] = "true"
# Test a simple API call
result = get_ticker_price("BTCUSDT")
print(f"BTC Price: ${result['data']['price']}")
Troubleshooting¶
Common Issues¶
❌ Configuration Errors¶
Solution: Ensure environment variables are set correctly❌ API Authentication Errors¶
Solutions: - Verify API key and secret are correct - Check API key permissions in Binance account - Ensure IP restrictions allow your server IP❌ Rate Limit Errors¶
Solutions: - Wait a few minutes before retrying - Reduce request frequency - Contact Binance support for higher limits❌ Network Errors¶
Solutions: - Check internet connectivity - Verify firewall settings - Try using testnet firstTestnet vs Production¶
Environment | API Base URL | Purpose |
---|---|---|
Testnet | https://testnet.binance.vision |
Development & Testing |
Production | https://api.binance.com |
Live Trading |
Important
Always start with testnet (BINANCE_TESTNET=true
) for development and testing. Testnet uses fake money and allows safe experimentation.
Logging¶
Enable debug logging for troubleshooting:
Log output includes: - API requests and responses - Rate limiting status - Error details and stack traces - Configuration validation results
Next Steps¶
- 📖 API Reference - Learn about all available tools
- 💡 Examples - See practical usage examples
- 🏗️ Architecture - Understand the system design
- 🤝 Contributing - Help improve the server