Skip to main content
Glama
mm-ibkr-mcp

mm-ibkr-mcp

by MrRolie

mm-ibkr-mcp

⚠️ LIVE CAPITAL AT RISK — USE AT YOUR OWN RISK

This project connects to Interactive Brokers and can place real, irreversible trades with real money. It is a proof-of-concept research implementation for agent-driven trading workflows. It is not financial advice, not a licensed trading system, and not production-ready.

Agent systems can and do make errors: misnamed parameters, hallucinated calculations, incorrect order quantities, and wrong order sides have all been observed in testing. The human-in-the-loop Telegram approval gate exists precisely because automated execution without oversight is dangerous.

You are solely responsible for any losses incurred through use of this software. If you do not understand the risks, do not use this project.

mm-ibkr-mcp is the canonical Interactive Brokers MCP repo for agent-driven account monitoring and trade execution.

It assumes the user already has IB Gateway or TWS running locally. This repo does not manage the broker process. Its job is to connect, inspect account state, preview orders, place trades, persist execution state, and gate submissions through Telegram when required.

This repo is the canonical monitoring and trading MCP surface.

Scope

Included:

  • account health, balances, P&L, positions, open orders

  • market data, contract resolution, options chain and snapshot tools

  • single-order preview and placement

  • durable basket execution through persisted trade intents

  • SQLite-backed audit, approvals, trade intents, execution state, and position snapshots

  • Telegram approval flow for single orders and baskets

  • compare-and-swap admin control over control.json

Not included as part of the canonical workflow:

  • starting or stopping IB Gateway

  • web UI or REST admin as a first-class interface

  • schedulers, signal ingestion, or separate OMS daemons

Related MCP server: ib-async-mcp

Safety model

Two layers control execution:

  1. control.json

    • orders_enabled

    • dry_run

    • block_reason

  2. MCP_ORDER_APPROVAL_MODE

    • telegram: order submission requires Telegram approval

    • yolo: no approval gate

Safe defaults are:

  • orders_enabled=false

  • dry_run=true

  • MCP_ORDER_APPROVAL_MODE=telegram

Configuration

On first start, uv run ibkr-mcp creates safe defaults for:

  • data/ibkr-mcp/config.json

  • data/ibkr-mcp/control.json

Edit config.json to match your local IB Gateway or TWS connection:

{
  "ibkr_host": "127.0.0.1",
  "ibkr_port": 4002,
  "ibkr_client_id": 1,
  "default_account_id": null
}

.env is optional. Copy .env.example to .env only if you want Telegram approval or explicit yolo mode:

MCP_ORDER_APPROVAL_MODE=telegram

If using Telegram approval mode, also set:

TELEGRAM_BOT_TOKEN=...
TELEGRAM_CHAT_ID=...

For monitoring only, you can leave .env empty and use the default approval posture.

Advanced-only environment overrides:

MM_IBKR_DATA_DIR=/path/to/data
MM_IBKR_CONFIG_PATH=/path/to/config.json
MM_IBKR_CONTROL_DIR=/path/to/control-dir
MCP_TRANSPORT=streamable-http
MCP_HOST=127.0.0.1
MCP_PORT=8001
MCP_AUTH_TOKEN=change-me
MCP_ENABLE_ADMIN_TOOLS=true
APPROVED_UNUSED_EXPIRY_SECONDS=600   # auto-expiry for approved-but-unused approvals (default 600 s)

Running

Install dependencies:

uv sync --group dev

Start the MCP server over stdio:

uv run ibkr-mcp

The default transport is local stdio, which is the lowest-friction MCP setup for Claude Code/Desktop style clients.

Run over HTTP only for advanced self-hosted setups:

export MCP_TRANSPORT=streamable-http
export MCP_HOST=127.0.0.1
export MCP_PORT=8001
export MCP_AUTH_TOKEN=change-me
uv run ibkr-mcp

Remote Execution Host

If IB Gateway runs on another machine, the recommended agent setup is to run mm-ibkr-mcp on that execution host and launch it over SSH stdio from the client machine.

Why this is preferred:

  • control.json, approvals, and audit state stay on the execution host

  • the MCP process connects to the gateway through that host's own 127.0.0.1:4001 / 127.0.0.1:4002

  • OpenCode or Claude does not need a separate local socket tunnel for the execution workflow

