Binance MCP Server
A Model Context Protocol server that provides Claude Code with seamless access to Binance exchange API functionality for market data retrieval, account management, and trading operations.
README
Binance MCP Server
多语言文档 / Multi-language Documentation
A comprehensive Model Context Protocol (MCP) server that provides Claude Code with seamless access to Binance exchange API functionality.
Features
- Market Data Tools: Get real-time prices, order book depth, K-line data, and 24-hour statistics
- Account Management: View account information, balances, open orders, and order history
- Trading Operations: Place orders, cancel orders (testnet only)
- Full TypeScript Support: Complete type definitions and validation
- Security First: Environment-based configuration with input validation
- Error Handling: Comprehensive error handling with sanitized logging
Quick Start
Installation
npm install
Configuration
- Copy the environment template:
cp .env.example .env
- Configure your Binance API credentials in
.env:
BINANCE_API_KEY=your_api_key_here
BINANCE_API_SECRET=your_api_secret_here
BINANCE_TESTNET=true
MCP_SERVER_NAME=binance-mcp-server
MCP_SERVER_VERSION=1.0.0
LOG_LEVEL=info
Running the Server
Development mode:
npm run dev
Production build:
npm run build
npm start
Available Tools
Market Data Tools
get_price
Get current price for a trading pair.
{
"symbol": "BTCUSDT"
}
get_orderbook
Get order book depth data.
{
"symbol": "BTCUSDT",
"limit": 100
}
get_klines
Get K-line/candlestick data.
{
"symbol": "BTCUSDT",
"interval": "1h",
"limit": 500
}
get_24hr_ticker
Get 24-hour price change statistics.
{
"symbol": "BTCUSDT"
}
Account Tools
get_account_info
Get account information and balances.
{}
get_open_orders
Get current open orders.
{
"symbol": "BTCUSDT"
}
get_order_history
Get historical orders.
{
"symbol": "BTCUSDT",
"limit": 500
}
Trading Tools (Testnet Only)
place_order
Place a new order.
{
"symbol": "BTCUSDT",
"side": "BUY",
"type": "LIMIT",
"quantity": "0.001",
"price": "50000"
}
cancel_order
Cancel a specific order.
{
"symbol": "BTCUSDT",
"orderId": 12345
}
cancel_all_orders
Cancel all open orders for a symbol.
{
"symbol": "BTCUSDT"
}
Claude Code Integration
Configuration
Add the following to your Claude Code MCP configuration:
{
"mcpServers": {
"binance": {
"command": "binance-mcp-server",
"env": {
"BINANCE_API_KEY": "your_api_key",
"BINANCE_API_SECRET": "your_api_secret",
"BINANCE_TESTNET": "true"
}
}
}
}
Usage Examples
Ask Claude to:
- "Get the current price of Bitcoin"
- "Show me the order book for ETHUSDT"
- "Get 1-hour candlestick data for BTCUSDT"
- "Check my account balance"
- "Place a limit buy order for 0.001 BTC at $50,000"
Security
Important Security Notes
- API Keys: Never commit API keys to version control
- Testnet Only: Trading functions only work with
BINANCE_TESTNET=true - Input Validation: All inputs are validated using Zod schemas
- Error Sanitization: Sensitive information is removed from error logs
Environment Variables
| Variable | Required | Description |
|---|---|---|
BINANCE_API_KEY |
Yes | Your Binance API key |
BINANCE_API_SECRET |
Yes | Your Binance API secret |
BINANCE_TESTNET |
No | Enable testnet mode (default: false) |
MCP_SERVER_NAME |
No | Server name (default: binance-mcp-server) |
MCP_SERVER_VERSION |
No | Server version (default: 1.0.0) |
LOG_LEVEL |
No | Logging level (default: info) |
Development
Project Structure
binance-mcp-server/
├── src/
│ ├── index.ts # Server entry point
│ ├── server.ts # MCP server core
│ ├── tools/ # Tool modules
│ │ ├── market-data.ts # Market data tools
│ │ ├── account.ts # Account info tools
│ │ ├── trading.ts # Trading tools
│ │ └── index.ts # Tool exports
│ ├── types/ # TypeScript definitions
│ │ ├── binance.ts # Binance API types
│ │ └── mcp.ts # MCP input schemas
│ ├── config/
│ │ └── binance.ts # Configuration management
│ └── utils/
│ ├── validation.ts # Input validation
│ └── error-handling.ts # Error handling
├── dist/ # Compiled JavaScript
├── .env.example # Environment template
├── package.json
├── tsconfig.json
└── README.md
Scripts
npm run build- Compile TypeScript to JavaScriptnpm run dev- Run in development mode with hot reloadnpm run start- Run the compiled servernpm run lint- Run ESLintnpm run typecheck- Run TypeScript type checking
Adding New Tools
- Define input schema in
src/types/mcp.ts - Create tool implementation in appropriate file under
src/tools/ - Export from
src/tools/index.ts - Update documentation
Troubleshooting
Common Issues
-
API Connection Failed
- Verify API credentials are correct
- Check network connectivity
- Ensure testnet flag matches your API key type
-
Permission Denied
- Verify API key has required permissions
- Check if IP is whitelisted on Binance
-
Invalid Symbol
- Use correct symbol format (e.g., BTCUSDT, not BTC/USDT)
- Verify symbol exists on Binance
-
Trading Disabled
- Set
BINANCE_TESTNET=truefor trading functions - Verify testnet API credentials
- Set
Debug Mode
Set LOG_LEVEL=debug for detailed logging:
LOG_LEVEL=debug npm run dev
API Rate Limits
The server respects Binance API rate limits:
- Market data: 1200 requests per minute
- Account data: 180 requests per minute
- Orders: 10 orders per second, 100,000 orders per 24 hours
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Update documentation
- Submit a pull request
License
MIT License - see LICENSE file for details
Support
For issues and questions:
- Check the troubleshooting section
- Review Binance API documentation
- Open an issue on GitHub
Disclaimer
This software is for educational and development purposes. Use at your own risk. Always test with testnet before using real funds.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。