mm-ibkr-mcp
Connect to Interactive Brokers for agent-driven account monitoring and trade execution with safety gates.
Check gateway health, trading status, schedule, account summary, positions, P&L, open orders, and order status.
Resolve contracts, fetch quotes, historical bars, option chains, and option snapshots with greeks.
Preview single orders or baskets, assess portfolio impact, risk, and profile/position limits.
Place/cancel single orders or order sets, and create/submit/reconcile/cancel persistent basket trade intents.
Request and poll Telegram approvals for trades, intents, and environment changes; send notifications.
Switch live/paper environments with approval, query session activity and audit logs.
Trigger an emergency stop to cancel all orders and disable trading.
Enables human-in-the-loop approval for trade orders and trade intents via Telegram bot and chat messages.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mm-ibkr-mcp Preview an order to buy 100 shares of AAPL"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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:
control.jsonorders_enableddry_runblock_reason
MCP_ORDER_APPROVAL_MODEtelegram: order submission requires Telegram approvalyolo: no approval gate
Safe defaults are:
orders_enabled=falsedry_run=trueMCP_ORDER_APPROVAL_MODE=telegram
Configuration
On first start, uv run ibkr-mcp creates safe defaults for:
data/ibkr-mcp/config.jsondata/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=telegramIf 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 devStart the MCP server over stdio:
uv run ibkr-mcpThe 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-mcpRemote 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 hostthe MCP process connects to the gateway through that host's own
127.0.0.1:4001/127.0.0.1:4002OpenCode 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:
healthget_trading_statusget_schedule_statusget_account_summaryget_positionsget_pnllist_open_ordersget_order_statuspreview_orderplace_ordercancel_order
Basket execution:
preview_order_basketcreate_trade_intentrequest_trade_intent_approvalsubmit_trade_intentget_trade_intentlist_trade_intentsreconcile_trade_intentcancel_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_changecheck_approval_statusemergency_stop
Expected workflow
Single order:
get_trading_statusresolve_contractpreview_orderassess_order_impactvalidate_against_profileIf
MCP_ORDER_APPROVAL_MODE=telegram, request approvalplace_order
Basket:
preview_order_basketcreate_trade_intentIf
MCP_ORDER_APPROVAL_MODE=telegram, request approvalsubmit_trade_intentreconcile_trade_intent
Persistence
The MCP server uses one SQLite database for:
audit_logorder_historyapprovalstrade_intentintent_orderexecution_stateposition_snapshot
This gives the agent one durable source of truth for approvals, order submission, reconciliation, and audit.
Available Tools
39 toolsassess_order_impactAssess Order ImpactBRead-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 OrderADestructive
Cancel a single open order by order id.
Inputs: order_id (required). Returns: Result of a cancel order request.
cancel_order_setCancel Order SetADestructive
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 IntentADestructive
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 StatusBRead-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 LimitsBRead-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 IntentBDestructiveIdempotent
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 StopADestructive
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 ChangeADestructive
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 SummaryBRead-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 ProfileARead-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 LogARead-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 BarsARead-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 ChainCRead-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 SnapshotARead-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 StatusBRead-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 StatusBRead-onlyIdempotent
Get the latest status for a single order id.
Inputs: order_id (required). Returns: Current status of an order at IBKR.
get_pnlGet PnLCRead-onlyIdempotent
Get account P&L with per-symbol breakdown.
Inputs: timeframe, account_id. Returns: Aggregated account-level P&L.
get_portfolio_riskGet Portfolio RiskBRead-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 PositionsARead-onlyIdempotent
List open positions for an account.
Inputs: account_id. Returns: Positions response wrapper.
get_quoteGet QuoteBRead-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 StatusARead-onlyIdempotent
Inspect the configured trading schedule window.
Inputs: no named parameters. Returns: Current trading schedule status.
get_session_activityGet Session ActivityARead-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 IntentARead-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 StatusBRead-onlyIdempotent
Inspect trading-control state from control.json.
Inputs: no named parameters. Returns: Trading control state from control.json.
healthIBKR HealthARead-onlyIdempotent
Check gateway connectivity and basic runtime health.
Inputs: no named parameters. Returns: High-level gateway health status.
list_open_ordersList Open OrdersARead-onlyIdempotent
List currently open orders on the active IBKR connection.
Inputs: no named parameters. Returns: Open orders response wrapper.
list_trade_intentsList Trade IntentsBRead-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 OrderADestructiveIdempotent
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 OrderARead-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 BasketARead-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 IntentBRead-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 ContractARead-onlyIdempotent
Resolve a SymbolSpec into a fully qualified IBKR contract.
Inputs: instrument (required). Returns: Fully resolved IBKR contract details.
submit_trade_intentSubmit Trade IntentADestructiveIdempotent
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 ProfileBRead-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
Scored across 39 tools
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.
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).
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.
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
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
Open-source MCP server for Zerodha Kite Connect. Portfolio, market data, backtesting, alerts.
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn 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.6MIT
- AlicenseBqualityDmaintenanceMCP server for Interactive Brokers API, enabling account management, trading, market data, options, scanners, and news via natural language.333MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server for Interactive Brokers, enabling account management, trading operations, and market data queries.8MIT
- AlicenseNot gradedqualityDmaintenanceMCP 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.1MIT