Use local SSH port forwarding only for other applications that require local gateway sockets on the client machine, such as a tracker or sync job that connects directly through ib_insync.

Canonical tools

Core monitoring and execution:

  • health

  • get_trading_status

  • get_schedule_status

  • get_account_summary

  • get_positions

  • get_pnl

  • list_open_orders

  • get_order_status

  • preview_order

  • place_order

  • cancel_order

Basket execution:

  • preview_order_basket

  • create_trade_intent

  • request_trade_intent_approval

  • submit_trade_intent

  • get_trade_intent

  • list_trade_intents

  • reconcile_trade_intent

  • cancel_trade_intent

Approval and safety:

  • request_trade_approval (Blocks until approved/denied/timeout)

  • request_trade_intent_approval (Blocks until approved/denied/timeout)

  • request_environment_change (Blocks until approved/denied/timeout)

  • execute_environment_change

  • check_approval_status

  • emergency_stop

Expected workflow

Single order:

  1. get_trading_status

  2. resolve_contract

  3. preview_order

  4. assess_order_impact

  5. validate_against_profile

  6. If MCP_ORDER_APPROVAL_MODE=telegram, request approval

  7. place_order

Basket:

  1. preview_order_basket

  2. create_trade_intent

  3. If MCP_ORDER_APPROVAL_MODE=telegram, request approval

  4. submit_trade_intent

  5. reconcile_trade_intent

Persistence

The MCP server uses one SQLite database for:

  • audit_log

  • order_history

  • approvals

  • trade_intent

  • intent_order

  • execution_state

  • position_snapshot

This gives the agent one durable source of truth for approvals, order submission, reconciliation, and audit.

Available Tools

39 tools
assess_order_impactAssess Order ImpactB
Read-onlyIdempotent

Compute portfolio-level impact of a proposed order: concentration change, buying-power usage, margin impact, and max-loss estimate. Provide an OrderPreview from ibkr_preview_order for the best accuracy.

Inputs: order (required), preview, account_id. Returns: Pre-trade order impact assessment.

cancel_orderCancel OrderA
Destructive

Cancel a single open order by order id.

Inputs: order_id (required). Returns: Result of a cancel order request.

cancel_order_setCancel Order SetA
Destructive

Cancel a set of related orders, such as bracket legs.

Inputs: order_ids (required). Returns: Result of a cancel order request.

cancel_trade_intentCancel Trade IntentA
Destructive

Cancel all active broker orders associated with a trade intent.

Inputs: intent_id (required). Returns: Result of cancelling active orders for a trade intent.

check_approval_statusCheck Approval StatusB
Read-onlyIdempotent

Poll the status of a pending trade, trade-intent, or execution-unlock approval. Status values: pending | approved | denied | expired | used.

Inputs: approval_id (required). Returns: Status of a human-in-the-loop approval request.

check_position_limitsCheck Position LimitsB
Read-onlyIdempotent

Validate a proposed order against the active agent profile's position limits. Returns passed=true when no violations are found.

Inputs: order (required), account_id, profile_id. Returns: Result of checking an order against position limits.

create_trade_intentCreate Trade IntentB
DestructiveIdempotent

Create or return an idempotent basket-style trade intent from explicit orders. This persists the basket and optional previews before submission.

Inputs: orders (required), reason (required), account_id, preview_orders. Returns: Response model for a basket-oriented trade intent.

emergency_stopEmergency StopA
Destructive

PANIC BUTTON: cancel ALL open orders, disable order placement in control.json, and send a Telegram alert. Use only in emergency situations.

Inputs: reason. Returns: Result of executing an emergency stop.

execute_environment_changeExecute Environment ChangeA
Destructive

Apply an approved environment change. Provide the approval_id from ibkr_request_environment_change. This applies safety locks to control.json and switches the active connection port in config.json. The connection will automatically reconnect on the next tool call.

Inputs: target_env (required), approval_id (required). Returns: result

get_account_summaryGet Account SummaryB
Read-onlyIdempotent

Get balances, buying power, and margin metrics for an account.

Inputs: account_id. Returns: High-level snapshot of account status.

