Skip to main content
Glama
eikarna

Binance Agent MCP Server

by eikarna

Binance Agent OS โ€” Institutional MCP Server & Trading Engine

Bun Runtime MCP Protocol TypeScript Strict Tests License: MIT

Official Submission for the Binance Agent OS Mini Hackathon ($60K USDC Prize Pool)
Production-grade Model Context Protocol (MCP) server and autonomous trading framework engineered for zero-float precision, cryptographic intent verification (EIP-712), deterministic idempotency, and institutional pre-trade risk policy.


๐Ÿ›๏ธ The 4 Institutional Safeguard Pillars

Most AI trading agents fail in production due to floating point inaccuracies, duplicate order firing on network disconnects, timestamp desynchronization, and lack of pre-trade risk guardrails. This toolkit solves them natively:

                          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                          โ”‚  Autonomous AI Agent   โ”‚
                          โ”‚ (Claude/Cursor/Hermes) โ”‚
                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                      โ”‚ Trade Intent Request
                                      โ–ผ
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚       HARDENED MCP INTERCEPTOR & AGENT OS       โ”‚
             โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
             โ”‚ 1. Idempotency Engine   โ”€โ”€โ–บ SHA-256 Client ID   โ”‚
             โ”‚ 2. Precision Normalizer โ”€โ”€โ–บ LOT_SIZE / TICK_SIZEโ”‚
             โ”‚ 3. Policy Risk Engine   โ”€โ”€โ–บ Cap & Slippage Gate โ”‚
             โ”‚ 4. Resilience Manager   โ”€โ”€โ–บ Clock Sync & Backoffโ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                      โ”‚ Cryptographic EIP-712 Proof
                                      โ–ผ
                          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                          โ”‚  Binance Spot/Futures  โ”‚
                          โ”‚     REST & WebSockets  โ”‚
                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  1. Pre-Trade Policy Engine & Circuit Breaker (src/policy.ts)

    • Hard Notional USD caps per transaction and aggregate 24-hour drawdown limits.

    • Dynamic price slippage collar filters (auto-rejects orders exceeding configurable basis points vs reference price).

    • Strict symbol allowlisting to prevent hallucinated asset routing.

  2. Deterministic Idempotency Shield (src/idempotency.ts)

    • Deterministic clientOrderId generation via SHA-256 hashing of trade intents.

    • Replay protection: Network retries and duplicate events return cached state instead of double-filling on the exchange.

  3. Exchange Resilience & Clock Drift Sentinel (src/resilience.ts)

    • Proactive calibration with Binance Server Time (/api/v3/time) eliminating error -1021 (Timestamp for this request was 1000ms ahead/behind).

    • Real-time X-MBX-USED-WEIGHT-1M header tracking with adaptive backoff to prevent IP rate-limit bans (HTTP 418 / 429).

  4. Zero-Drift Micro-Precision Normalizer (src/precision.ts)

    • String-slicing and BigInt decimal math bypassing JavaScript IEEE-754 floating-point drift (0.1 + 0.2 = 0.30000000000000004).

    • Exact adherence to Binance exchange filters (LOT_SIZE, PRICE_FILTER, MIN_NOTIONAL).

  5. Cryptographic EIP-712 Intent Signing (src/eip712.ts)

    • Typed data domain separation and ECDSA secp256k1 recovery ensuring only authorized agents or human multisig keyholders can broadcast orders.


Related MCP server: GearTrade MCP Server

โšก Interactive Live Demo Runner

Run the interactive TUI demo runner to see the 4 pillars execute in real time:

bun run demo

Live Terminal Snapshot

================================================================================
   BINANCE AGENT OS โ€” INSTITUTIONAL RESILIENCE & MCP DEMO RUNNER                
   Target: Binance Agent OS Mini Hackathon ($60K USDC)                          
================================================================================

[INIT] Initializing Institutional Agent Engine & Calibrating Clock Offset...
โœ“ Binance Server Time Synced: Offset = 0 ms (Protected against error -1021)

