Binance's Model Context Protocol (MCP). Designed to support developers building crypto trading AI Agents.
Project description
Binance MCP Server ๐
A powerful Model Context Protocol (MCP) server that enables AI agents to interact seamlessly with the Binance cryptocurrency exchange. This server provides a comprehensive suite of trading tools, market data access, and account management capabilities through the standardized MCP interface.
๐ฏ Key Features
- Secure Authentication: API key-based authentication with Binance
- Real-time Market Data: Live price feeds, order book data, and market statistics
- Trading Operations: Place, modify, and cancel orders across spot and futures markets
- Portfolio Management: Account balance tracking, position monitoring, and P&L analysis
- Smart Notifications: Real-time alerts for price movements, order fills, and market events
- Risk Management: Built-in safeguards and validation for trading operations
๐ Quick Start
Prerequisites
- Python 3.10+ installed on your system
- Binance account with API access enabled
- API credentials (API Key & Secret) from your Binance account
1๏ธโฃ Installation
Install the official package from PyPI:
# Recommended: Install using pip
pip install binance-mcp-server
# Alternative: Using uv for faster package management
uv add binance-mcp-server
๐ก Why use the PyPI package?
- โ Always up-to-date with latest releases
- โ Automatic dependency management
- โ Simple installation and updates
- โ No need to clone repositories or manage source code
2๏ธโฃ Configuration
Set up your Binance API credentials as environment variables:
# Required: Your Binance API credentials
export BINANCE_API_KEY="your_api_key_here"
export BINANCE_API_SECRET="your_api_secret_here"
# Recommended: Use testnet for development and testing
export BINANCE_TESTNET="true"
3๏ธโฃ Launch Server
# Start the MCP server (after installing from PyPI)
binance-mcp-server --api-key $BINANCE_API_KEY --api-secret $BINANCE_API_SECRET --binance-testnet
4๏ธโฃ Connect Your AI Agent
Configure your AI agent (Claude, GPT-4, or custom bot) to connect to the MCP server:
{
"mcpServers": {
"binance": {
"command": "binance-mcp-server",
"args": [
"--api-key", "your_api_key",
"--api-secret", "your_secret",
"--binance-testnet"
]
}
}
}
๐ Available Tools
Our MCP server provides 15 comprehensive trading tools that enable AI agents to perform cryptocurrency trading operations. Each tool follows the Model Context Protocol standard for seamless integration.
๐ฆ Account & Portfolio Management
| Tool | Purpose |
|---|---|
get_balance |
Retrieve account balances for all assets |
get_account_snapshot |
Point-in-time account state snapshot |
get_fee_info |
Trading fee rates (maker/taker commissions) for symbols |
get_available_assets |
List all tradable cryptocurrencies and exchange info |
๐ Market Data & Analysis
| Tool | Purpose |
|---|---|
get_ticker_price |
Current price for a trading symbol |
get_ticker |
24-hour ticker price change statistics |
get_order_book |
Current order book (bids/asks) for a symbol |
๐ฑ Trading Operations
| Tool | Purpose |
|---|---|
create_order |
Create buy/sell orders (market, limit, etc.) |
get_orders |
List order history for a specific symbol |
๐ Performance & Analytics
| Tool | Purpose |
|---|---|
get_pnl |
Calculate profit and loss for futures trading |
get_position_info |
Open futures positions details |
๐ช Wallet & Transfers
| Tool | Purpose |
|---|---|
get_deposit_address |
Get deposit address for a specific coin |
get_deposit_history |
Deposit history for a specific coin |
get_withdraw_history |
Withdrawal history for a specific coin |
๐ก๏ธ Risk Management
| Tool | Purpose |
|---|---|
get_liquidation_history |
Past liquidation events for futures trading |
๐ง Configuration
Environment Variables
| Variable | Description | Required | Default |
|---|---|---|---|
BINANCE_API_KEY |
Your Binance API key | โ | - |
BINANCE_API_SECRET |
Your Binance API secret | โ | - |
BINANCE_TESTNET |
Use testnet environment | โ | false |
๐ ๏ธ Development
๐ Note: This section is for contributors and developers who want to modify the source code. Regular users should install from PyPI using the instructions above.
Development Environment Setup
# 1. Clone the repository
git clone https://github.com/AnalyticAce/binance-mcp-server.git
cd binance-mcp-server
# 2. Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 3. Install development dependencies (choose one)
# Option A: Using uv (if available)
uv install --dev
# Option B: Using pip
pip install -e .
pip install pytest # for testing
# 4. Set up pre-commit hooks (optional)
pip install pre-commit
pre-commit install --hook-type commit-msg
# 5. Run tests to verify setup
pytest
# 6. Start development server
python -m binance_mcp_server.cli
Testing Strategy
# Run all tests
pytest
# Run tests with coverage report
pytest --cov=binance_mcp_server --cov-report=html
# Run specific test category
pytest tests/test_tools/test_account.py -v
๐ค Contributing
We welcome contributions from the crypto and AI development community! Here's how you can help:
๐ฏ Current Priorities
Check our GitHub Issues for the latest development priorities:
- Enhanced Trading Tools - Order cancellation, modification, and advanced order types
- Portfolio Management - Advanced portfolio analytics and asset allocation tools
- Risk Management Extensions - Margin monitoring, leverage management, and liquidation alerts
- Market Data Enhancements - Historical data, technical indicators, and market analysis
- Alert System - Price notifications and position monitoring
- Documentation & Examples - Comprehensive guides and use case examples
๐ Contribution Guidelines
- Fork & Branch: Create a feature branch from
main - Code: Follow our coding standards
- Pre-commit Hooks: Install and configure pre-commit hooks for commit message validation
- Test: Add tests for new features (aim for >80% coverage)
- Document: Update documentation for user-facing changes
- Review: Submit a pull request for review
๐ง Development Setup for Contributors
๐ก For Regular Use: Most users should install via
pip install binance-mcp-serverinstead of cloning this repository.
# Clone your fork
git clone https://github.com/your-username/binance-mcp-server.git
cd binance-mcp-server
# Install dependencies and set up environment (choose one)
# Option A: Using uv (if available)
uv install --dev
# Option B: Using pip
pip install -e .
pip install pytest pre-commit
# Install pre-commit hooks (enforces commit message conventions)
pre-commit install --hook-type commit-msg
# Make your changes and commit using conventional format
git commit -m "feat(tools): add new market data tool"
๐ท๏ธ Issue Labels
good first issue- Perfect for newcomersenhancement- New features and improvementsbug- Something isn't working correctlydocumentation- Documentation updates neededhelp wanted- Community assistance requested
๐ Development Standards
- Pre-commit Hooks: Required for all contributors to ensure commit message consistency
- Type Hints: Full type annotations required
- Testing: pytest with >80% coverage target
- Commits: Conventional commit format (
feat:,fix:, etc.) enforced by pre-commit hooks - Documentation: Google-style docstrings
๐ Security & Best Practices
๐ก๏ธ API Security
- Credential Management: Never commit API keys to version control
- Testnet First: Always test with Binance testnet before live trading
- Rate Limiting: Built-in respect for Binance API rate limits
- Input Validation: Comprehensive validation of all trading parameters
- Audit Logging: Complete audit trail of all operations
๐ Environment Security
# Use environment variables for sensitive data
export BINANCE_API_KEY="your_key_here"
export BINANCE_API_SECRET="your_secret_here"
# Enable testnet for development
export BINANCE_TESTNET="true"
๐ก Usage Examples
๐ Market Data Queries
# Get real-time Bitcoin price
{
"name": "get_ticker_price",
"arguments": {
"symbol": "BTCUSDT"
}
}
# Get 24-hour ticker statistics for Ethereum
{
"name": "get_ticker",
"arguments": {
"symbol": "ETHUSDT"
}
}
# Check current order book for Ethereum
{
"name": "get_order_book",
"arguments": {
"symbol": "ETHUSDT",
"limit": 10
}
}
๐ฐ Account Management
# Check account balances
{
"name": "get_balance",
"arguments": {}
}
# Get account snapshot
{
"name": "get_account_snapshot",
"arguments": {
"account_type": "SPOT"
}
}
๐ Trading Operations
# Create a limit buy order for Ethereum
{
"name": "create_order",
"arguments": {
"symbol": "ETHUSDT",
"side": "BUY",
"order_type": "LIMIT",
"quantity": 0.1,
"price": 2000.00
}
}
# Get order history for a symbol
{
"name": "get_orders",
"arguments": {
"symbol": "ETHUSDT"
}
}
๐ Performance Analysis
# Calculate profit and loss
{
"name": "get_pnl",
"arguments": {}
}
# Get position information
{
"name": "get_position_info",
"arguments": {}
}
๐ฏ Roadmap
๐ Phase 1: Core Foundation โ
- MCP Server Framework - FastMCP integration and basic structure
- Documentation & Planning - Comprehensive tool specifications
- Authentication System - Secure Binance API integration
- Basic Tools Implementation - Essential trading and account tools (15 tools)
๐ Phase 2: Trading Operations ๐ง
- Order Management - Basic order creation and history
- Market Data Integration - Real-time price feeds and order books
- Portfolio Analytics - Basic P&L tracking and position info
- Advanced Order Types - Stop-loss, take-profit, OCO orders
- Order Cancellation - Cancel and modify existing orders
- Enhanced Risk Management - Advanced margin monitoring
๐ฅ Phase 3: Advanced Features ๐
- Advanced Analytics - Technical indicators and market insights
- Alert System - Price notifications and position monitoring
- Strategy Tools - DCA, grid trading, and automation helpers
- Multi-account Support - Cross-margin, isolated margin accounts
๐ Success Metrics
- Tool Coverage: 15/15 core tools implemented โ
- Test Coverage: >90% code coverage target (currently 22 tests passing)
- Performance: <100ms average API response time
- Community: Growing GitHub engagement and contributions
- Production Usage: Stable package releases on PyPI
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support & Community
๐ Documentation & Resources
- Complete Documentation - Comprehensive guides and tutorials
๐ฌ Get Help
- Report Issues - Bug reports and feature requests
- Discussions - Community Q&A and ideas
- Email Support - Technical questions and partnership inquiries
๐ท๏ธ Quick Help Tags
When creating issues, please use these labels to help us respond faster:
bug- Something isn't workingenhancement- Feature requestsquestion- General questionsdocumentation- Docs improvementsgood first issue- Perfect for newcomers
โ ๏ธ Legal Disclaimer
Important Notice: This software is provided for educational and development purposes only. Cryptocurrency trading involves substantial risk of financial loss.
๐ Risk Acknowledgment
- Testing Environment: Always use Binance testnet for development and testing
- Financial Risk: Only trade with funds you can afford to lose
- Due Diligence: Conduct thorough testing before deploying to live trading
- No Liability: Developers assume no responsibility for financial losses
๐ License & Attribution
This project is licensed under the MIT License - see the LICENSE file for details.
Built with โค๏ธ by the crypto development community
โก Powered by Model Context Protocol โก
โญ Star this project | ๐ด Fork & Contribute | ๐ Read the Docs
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file binance_mcp_server-1.2.5.tar.gz.
File metadata
- Download URL: binance_mcp_server-1.2.5.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97f746925180de9db71f6b5ec423ffc05e1db71df613956d4cdbb3498dfb7b0b
|
|
| MD5 |
57406f0d84c6d871e7a05becf2437b5f
|
|
| BLAKE2b-256 |
7bdb068ff636d9cb4284ef77569252e6e542549ede4b9159cb041d9f5fd86950
|
File details
Details for the file binance_mcp_server-1.2.5-py3-none-any.whl.
File metadata
- Download URL: binance_mcp_server-1.2.5-py3-none-any.whl
- Upload date:
- Size: 33.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af4959096f32d66bb0abb9e81d322abfccdf9e739df448ef4ef6b5f00adfe11e
|
|
| MD5 |
6380047a69ba1125d9b4f2784dd15f3d
|
|
| BLAKE2b-256 |
2c92e207eb1dd677cd1ce7b14e00f935fbb0a0bdef0d3c203cc7804460eff111
|