get_agent_profileGet Agent ProfileA
Read-onlyIdempotent

Load and return the active agent trading profile with its constraints. Use profile_id to fetch a specific profile, or omit to load the default.

Inputs: profile_id. Returns: An agent's trading profile / constraint set.

get_audit_logGet Audit LogA
Read-onlyIdempotent

Query the SQLite audit log. Filter by event_type, symbol, account_id, or date range. Returns up to limit entries (default 50, max 200).

Inputs: limit, since, until, symbol, +2 more. Returns: Paginated audit log query result.

get_historical_barsGet Historical BarsA
Read-onlyIdempotent

Get historical OHLCV bars for a fully specified instrument.

Inputs: bar_size (required), duration (required), instrument (required), rth_only, +1 more. Returns: Historical bar response wrapper.

get_option_chainGet Option ChainC
Read-onlyIdempotent

Discover single-leg option contracts for an underlying and return a bounded list of qualified candidates.

Inputs: underlying (required), rights, expiries, expiry_end, +6 more. Returns: Filtered option chain for an underlying instrument.

get_option_snapshotGet Option SnapshotA
Read-onlyIdempotent

Get quote, volatility, and greeks for a fully specified single-leg option.

Inputs: instrument (required). Returns: Option quote plus greeks and volatility fields.

get_order_set_statusGet Order Set StatusB
Read-onlyIdempotent

Get aggregate status for a list of related order ids.

Inputs: order_ids (required). Returns: Aggregated status for a set of order ids.

get_order_statusGet Order StatusB
Read-onlyIdempotent

Get the latest status for a single order id.

Inputs: order_id (required). Returns: Current status of an order at IBKR.

get_pnlGet PnLC
Read-onlyIdempotent

Get account P&L with per-symbol breakdown.

Inputs: timeframe, account_id. Returns: Aggregated account-level P&L.

get_portfolio_riskGet Portfolio RiskB
Read-onlyIdempotent

Compute portfolio-wide risk metrics: margin utilisation, concentration by symbol, unrealised P&L, and an overall risk level.

Inputs: account_id. Returns: Portfolio-wide risk metrics.

get_positionsGet PositionsA
Read-onlyIdempotent

List open positions for an account.

Inputs: account_id. Returns: Positions response wrapper.

get_quoteGet QuoteB
Read-onlyIdempotent

Get a market-data snapshot for a fully specified instrument.

Inputs: instrument (required). Returns: Snapshot of current market data for a single instrument.

get_schedule_statusSchedule StatusA
Read-onlyIdempotent

Inspect the configured trading schedule window.

Inputs: no named parameters. Returns: Current trading schedule status.

get_session_activityGet Session ActivityA
Read-onlyIdempotent

Summarise trading activity for today's session: orders placed, filled, cancelled, and pending — with a list of the most recent orders.

Inputs: no named parameters. Returns: Summary of trading activity for the current session / today.

get_trade_intentGet Trade IntentA
Read-onlyIdempotent

Fetch the persisted state of a trade intent and its orders.

Inputs: intent_id (required). Returns: Response model for a basket-oriented trade intent.

get_trading_statusTrading StatusB
Read-onlyIdempotent

Inspect trading-control state from control.json.

Inputs: no named parameters. Returns: Trading control state from control.json.

healthIBKR HealthA
Read-onlyIdempotent

Check gateway connectivity and basic runtime health.

Inputs: no named parameters. Returns: High-level gateway health status.

list_open_ordersList Open OrdersA
Read-onlyIdempotent

List currently open orders on the active IBKR connection.

Inputs: no named parameters. Returns: Open orders response wrapper.

list_trade_intentsList Trade IntentsB
Read-onlyIdempotent

List recent persisted trade intents with optional status filtering.

Inputs: limit, status. Returns: List response for recent trade intents.

notifySend Telegram NotificationA

Send an informational notification to the operator via Telegram. No approval required; purely informational.

Inputs: body (required), title (required), level. Returns: Result of sending a Telegram notification.

place_orderPlace OrderA
DestructiveIdempotent

Place a single-leg or bracket order. Requires a clientOrderId. When MCP_ORDER_APPROVAL_MODE=telegram, an approval_id from ibkr_request_trade_approval is also required.

