Skip to main content
Glama
IBKR MCP Server

IBKR MCP Server

IBKR MCP Server

A self-hosted, institutional-grade risk engine for Interactive Brokers — with a full trading, market-data, and execution stack wired behind it.

You run this against your own IB Gateway, on your own account, under your own control. Every order it can place — market, limit, bracket, OCA, trailing stop, TWAP/VWAP/DarkIce/Adaptive algos — fires through a real risk layer first: parametric and historical Value-at-Risk, Kelly and volatility-based position sizing, margin/concentration/buying-power limits, and an automatic loss circuit-breaker that halts trading when you cross a drawdown threshold. Exposing IBKR to an AI assistant is the table stakes. The risk stack is the product.

Why this vs IBKR's official MCP / the free clones

IBKR now ships a free official MCP server, and there are 10+ open-source IBKR MCP clones. They connect an LLM to your account and let it read data and route orders. That's it. None of them ship the risk layer — no VaR, no Kelly/vol sizing engine, no enforced margin/concentration limits, no automatic loss circuit-breaker. The most complete OSS clone stops at option Greeks and a concentration check.

Official IBKR MCP / OSS clones

This server

Connect an LLM to IBKR

✅

✅

Market data, orders, options, futures, scanners

✅

✅

Bracket / OCA / trailing / TWAP / VWAP / DarkIce algos

partial

✅

Parametric + historical VaR

❌

✅

Kelly / volatility position sizing

❌

✅

Enforced margin / concentration / buying-power limits

❌

✅

Automatic loss circuit-breaker (halts trading)

❌

✅

Self-hosted on your own Gateway + account

—

✅

If all you need is "an LLM that can see my IBKR account," use the free official one. This exists for quant prosumers and small funds who want the AI to trade inside hard risk rails they define.

Related MCP server: Interactive Brokers MCP Server

Safety model — you own the risk

This is a tool you self-host and run against your own account and your own IB Gateway. There is no hosted service in the middle touching accounts you don't own, and there is no third party taking custody of anything.

  • Default posture is approval-required. Out of the box, the assistant proposes orders; a human confirms before anything routes.

  • Fully-autonomous (no-human-click) execution is an explicit opt-in that you enable, on your account, on your Gateway. It is off until you turn it on.

  • The risk gates are always in the path regardless of mode — approval-required or autonomous, orders still pass through VaR, sizing, limit, and circuit-breaker checks before reaching the broker.

This is deliberately different from IBKR's liability-driven mandatory-approval design: you decide how much autonomy to grant, because you're the one holding the account and the risk.

Features

Risk Management

  • Value at Risk - Parametric and historical VaR

  • Position Sizing - Fixed risk, Kelly criterion, volatility-based

  • Risk Limits - Margin utilization, concentration, buying power checks

  • Circuit Breaker - Automatic trading halt on excessive losses

Trading

  • Basic Orders - Market, limit, stop orders

  • Bracket Orders - Entry + take profit + stop loss

  • Trailing Stops - By amount or percentage

  • OCA Orders - One-Cancels-All order groups

  • Algo Orders - TWAP, VWAP, Arrival Price, DarkIce, Adaptive, and more

Account & Portfolio

  • Account Summary - Balances, buying power, margin status

  • Positions - Current holdings with P&L

  • Portfolio Analysis - Allocation by asset class, symbol, currency

  • Rebalancing - Calculate and execute rebalancing trades

Market Data

  • Real-time Prices - Live quotes with fast failover

  • Historical Data - OHLCV bars with pagination

  • Level 2 - Order book / market depth

  • Streaming - Real-time data for HFT strategies

  • Symbol Search - Find tradable instruments

Options

  • Option Chains - Full chain with Greeks

  • Spread Analysis - Bull call, bear put, straddle, strangle, iron condor

Futures

  • Futures Chain - All available contracts

  • Rollover Detection - Automatic expiry alerts

  • Continuous Contracts - For historical analysis

Market Scanners

  • Pre-built Scans - Top gainers, losers, most active, unusual volume

  • Custom Scanners - Build your own with filters

  • Options Volume - Unusual options activity

Installation

# From source (this is a private, proprietary repo — not published to PyPI)
git clone git@github.com:YoungMoneyInvestments/ibkr-mcp.git
cd ibkr-mcp
pip install -e .

Note: an unrelated ibkr-mcp package exists on public PyPI — it is NOT this project. Install from source only.

