MCP Server for Binance Spot Trading

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Provides comprehensive integration with Binance's spot and futures trading operations, including executing trades, monitoring account balances, managing orders, setting leverage, tracking funding rates, and supporting various position modes.

mcp-server-cex-bn

この MCP サーバーは、Binance のスポットおよび先物取引業務との包括的な統合を提供します。

中国語の説明

特徴

スポット取引業務

  • スポット取引操作(指値/成行注文)を実行する
  • 口座残高を監視する
  • オープン注文の追跡と管理
  • 既存の注文をキャンセルする

先物取引業務

  • さまざまなタイプの先物注文(LIMIT、MARKET、STOP、TAKE_PROFIT など)を作成します
  • レバレッジ設定を管理する(1~125倍)
  • 先物ポジションと口座情報を監視する
  • 資金調達率を追跡する
  • 一方向とヘッジモードの両方のポジションをサポート
  • トレーリングストップやリデュースオンリー注文などの高度な注文タイプ

ツール

API構成

configure_api_keys

Binance API の認証情報を安全に保存します。

await configureBinanceApiKeys({ apiKey: 'your-api-key', apiSecret: 'your-api-secret' });

スポット取引ツール

create_spot_order

LIMIT 注文または MARKET 注文を作成します。

// 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_order

既存の注文をキャンセルする:

await cancelOrder({ symbol: 'BTCUSDT', orderId: '12345678' });
get_balances

アカウント残高を確認してください:

const balances = await getBalances(); // Returns: { BTC: '0.1', USDT: '1000', ... }
get_open_orders

すべてのオープン注文を一覧表示します:

const orders = await getOpenOrders({ symbol: 'BTCUSDT' // Optional: specify symbol });

先物取引ツール

create_futures_order

さまざまな種類の先物注文を作成します。

// 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_leverage

取引ペアのレバレッジを調整します。

await setFuturesLeverage({ symbol: 'BTCUSDT', leverage: 10 // 1-125x });
get_futures_positions

すべてのオープン先物ポジションを取得します。

const positions = await getFuturesPositions();
get_futures_account

詳細な先物口座情報を取得します。

const account = await getFuturesAccount();
get_funding_rate

先物シンボルの資金調達率を取得します。

const fundingRate = await getFundingRate({ symbol: 'BTCUSDT' });
cancel_futures_order

既存の先物注文をキャンセルする:

await cancelFuturesOrder({ symbol: 'BTCUSDT', orderId: '12345678' });

先物取引の詳細

位置モード

  • 一方向モード: シンボルごとに単一の位置
    • デフォルトモード、よりシンプルなポジション管理
    • 総ポジションサイズはすべての注文の合計です
  • ヘッジモード: ロングポジションとショートポジションを分離
    • ロングポジションとショートポジションを同時に保持できる
    • 各ポジションには独立した証拠金要件がある

マージンの種類

  • 分離マージン: ポジションごとに固定マージン
    • リスクは割り当てられたマージンに限定されます
    • 各ポジションには独自のレバレッジ設定があります
  • クロスマージン: ポジション間で共有されるマージン
    • 資本効率の向上
    • すべてのポジションでリスクを共有

資金調達率

永久先物契約では、資金調達率を使用して先物価格をスポット価格と一致させます。

  • プラス金利:ロングがショートを支払う
  • マイナス金利:ショートがロングに有利
  • 支払いは8時間ごとに行われます

セキュリティに関する考慮事項

スポット取引のセキュリティ

  • APIキーをバージョン管理にコミットしない
  • 環境変数または安全なキーストレージを使用する
  • APIキーの権限を必要な操作のみに制限する
  • APIキーを定期的にローテーションする

先物取引セキュリティ

  • リスク許容度に基づいて適切なレバレッジ制限を設定する
  • 潜在的な損失を制限するために、常にストップロス注文を使用してください。
  • 清算価格を注意深く監視する
  • ポジションリスクと証拠金比率を定期的にチェックする
  • リスク管理のために減額注文の使用を検討する
  • リスク共有のためクロスマージンには注意が必要

レート制限

  • Binance APIのレート制限を尊重する
  • デフォルトのレート制限:
    • 注文操作のリクエストは1分あたり1200件
    • 市場データに対する1秒あたり100件のリクエスト
  • レート制限エラーに対する適切なエラー処理を実装する

エラー処理

よくあるエラーのシナリオ

  • 無効なAPI認証情報
  • 残高または証拠金が不足している
  • 無効な注文パラメータ
  • レート制限を超えました
  • ネットワーク接続の問題

先物特有のエラー

  • InsufficientMarginError: 操作に必要なマージンが足りません
  • InvalidPositionModeError: 位置モードの設定が間違っています
  • OrderValidationError: 先物注文パラメータが無効です

エラー処理の例:

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

発達

  1. 環境変数を設定します。

ルートディレクトリに.envファイルを作成し、Binance API の資格情報を設定します。

BINANCE_API_KEY=your_api_key_here BINANCE_API_SECRET=your_secret_key_here
  1. 依存関係をインストールします:
pnpm install

サーバーを構築します。

pnpm build

自動リビルドを使用した開発の場合:

pnpm watch

インストール

Smithery経由でインストール

Smithery経由で Claude Desktop 用の Binance Trading Server を自動的にインストールするには:

npx -y @smithery/cli install mcp-server-cex-bn --client claude

手動でインストールする

  1. リポジトリをクローンする
  2. 依存関係をインストールします:
pnpm install
  1. .envでBinance APIの認証情報を設定する
  2. サーバーをビルドして起動します。
pnpm build pnpm start

デバッグ

MCPサーバーはstdio経由で通信するため、デバッグが困難になる場合があります。パッケージスクリプトとして提供されているMCP Inspectorの使用をお勧めします。

pnpm inspector

インスペクターは、ブラウザでデバッグ ツールにアクセスするための URL を提供します。

mcp-server-bn

-
security - not tested
F
license - not found
-
quality - not tested

このサーバーは、API 資格情報の安全な管理、スポット注文の実行と管理、アカウント残高とオープン注文の監視など、Binance スポット取引操作のための堅牢なインターフェースを提供します。

  1. Features
    1. Spot Trading Operations
    2. Futures Trading Operations
    3. Tools
  2. Futures Trading Details
    1. Position Modes
    2. Margin Types
    3. Funding Rate
  3. Security Considerations
    1. Spot Trading Security
    2. Futures Trading Security
  4. Rate Limits
    1. Error Handling
      1. Common Error Scenarios
      2. Futures-Specific Errors
    2. Project Structure
      1. Development
        1. Installation
          1. Installing via Smithery
          2. Installing manually
          3. Debugging
        2. mcp-server-bn
          ID: kbmjzs3g81