Inputs: order (required), approval_id. Returns: Result of an attempt to place an order.

preview_orderPreview OrderA
Read-only

Preview a single-leg or bracket order without placing it.

Inputs: order (required). Returns: Estimated impact and characteristics of an order, without sending it.

preview_order_basketPreview Order BasketA
Read-only

Preview a basket of explicit orders without placing them.

Inputs: orders (required). Returns: Preview response for a basket of explicit orders.

reconcile_trade_intentReconcile Trade IntentB
Read-onlyIdempotent

Refresh a trade intent against current broker order status and positions.

Inputs: intent_id (required). Returns: Response model for a basket-oriented trade intent.

request_environment_changeRequest Environment ChangeA

Send a request to the operator via Telegram to switch the IBKR connection between 'live' (real-money) and 'paper' (simulated) environments. Returns an approval_id — poll ibkr_check_approval_status until resolved. Once approved, you MUST use the ibkr_execute_environment_change tool with the approval_id to actually apply the change. Switching environments will automatically engage safety locks (orders disabled, dry-run enabled).

Inputs: reason (required), target_env (required). Returns: Status of a human-in-the-loop approval request.

request_trade_approvalRequest Trade ApprovalA

Send a trade approval request to the operator via Telegram. Returns an approval_id to poll with ibkr_check_approval_status. When MCP_ORDER_APPROVAL_MODE=telegram, this approval_id must be passed to ibkr_place_order.

Inputs: order (required), reason (required), preview. Returns: Status of a human-in-the-loop approval request.

request_trade_intent_approvalRequest Trade Intent ApprovalA

Request a single Telegram approval covering a persisted trade intent. In YOLO mode, the approval is auto-approved immediately.

Inputs: intent_id (required). Returns: Status of a human-in-the-loop approval request.

resolve_contractResolve ContractA
Read-onlyIdempotent

Resolve a SymbolSpec into a fully qualified IBKR contract.

Inputs: instrument (required). Returns: Fully resolved IBKR contract details.

submit_trade_intentSubmit Trade IntentA
DestructiveIdempotent

Submit the planned orders in a persisted trade intent. Requires a trade-intent approval when MCP_ORDER_APPROVAL_MODE=telegram.

Inputs: intent_id (required), approval_id. Returns: Response model for a basket-oriented trade intent.

validate_against_profileValidate Against ProfileB
Read-onlyIdempotent

Check a proposed order against the agent's trading profile constraints. Returns passed=true and an empty violations list when the order is within limits.

Inputs: order (required), account_id, profile_id. Returns: Result of validating a proposed order against an agent profile.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 39 tools

    Disambiguation2/5

    Several tool names are duplicated (preview_order, place_order, cancel_order) and approval-related tools overlap (request_trade_intent_approval vs request_trade_approval), making it hard to select the correct operation. Order intent and order status tools also cover similar territory.

    Naming Consistency3/5

    Most tools use a clear snake_case verb_noun pattern, but exceptions like health, notify, and emergency_stop break the convention, and similar concepts are named inconsistently (get_option_chain vs get_option_snapshot, request_trade_intent_approval vs request_trade_approval).

    Tool Count3/5

    At 40 listed tools, the surface is quite large for a trading server, and duplicate entries inflate the count. The breadth is justifiable for IBKR trading operations, but it feels boundary-heavy and would benefit from consolidation.

    Completeness4/5

    The set covers the main trading lifecycle (intents, orders, approvals, execution), market data, account positions, risk checks, environment switching, and audit logging. Missing multi-leg option discovery or order modification tools are minor gaps given the basket and cancel/re-submit capabilities.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables interaction with Interactive Brokers TWS/Gateway via natural language for portfolio management and market data retrieval. It provides tools for account summaries, historical data, and a secure two-step confirmation process for placing and canceling orders.
      6
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      MCP server for Interactive Brokers API, enabling account management, trading, market data, options, scanners, and news via natural language.
      33
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server for Interactive Brokers, enabling account management, trading operations, and market data queries.
      8
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for Interactive Brokers that exposes portfolio data, market quotes, trading, and analysis to any MCP-compatible AI client, with support for EU investors and safety-gated trading.
      1
      MIT