Prerequisites

  1. Interactive Brokers Account - Live or paper trading account

  2. TWS or IB Gateway - Running and accepting API connections

  3. API Configuration in TWS/Gateway:

    • Enable API: Configure > API > Settings > Enable ActiveX and Socket Clients

    • Trusted IPs: Add 127.0.0.1

    • Port: 7497 (paper) or 7496 (live)

Quick Start

1. Start TWS/IB Gateway

Open TWS or IB Gateway and log in. Ensure API connections are enabled.

2. Configure Claude Desktop

Add to your Claude Desktop mcp.json:

{
  "mcpServers": {
    "ibkr": {
      "command": "ibkr-mcp",
      "args": ["--port", "7497"]
    }
  }
}

For live trading (use with caution):

{
  "mcpServers": {
    "ibkr": {
      "command": "ibkr-mcp",
      "args": ["--port", "7496"]
    }
  }
}

3. Use with Claude

"Show me my current positions"
"Get a quote for AAPL"
"Place a limit order to buy 100 shares of MSFT at $400"
"What's the option chain for SPY?"
"Scan for top percentage gainers today"
"Calculate position size for TSLA with $500 risk and stop at $350"

CLI Usage

# Default settings (paper trading, stdio transport)
ibkr-mcp

# Connect to live trading
ibkr-mcp --port 7496

# Read-only mode (no trading)
ibkr-mcp --readonly

# SSE transport for web clients
ibkr-mcp --transport sse --mcp-port 8080

# Verbose logging
ibkr-mcp -v

# Full options
ibkr-mcp --help

Environment Variables

Connection Settings

Variable

Default

Description

IBKR_MODE

-

Connection preset (see below)

IBKR_HOST

127.0.0.1

TWS/Gateway host

IBKR_PORT

7497

TWS/Gateway port (overridden by IBKR_MODE)

IBKR_CLIENT_ID

1

Starting client ID

IBKR_CLIENT_ID_AUTO_RETRY

true

Auto-retry with different client ID on conflict

IBKR_CLIENT_ID_MAX_ATTEMPTS

5

Max attempts to find available client ID

IBKR_READONLY

false

Disable trading

IBKR_TIMEOUT

30

Connection timeout (seconds)

MCP_TRANSPORT

stdio

Transport type

Connection Mode Presets

Use IBKR_MODE to easily switch between platforms:

Mode

Port

Description

tws_paper

7497

TWS Paper Trading (default)

tws_live

7496

TWS Live Trading

gateway_paper

4002

IB Gateway Paper Trading

gateway_live

4001

IB Gateway Live Trading

Examples:

# Connect to IB Gateway paper trading
IBKR_MODE=gateway_paper ibkr-mcp

# Connect to TWS live with custom client ID
IBKR_MODE=tws_live IBKR_CLIENT_ID=10 ibkr-mcp

# Disable client ID auto-retry
IBKR_CLIENT_ID_AUTO_RETRY=false ibkr-mcp

Available Tools

Connection

  • connection_status - Check IBKR connection

  • reconnect - Reconnect to IBKR

Account

  • get_account_summary - Account balances and values

  • get_positions - Current holdings

  • analyze_portfolio_allocation - Portfolio breakdown

  • calculate_rebalancing_orders - Rebalancing plan

  • execute_rebalancing - Execute rebalancing trades

Trading

  • place_order - Market/limit/stop orders

  • place_bracket_order - Bracket orders

  • place_trailing_stop - Trailing stop orders

  • place_one_cancels_all - OCA order groups

  • place_algo_order - Algorithmic orders

  • cancel_order - Cancel an order

  • get_open_orders - List open orders

Market Data

  • get_realtime_price - Real-time quote

  • get_historical_data - Historical bars

  • get_order_book - Level 2 data

  • search_symbols - Symbol search

  • get_news - News bulletins

Options

  • get_option_chain - Options with Greeks

  • analyze_option_spread - Spread strategy analysis

Futures

  • get_futures_chain - Available contracts

  • detect_rollover_needed - Expiry alerts

Scanners

  • scan_market - Pre-built market scans

  • create_custom_scanner - Custom scans

  • scan_options_volume - Unusual options activity

Risk

  • calculate_position_size - Position sizing

  • check_risk_limits - Risk status

  • set_stop_loss_orders - Auto stop losses

  • calculate_var - Value at Risk

Docker

docker build -t ibkr-mcp .
docker run -e IBKR_HOST=host.docker.internal ibkr-mcp

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy src

# Linting
ruff check src

