Binance Trading
STDIOBinance spot and futures trading integration for market and limit orders
Binance spot and futures trading integration for market and limit orders
This MCP Server provides comprehensive integration with Binance's spot and futures trading operations.
configure_api_keysSecurely store your Binance API credentials:
await configureBinanceApiKeys({ apiKey: 'your-api-key', apiSecret: 'your-api-secret' });
create_spot_orderCreate LIMIT or MARKET orders:
// LIMIT order await createSpotOrder({ symbol: 'BTCUSDT', side: 'BUY', type: 'LIMIT', quantity: '0.001', price: '40000' }); // MARKET order await createSpotOrder({ symbol: 'BTCUSDT', side: 'BUY', type: 'MARKET', quantity: '0.001' });
cancel_orderCancel an existing order:
await cancelOrder({ symbol: 'BTCUSDT', orderId: '12345678' });
get_balancesCheck your account balances:
const balances = await getBalances(); // Returns: { BTC: '0.1', USDT: '1000', ... }
get_open_ordersList all open orders:
const orders = await getOpenOrders({ symbol: 'BTCUSDT' // Optional: specify symbol });
create_futures_orderCreate various types of futures orders:
// LIMIT order await createFuturesOrder({ symbol: 'BTCUSDT', side: 'BUY', type: 'LIMIT', quantity: '0.001', price: '40000', timeInForce: 'GTC' }); // STOP MARKET order await createFuturesOrder({ symbol: 'BTCUSDT', side: 'SELL', type: 'STOP_MARKET', quantity: '0.001', stopPrice: '38000' }); // TRAILING STOP order await createFuturesOrder({ symbol: 'BTCUSDT', side: 'SELL', type: 'TRAILING_STOP_MARKET', quantity: '0.001', callbackRate: '1.0' // 1% callback rate });
set_futures_leverageAdjust leverage for a trading pair:
await setFuturesLeverage({ symbol: 'BTCUSDT', leverage: 10 // 1-125x });
get_futures_positionsGet all open futures positions:
const positions = await getFuturesPositions();
get_futures_accountGet detailed futures account information:
const account = await getFuturesAccount();
get_funding_rateGet funding rate for a futures symbol:
const fundingRate = await getFundingRate({ symbol: 'BTCUSDT' });
cancel_futures_orderCancel an existing futures order:
await cancelFuturesOrder({ symbol: 'BTCUSDT', orderId: '12345678' });
Perpetual futures contracts use funding rates to keep futures prices aligned with spot prices:
Example error handling:
try { await createFuturesOrder({ symbol: 'BTCUSDT', side: 'BUY', type: 'LIMIT', quantity: '0.001', price: '40000', timeInForce: 'GTC' }); } catch (error) { if (error instanceof InsufficientMarginError) { console.error('Insufficient margin available'); } else if (error instanceof InvalidPositionModeError) { console.error('Invalid position mode'); } else if (error instanceof OrderValidationError) { console.error('Invalid order parameters'); } }
.
├── src/
│   ├── index.ts                 # Server entry point
│   ├── services/
│   │   ├── binance.ts          # Binance API integration
│   │   ├── keystore.ts         # API key management
│   │   └── tools.ts            # Trading tools implementation
│   └── types/
│       ├── binance.ts          # Binance types
│       └── binance-connector.d.ts  # API client types
├── README.md
├── README_CN.md
├── package.json
├── pnpm-lock.yaml
└── tsconfig.json
create .env file in the root directory, and set your Binance API credentials:
BINANCE_API_KEY=your_api_key_here BINANCE_API_SECRET=your_secret_key_here
pnpm install
Build the server:
pnpm build
For development with auto-rebuild:
pnpm watch
To install Binance Trading Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install mcp-server-cex-bn --client claude
pnpm install
.envpnpm build pnpm start
Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:
pnpm inspector
The Inspector will provide a URL to access debugging tools in your browser.