binance-futures-mcp 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- binance_futures_mcp-1.0.0/LICENSE +21 -0
- binance_futures_mcp-1.0.0/PKG-INFO +437 -0
- binance_futures_mcp-1.0.0/README.md +403 -0
- binance_futures_mcp-1.0.0/pyproject.toml +67 -0
- binance_futures_mcp-1.0.0/setup.cfg +4 -0
- binance_futures_mcp-1.0.0/src/binance_futures_mcp.egg-info/PKG-INFO +437 -0
- binance_futures_mcp-1.0.0/src/binance_futures_mcp.egg-info/SOURCES.txt +12 -0
- binance_futures_mcp-1.0.0/src/binance_futures_mcp.egg-info/dependency_links.txt +1 -0
- binance_futures_mcp-1.0.0/src/binance_futures_mcp.egg-info/entry_points.txt +2 -0
- binance_futures_mcp-1.0.0/src/binance_futures_mcp.egg-info/requires.txt +10 -0
- binance_futures_mcp-1.0.0/src/binance_futures_mcp.egg-info/top_level.txt +1 -0
- binance_futures_mcp-1.0.0/src/binance_mcp/__init__.py +3 -0
- binance_futures_mcp-1.0.0/src/binance_mcp/__main__.py +7 -0
- binance_futures_mcp-1.0.0/src/binance_mcp/server.py +760 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Binance MCP Server
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,437 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: binance-futures-mcp
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: A Model Context Protocol server for Binance Futures API
|
5
|
+
Author: Binance MCP Server
|
6
|
+
License: MIT
|
7
|
+
Project-URL: Homepage, https://github.com/bin-mcp/binance-mcp-server
|
8
|
+
Project-URL: Repository, https://github.com/bin-mcp/binance-mcp-server.git
|
9
|
+
Project-URL: Issues, https://github.com/bin-mcp/binance-mcp-server/issues
|
10
|
+
Keywords: mcp,binance,trading,futures,api,model-context-protocol
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
12
|
+
Classifier: Intended Audience :: Developers
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
20
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
21
|
+
Requires-Python: >=3.8
|
22
|
+
Description-Content-Type: text/markdown
|
23
|
+
License-File: LICENSE
|
24
|
+
Requires-Dist: mcp>=1.0.0
|
25
|
+
Requires-Dist: aiohttp>=3.8.0
|
26
|
+
Requires-Dist: pydantic>=2.0.0
|
27
|
+
Provides-Extra: dev
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
29
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
30
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
31
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
32
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
33
|
+
Dynamic: license-file
|
34
|
+
|
35
|
+
# Binance MCP Server
|
36
|
+
|
37
|
+
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.
|
38
|
+
|
39
|
+
## Features
|
40
|
+
|
41
|
+
### Account Information Tools
|
42
|
+
- Get account info, balance, and position information
|
43
|
+
- Query position mode and commission rates
|
44
|
+
- Access risk management data (ADL quantile, leverage brackets, force orders)
|
45
|
+
|
46
|
+
### Order Management Tools
|
47
|
+
- Place orders (MARKET, LIMIT, STOP, STOP_MARKET, TRAILING_STOP_MARKET)
|
48
|
+
- Place multiple orders in batch
|
49
|
+
- Cancel orders (single, multiple, or all)
|
50
|
+
- Query order status and history
|
51
|
+
- Auto-cancel functionality
|
52
|
+
|
53
|
+
### Trading Configuration Tools
|
54
|
+
- Change leverage and margin type
|
55
|
+
- Switch between hedge and one-way position modes
|
56
|
+
- Modify position margins
|
57
|
+
|
58
|
+
### Market Data Tools
|
59
|
+
- Get exchange information and trading rules
|
60
|
+
- Access real-time price data and order books
|
61
|
+
- Retrieve candlestick/kline data
|
62
|
+
- Get mark prices and funding rates
|
63
|
+
- Access aggregate trade data
|
64
|
+
|
65
|
+
### Trading History Tools
|
66
|
+
- Get account trade history
|
67
|
+
- Access income history (funding fees, PnL, etc.)
|
68
|
+
- Retrieve funding rate history
|
69
|
+
|
70
|
+
## Installation
|
71
|
+
|
72
|
+
### Prerequisites
|
73
|
+
- Python 3.8 or higher
|
74
|
+
- Binance Futures API credentials
|
75
|
+
|
76
|
+
### Method 1: Install via uvx (Recommended)
|
77
|
+
|
78
|
+
```bash
|
79
|
+
uvx --from git+https://github.com/alexcandrabersiva/bin-mcp binance-mcp-server
|
80
|
+
```
|
81
|
+
|
82
|
+
### Method 2: Local Installation
|
83
|
+
|
84
|
+
```bash
|
85
|
+
cd binance-mcp-server
|
86
|
+
pip install -e .
|
87
|
+
```
|
88
|
+
|
89
|
+
Or install development dependencies:
|
90
|
+
|
91
|
+
```bash
|
92
|
+
pip install -e ".[dev]"
|
93
|
+
```
|
94
|
+
|
95
|
+
## MCP Client Configuration
|
96
|
+
|
97
|
+
This server can be integrated with various MCP clients. Here are configuration examples for popular clients:
|
98
|
+
|
99
|
+
### VS Code
|
100
|
+
|
101
|
+
Add to your VS Code `settings.json`:
|
102
|
+
|
103
|
+
```json
|
104
|
+
{
|
105
|
+
"mcp.servers": {
|
106
|
+
"binance": {
|
107
|
+
"command": "uvx",
|
108
|
+
"args": ["binance-mcp-server"],
|
109
|
+
"env": {
|
110
|
+
"BINANCE_API_KEY": "your_api_key_here",
|
111
|
+
"BINANCE_SECRET_KEY": "your_secret_key_here"
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
```
|
117
|
+
|
118
|
+
### Cursor
|
119
|
+
|
120
|
+
Add to your Cursor configuration file (`.cursor/mcp.json`):
|
121
|
+
|
122
|
+
```json
|
123
|
+
{
|
124
|
+
"servers": {
|
125
|
+
"binance": {
|
126
|
+
"command": "uvx",
|
127
|
+
"args": ["binance-mcp-server"],
|
128
|
+
"env": {
|
129
|
+
"BINANCE_API_KEY": "your_api_key_here",
|
130
|
+
"BINANCE_SECRET_KEY": "your_secret_key_here"
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
```
|
136
|
+
|
137
|
+
### Windsurf
|
138
|
+
|
139
|
+
Add to your Windsurf configuration (`.windsurf/mcp.json`):
|
140
|
+
|
141
|
+
```json
|
142
|
+
{
|
143
|
+
"mcpServers": {
|
144
|
+
"binance": {
|
145
|
+
"command": "uvx",
|
146
|
+
"args": ["binance-mcp-server"],
|
147
|
+
"env": {
|
148
|
+
"BINANCE_API_KEY": "your_api_key_here",
|
149
|
+
"BINANCE_SECRET_KEY": "your_secret_key_here"
|
150
|
+
}
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
```
|
155
|
+
|
156
|
+
### Claude Desktop
|
157
|
+
|
158
|
+
Add to your Claude Desktop configuration file:
|
159
|
+
|
160
|
+
**On macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
161
|
+
**On Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
|
162
|
+
|
163
|
+
```json
|
164
|
+
{
|
165
|
+
"mcpServers": {
|
166
|
+
"binance": {
|
167
|
+
"command": "uvx",
|
168
|
+
"args": ["binance-mcp-server"],
|
169
|
+
"env": {
|
170
|
+
"BINANCE_API_KEY": "your_api_key_here",
|
171
|
+
"BINANCE_SECRET_KEY": "your_secret_key_here"
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
```
|
177
|
+
|
178
|
+
### Configuration Notes
|
179
|
+
|
180
|
+
1. **No path needed**: With PyPI installation, you don't need to specify paths or working directories.
|
181
|
+
|
182
|
+
2. **Set API credentials**: Replace `your_api_key_here` and `your_secret_key_here` with your actual Binance API credentials.
|
183
|
+
|
184
|
+
3. **Alternative commands**: You can also use:
|
185
|
+
- `pip install binance-mcp-server && python -m binance_mcp`
|
186
|
+
- `binance-mcp-server` (if installed globally)
|
187
|
+
|
188
|
+
4. **Python environment**: Using `uvx` automatically handles the Python environment.
|
189
|
+
|
190
|
+
5. **Security**: For production use, consider storing credentials in your system's environment variables instead of directly in configuration files.
|
191
|
+
|
192
|
+
## Installation
|
193
|
+
|
194
|
+
### Prerequisites
|
195
|
+
- Python 3.8 or higher
|
196
|
+
- Binance Futures API credentials
|
197
|
+
|
198
|
+
### Method 1: Install via uvx (Recommended)
|
199
|
+
|
200
|
+
```bash
|
201
|
+
uvx --from git+https://github.com/alexcandrabersiva/bin-mcp binance-mcp-server
|
202
|
+
```
|
203
|
+
|
204
|
+
### Method 2: Local Installation
|
205
|
+
|
206
|
+
```bash
|
207
|
+
cd binance-mcp-server
|
208
|
+
pip install -e .
|
209
|
+
```
|
210
|
+
|
211
|
+
Or install development dependencies:
|
212
|
+
|
213
|
+
```bash
|
214
|
+
pip install -e ".[dev]"
|
215
|
+
```
|
216
|
+
|
217
|
+
## Configuration
|
218
|
+
|
219
|
+
### Environment Variables
|
220
|
+
|
221
|
+
Set your Binance API credentials as environment variables:
|
222
|
+
|
223
|
+
```bash
|
224
|
+
export BINANCE_API_KEY="your_api_key_here"
|
225
|
+
export BINANCE_SECRET_KEY="your_secret_key_here"
|
226
|
+
```
|
227
|
+
|
228
|
+
### API Permissions
|
229
|
+
|
230
|
+
Your Binance API key needs the following permissions:
|
231
|
+
- **Futures Trading**: For order placement and management
|
232
|
+
- **Futures Reading**: For account and market data access
|
233
|
+
|
234
|
+
**Note**: Market data endpoints (exchange info, prices, order books, etc.) work without authentication.
|
235
|
+
|
236
|
+
## Usage
|
237
|
+
|
238
|
+
### Running the Server
|
239
|
+
|
240
|
+
```bash
|
241
|
+
# Run directly
|
242
|
+
python -m binance_mcp
|
243
|
+
|
244
|
+
# Or using the installed script
|
245
|
+
binance-mcp-server
|
246
|
+
```
|
247
|
+
|
248
|
+
### Available Tools
|
249
|
+
|
250
|
+
The server provides 32 tools organized into categories:
|
251
|
+
|
252
|
+
#### Account Information (5 tools)
|
253
|
+
- `get_account_info` - Get futures account information
|
254
|
+
- `get_balance` - Get account balance for all assets
|
255
|
+
- `get_position_info` - Get current position information
|
256
|
+
- `get_position_mode` - Get position mode (Hedge/One-way)
|
257
|
+
- `get_commission_rate` - Get commission rate for a symbol
|
258
|
+
|
259
|
+
#### Risk Management (4 tools)
|
260
|
+
- `get_adl_quantile` - Get ADL quantile estimation
|
261
|
+
- `get_leverage_brackets` - Get leverage brackets
|
262
|
+
- `get_force_orders` - Get liquidation orders
|
263
|
+
- `get_position_margin_history` - Get margin change history
|
264
|
+
|
265
|
+
#### Order Management (10 tools)
|
266
|
+
- `place_order` - Place a futures order
|
267
|
+
- `place_multiple_orders` - Place multiple orders in batch
|
268
|
+
- `cancel_order` - Cancel an active order
|
269
|
+
- `cancel_multiple_orders` - Cancel multiple orders
|
270
|
+
- `cancel_all_orders` - Cancel all open orders for a symbol
|
271
|
+
- `auto_cancel_all_orders` - Set up auto-cancellation
|
272
|
+
- `get_open_order` - Query specific open order
|
273
|
+
- `get_open_orders` - Get all open orders
|
274
|
+
- `get_all_orders` - Get all orders (filled, canceled, rejected)
|
275
|
+
- `query_order` - Query order status
|
276
|
+
|
277
|
+
#### Trading Configuration (4 tools)
|
278
|
+
- `change_leverage` - Change initial leverage
|
279
|
+
- `change_margin_type` - Change margin type (ISOLATED/CROSSED)
|
280
|
+
- `change_position_mode` - Change position mode
|
281
|
+
- `modify_position_margin` - Modify position margin
|
282
|
+
|
283
|
+
#### Market Data (6 tools)
|
284
|
+
- `get_exchange_info` - Get trading rules and symbol info
|
285
|
+
- `get_book_ticker` - Get best bid/ask prices
|
286
|
+
- `get_price_ticker` - Get latest prices
|
287
|
+
- `get_order_book` - Get order book depth
|
288
|
+
- `get_klines` - Get candlestick data
|
289
|
+
- `get_mark_price` - Get mark price and funding rate
|
290
|
+
- `get_aggregate_trades` - Get aggregate trade data
|
291
|
+
|
292
|
+
#### Trading History (3 tools)
|
293
|
+
- `get_account_trades` - Get account trade history
|
294
|
+
- `get_income_history` - Get income history
|
295
|
+
- `get_funding_rate_history` - Get funding rate history
|
296
|
+
|
297
|
+
## Example Usage
|
298
|
+
|
299
|
+
### Place a Market Order
|
300
|
+
|
301
|
+
```json
|
302
|
+
{
|
303
|
+
"tool": "place_order",
|
304
|
+
"arguments": {
|
305
|
+
"symbol": "BTCUSDT",
|
306
|
+
"side": "BUY",
|
307
|
+
"order_type": "MARKET",
|
308
|
+
"quantity": 0.001
|
309
|
+
}
|
310
|
+
}
|
311
|
+
```
|
312
|
+
|
313
|
+
### Place a Limit Order
|
314
|
+
|
315
|
+
```json
|
316
|
+
{
|
317
|
+
"tool": "place_order",
|
318
|
+
"arguments": {
|
319
|
+
"symbol": "BTCUSDT",
|
320
|
+
"side": "BUY",
|
321
|
+
"order_type": "LIMIT",
|
322
|
+
"quantity": 0.001,
|
323
|
+
"price": 50000.0,
|
324
|
+
"time_in_force": "GTC"
|
325
|
+
}
|
326
|
+
}
|
327
|
+
```
|
328
|
+
|
329
|
+
### Get Account Information
|
330
|
+
|
331
|
+
```json
|
332
|
+
{
|
333
|
+
"tool": "get_account_info",
|
334
|
+
"arguments": {}
|
335
|
+
}
|
336
|
+
```
|
337
|
+
|
338
|
+
### Get Market Data
|
339
|
+
|
340
|
+
```json
|
341
|
+
{
|
342
|
+
"tool": "get_klines",
|
343
|
+
"arguments": {
|
344
|
+
"symbol": "BTCUSDT",
|
345
|
+
"interval": "1h",
|
346
|
+
"limit": 100
|
347
|
+
}
|
348
|
+
}
|
349
|
+
```
|
350
|
+
|
351
|
+
## Security
|
352
|
+
|
353
|
+
### API Key Security
|
354
|
+
- Store API credentials securely using environment variables
|
355
|
+
- Never commit credentials to version control
|
356
|
+
- Use API keys with minimal required permissions
|
357
|
+
- Consider using testnet for development
|
358
|
+
|
359
|
+
### Rate Limiting
|
360
|
+
The server respects Binance's rate limits:
|
361
|
+
- Weight-based limits for different endpoints
|
362
|
+
- Order placement rate limits
|
363
|
+
- Automatic signature generation for authenticated requests
|
364
|
+
|
365
|
+
### Error Handling
|
366
|
+
- Comprehensive error handling for API failures
|
367
|
+
- Clear error messages for common issues
|
368
|
+
- Validation of required parameters
|
369
|
+
|
370
|
+
## API Reference
|
371
|
+
|
372
|
+
This server implements all endpoints documented in the Binance Futures API:
|
373
|
+
|
374
|
+
- **Base URL**: `https://fapi.binance.com`
|
375
|
+
- **API Type**: Binance USD-S Margined Futures
|
376
|
+
- **Authentication**: API Key + HMAC SHA256 Signature
|
377
|
+
|
378
|
+
For detailed parameter specifications, see the [Binance Futures API Documentation](https://binance-docs.github.io/apidocs/futures/en/).
|
379
|
+
|
380
|
+
## Development
|
381
|
+
|
382
|
+
### Project Structure
|
383
|
+
|
384
|
+
```
|
385
|
+
binance-mcp-server/
|
386
|
+
├── src/
|
387
|
+
│ └── binance_mcp/
|
388
|
+
│ ├── __init__.py
|
389
|
+
│ ├── __main__.py
|
390
|
+
│ └── server.py
|
391
|
+
├── pyproject.toml
|
392
|
+
└── README.md
|
393
|
+
```
|
394
|
+
|
395
|
+
### Running Tests
|
396
|
+
|
397
|
+
```bash
|
398
|
+
pytest
|
399
|
+
```
|
400
|
+
|
401
|
+
### Code Formatting
|
402
|
+
|
403
|
+
```bash
|
404
|
+
black src/
|
405
|
+
ruff check src/
|
406
|
+
```
|
407
|
+
|
408
|
+
## Error Codes
|
409
|
+
|
410
|
+
Common Binance API error codes:
|
411
|
+
- `-1121`: Invalid symbol
|
412
|
+
- `-2019`: Margin is insufficient
|
413
|
+
- `-1116`: Invalid orderType
|
414
|
+
- `-1013`: Filter failure (PRICE_FILTER, LOT_SIZE, etc.)
|
415
|
+
|
416
|
+
## Contributing
|
417
|
+
|
418
|
+
1. Fork the repository
|
419
|
+
2. Create a feature branch
|
420
|
+
3. Make your changes
|
421
|
+
4. Add tests if applicable
|
422
|
+
5. Submit a pull request
|
423
|
+
|
424
|
+
## License
|
425
|
+
|
426
|
+
MIT License - see LICENSE file for details.
|
427
|
+
|
428
|
+
## Disclaimer
|
429
|
+
|
430
|
+
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.
|
431
|
+
|
432
|
+
## Support
|
433
|
+
|
434
|
+
For issues and questions:
|
435
|
+
- Check the [Binance API Documentation](https://binance-docs.github.io/apidocs/futures/en/)
|
436
|
+
- Review the error codes in the API documentation
|
437
|
+
- Ensure your API credentials have the correct permissions
|