Safety Features

  • Read-only Mode - Disable all trading operations

  • Rate Limiting - Stay under IBKR API limits

  • Circuit Breaker - Automatic halt on excessive losses

  • Input Validation - Validate all order parameters

  • Error Recovery - Automatic reconnection with backoff

License

Proprietary — Copyright (c) 2026 Cameron Bennion. All Rights Reserved. See LICENSE.

Disclaimer

This software is for educational and informational purposes only. Trading involves substantial risk of loss. Past performance is not indicative of future results. Always test with paper trading first.

Available Tools

38 tools
analyze_option_spreadC

Analyze option spread strategies (bull_call, bear_put, straddle, etc.).

Inputs: symbol (required), strike1 (required), strategy (required), expiry, +2 more. Returns: object

analyze_portfolio_allocationB

Analyze portfolio allocation by asset class, symbol, and currency.

Inputs: no named parameters. Returns: object

calculate_position_sizeC

Calculate optimal position size based on risk parameters.

Inputs: symbol (required), stop_loss (required), risk_amount (required), method, +1 more. Returns: object

calculate_rebalancing_ordersC

Calculate trades needed to rebalance portfolio to target allocations.

Inputs: target_allocations (required), use_cash, rebalance_threshold. Returns: object

calculate_slippageC

Calculate execution slippage for an order.

Inputs: order_id (required). Returns: object

calculate_varC

Calculate Value at Risk for the portfolio.

Inputs: time_horizon, confidence_level. Returns: object

cancel_orderC

Cancel an open order.

Inputs: order_id (required). Returns: object

check_risk_limitsB

Check current portfolio against risk limits.

Inputs: no named parameters. Returns: object

circuit_breaker_resetB

Reset the circuit breaker after it has been tripped.

Inputs: admin_override. Returns: object

circuit_breaker_statusB

Get circuit breaker status including trip state, daily P&L, and utilization.

Inputs: no named parameters. Returns: object

connection_statusB

Check IBKR connection status.

Inputs: no named parameters. Returns: object

create_custom_scannerC

Create custom scanner with specific criteria.

Inputs: criteria (required). Returns: object

detect_rollover_neededC

Check if futures contract rollover is needed.

Inputs: symbol (required), exchange, days_before. Returns: object

execute_rebalancingB

Execute rebalancing trades from a rebalancing plan.

Approval-required by default; re-call with confirm=True to transmit the full batch of rebalancing orders, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval. The batch is always all-preview or all-execute -- never a partial mix.

Inputs: rebalancing_plan (required), confirm, order_type, execute_sells_first. Returns: object

get_account_summaryA

Get account summary including balances, buying power, and margin.

Inputs: no named parameters. Returns: object

get_contract_by_conidC

Get contract details by contract ID.

Inputs: con_id (required). Returns: object

get_futures_chainC

Get all available futures contracts for an underlying.

Inputs: underlying (required), exchange. Returns: object

get_historical_dataC

Get historical price data with pagination.

Inputs: symbol (required), page, bar_size, duration, +3 more. Returns: object

get_newsC

Get news bulletins for a symbol.

Inputs: symbol (required), exchange, sec_type. Returns: object

get_open_ordersB

Get all open orders.

Inputs: no named parameters. Returns: object

get_option_chainC

Get option chain with Greeks for a symbol.

Inputs: symbol (required), exchange. Returns: object

get_order_bookC

Get Level 2 order book data (market depth).

Inputs: symbol (required), depth. Returns: object

get_positionsA

Get all current positions with P&L.

Inputs: no named parameters. Returns: object

get_realtime_priceC

Get real-time price for a symbol.

Inputs: symbol (required), exchange, sec_type. Returns: object

place_adaptive_orderB

Place an IB Adaptive algorithmic order.

Approval-required by default; re-call with confirm=True to transmit, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval.

Inputs: action (required), symbol (required), quantity (required), confirm, +3 more. Returns: object

place_algo_orderB

Place an algorithmic order using IBKR's algo strategies.

Approval-required by default; re-call with confirm=True to transmit, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval.

Inputs: action (required), symbol (required), quantity (required), algo_params (required), +4 more. Returns: object

place_arrival_price_orderB

Place an Arrival Price algorithmic order.

Approval-required by default; re-call with confirm=True to transmit, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval.

Inputs: action (required), symbol (required), quantity (required), confirm, +7 more. Returns: object

place_bracket_orderB

Place a bracket order (entry + take profit + stop loss).

Approval-required by default; re-call with confirm=True to transmit, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval.