โ”Œโ”€โ”€ [SCENARIO 1: Micro-Precision & LOT_SIZE Normalization] โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Raw JavaScript Floating Arithmetic: 0.30000000000000004 (Would trigger LOT_SIZE rejection)
โ”‚ Applying PrecisionEngine Normalizer: 0.3 (stepSize: 0.001)
โ”‚ Status: PASSED โ€” Zero Float Drift
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€ [SCENARIO 2: Pre-Trade Policy Engine & Hard Risk Guardrails] โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Testing Trade: BUY 0.05 BTC @ $65,000 (Notional: $3,250.00 | Cap: $100.00)
โ”‚ Policy Intercept: BLOCKED -> NOTIONAL_CAP_EXCEEDED (Max $100.00 cap)
โ”‚ Testing Trade: BUY 0.001 BTC @ $66,000 (Ref: $65,000 | Diff: 153.8 bps > 50 bps max)
โ”‚ Policy Intercept: BLOCKED -> PRICE_COLLAR_BREACH (Exceeds 0.50% max slippage)
โ”‚ Testing Trade: BUY 0.001 BTC @ $65,010 (Notional: $65.01 | Safe Bounds)
โ”‚ Policy Intercept: APPROVED -> Notional: $65.01
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€ [SCENARIO 3: Deterministic Idempotency & Duplicate Shield] โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Generated Deterministic Order ID: mcp_5da191fa5e5fd27470b6e9c25b10
โ”‚ Order 1 Dispatched -> Status: EXECUTED (FILLED)
โ”‚ Simulating Network Retry / Duplicate Event...
โ”‚ Duplicate Intercept: BLOCKED DUPLICATE ORDER (Safe Replay)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€ [SCENARIO 4: Rate-Limit Sentinel & Backoff Throttling] โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Simulated Inbound Used Weight: 1050 / 1200 (87.5% - High Load Threshold)
โ”‚ Throttling Sentinel: Backing off for 5100ms to prevent IP ban (HTTP 418/429)
โ”‚ Status: PASSED โ€” Proactive Exchange Safety Protected
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ MCP Tools & Capabilities

Tool Name

Auth

Description

binance_get_ticker

Public

Real-time 24hr rolling window price, volume, and spread stats.

binance_get_orderbook

Public

Depth analysis with live bid/ask spread and imbalance ratio.

binance_get_klines

Public

Candlestick series for technical indicator processing (EMA/RSI/MACD).

binance_detect_arbitrage

Public

Autonomous multi-pair triangular arbitrage opportunity scanner.

binance_create_order

Signed

Safe SPOT order execution with policy validation & dry-run toggle.

binance_cancel_order

Signed

Order cancellation with deterministic ID matching.

binance_get_account

Signed

Account balances, asset allocation, and free margin inspection.


๐Ÿš€ Quickstart

1. Prerequisites

2. Installation

git clone https://github.com/eikarna/binance-agent-mcp.git
cd binance-agent-mcp
bun install

3. Environment Setup (.env)

BINANCE_API_KEY="your_api_key_here"
BINANCE_API_SECRET="your_api_secret_here"
BINANCE_USE_TESTNET="true" # Set to false for live production API
BINANCE_DRY_RUN="true"     # Simulation mode for testing

4. Connect to Cursor / Claude Desktop / Hermes Agent

Add the server to your claude_desktop_config.json or Cursor MCP settings:

{
  "mcpServers": {
    "binance-agent-os": {
      "command": "bun",
      "args": ["run", "C:/path/to/binance-agent-mcp/src/index.ts"],
      "env": {
        "BINANCE_API_KEY": "your_api_key",
        "BINANCE_API_SECRET": "your_api_secret",
        "BINANCE_DRY_RUN": "true"
      }
    }
  }
}

๐Ÿงช Testing & Verification

# Run unit & security test suite
bun test

# Strict TypeScript type checking
bun run typecheck

# Run interactive TUI demo
bun run demo

๐Ÿ›๏ธ Full MCP Specification Compliance

Unlike tool-only wrappers, this server implements all 3 core primitives of the Model Context Protocol:

  1. Tools: Hardened execution functions guarded by pre-trade risk policies and float-drift protection.

  2. Resources (binance://market/{symbol}, binance://risk/parameters): Dynamic contextual feeds exposing real-time order books, spreads, and pre-trade risk thresholds directly into the LLM context.

  3. Prompts (analyze_orderbook_imbalance, execute_guarded_trade): Standardized system workflows guiding autonomous agents to inspect order book depth and evaluate risk boundaries before submitting orders.


๐Ÿ“œ License

MIT ยฉ Nix Seymour

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to perform cryptocurrency trading operations on Binance exchange through 30 comprehensive tools supporting spot trading, futures contracts, options, account management, market data analysis, and risk control features. Provides enterprise-grade security with local encrypted API key storage and supports multiple account types with sandbox environment testing.
    9
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI assistants to perform cryptocurrency trading analysis and execution with 38+ tools including real-time market data, technical indicators, risk management, and support for both paper trading and live execution on Hyperliquid.
    7
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    Enables AI assistants to interact with a complete trading infrastructure, including live futures bots, real market data, backtesting, and copy-trading signals. Supports 503 tools across 20 domains, from market data to order execution, with zero synthetic data.
    100
    1
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/eikarna/binance-agent-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server