Inputs: action (required), symbol (required), quantity (required), stop_loss (required), +5 more. Returns: object

place_one_cancels_allB

Place One-Cancels-All (OCA) order group.

Approval-required by default; re-call with confirm=True to transmit, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval.

Inputs: orders (required), oca_group (required), confirm, oca_type. Returns: object

place_orderA

Place a trading order (market, limit, or stop).

Approval-required by default: without confirm=True (and unless IBKR_MCP_AUTONOMOUS_EXECUTION=true), this stages the order and returns a PENDING_APPROVAL preview instead of transmitting it. Re-call with confirm=True to actually submit it to IBKR.

Inputs: action (required), symbol (required), quantity (required), confirm, +5 more. Returns: object

place_trailing_stopB

Place a trailing stop order.

Approval-required by default; re-call with confirm=True to transmit, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval.

Inputs: action (required), symbol (required), quantity (required), confirm, +4 more. Returns: object

place_twap_orderC

Place a TWAP (Time-Weighted Average Price) algorithmic order.

Approval-required by default; re-call with confirm=True to transmit, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval.

Inputs: action (required), symbol (required), quantity (required), confirm, +5 more. Returns: object

place_vwap_orderB

Place a VWAP (Volume-Weighted Average Price) algorithmic order.

Approval-required by default; re-call with confirm=True to transmit, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval.

Inputs: action (required), symbol (required), quantity (required), confirm, +6 more. Returns: object

reconnectB

Reconnect to IBKR.

Inputs: no named parameters. Returns: object

scan_marketC

Run a market scanner (TOP_PERC_GAIN, MOST_ACTIVE, etc.).

Inputs: scan_code (required), location, num_rows, instrument. Returns: object

scan_options_volumeC

Scan for unusual options activity.

Inputs: min_volume, underlying, min_open_interest. Returns: object

search_symbolsC

Search for tradable instruments matching a pattern.

Inputs: pattern (required). Returns: object

set_stop_loss_ordersA

Automatically set stop loss orders for all positions.

Approval-required by default; re-call with confirm=True to transmit the full batch of trailing stops, or set IBKR_MCP_AUTONOMOUS_EXECUTION=true to skip approval. The batch is always all-preview or all-execute -- never a partial mix.

Inputs: confirm, trail_amount, trail_percent. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 38 tools

    Disambiguation4/5

    Most tools have clearly distinct resource+action purposes (data retrieval vs. order placement vs. risk analysis vs. scanning). Minor overlap exists: place_algo_order could be confused with place_twap_order/place_vwap_order/place_arrival_price_order/place_adaptive_order (all algorithmic orders), and set_stop_loss_orders overlaps conceptually with place_trailing_stop. Descriptions help disambiguate but the boundary between generic and specific algo order tools is slightly muddy.

    Naming Consistency4/5

    Strong verb_noun snake_case pattern throughout (get_*, place_*, calculate_*, scan_*, analyze_*). A few deviations exist: noun-only status tools (connection_status, circuit_breaker_status) and inverted phrasing (detect_rollover_needed) break the otherwise predictable convention. Still highly readable overall.

    Tool Count2/5

    38 tools is heavy for any single server. While the domain is broad (market data, orders, algos, risk, scanners, circuit breaker), many order-placement variants (twap, vwap, arrival_price, adaptive, generic algo) could be consolidated into a single parameterized tool, inflating the surface unnecessarily.

    Completeness4/5

    Coverage is very thorough: market data, option/futures chains, multiple order types, risk/VaR, rebalancing, scanners, news, order book, and circuit-breaker management are all present. Minor gaps: no explicit order-modify/replace tool, and no trade/execution history retrieval beyond slippage calculation.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables AI assistants to interact with Interactive Brokers trading accounts to retrieve market data, check positions, and place trades. Includes pre-configured IB Gateway and handles OAuth authentication automatically.
      14
      317 npm
      227
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Connects AI assistants to Interactive Brokers for intelligent portfolio management, options analysis, risk monitoring, and automated trading strategy suggestions. Enables real-time account tracking, Greeks calculations, option chain analysis, and playbook-based risk adjustments through natural language.
      5
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables LLM agents to interact with Interactive Brokers accounts for market data, account info, and order entry with built-in risk controls and a two-step confirmation flow.
      9
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to query and trade through Interactive Brokers using 38 tools for order placement and management with risk checks, account and position data, market and historical data, and options analytics. Includes diagnostics and configurable safety limits, designed primarily for paper trading.
      MIT