Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MCP

The package exposes provider-neutral MCP tooling for local stdio clients and remote HTTP clients.

Broker authentication remains separate from MCP authorization. MCP bearer tokens must never be forwarded to IBKR.

Local Stdio

ibkr-agent mcp serve --transport stdio --describe --json
ibkr-agent mcp serve --transport stdio --json

Use --describe for a smoke check that exits immediately. Omit it when wiring an MCP client; the command then runs a line-oriented JSON-RPC stdio loop.

The local server lists only tools whose scopes are enabled by the current CLI config. Every tools/call enforces the tool scope before backend access and writes an audit event for completion, denial, refusal, or failure.

Example client configs live under examples/mcp-clients/.

Remote HTTP

Remote MCP is disabled by default and requires explicit configuration plus the independent safety flag. See remote-mcp-oauth.md.

Use --describe for a config smoke check, or omit it to bind the HTTP listener and serve JSON-RPC requests on POST /mcp:

ibkr-agent mcp serve --transport http --describe --enable-remote-mcp --json
ibkr-agent --config config/remote.example.yaml mcp serve --transport http --enable-remote-mcp --bind 127.0.0.1:8080

The HTTP transport validates OAuth/OIDC bearer tokens, serves protected-resource metadata, filters tool discovery by granted scopes, and routes authorized tools/call requests through the same handlers as stdio.

Tool Registry

Read tools:

ToolScope
ibkr_healthibkr:health:read
ibkr_backend_statusibkr:health:read
ibkr_session_requirementsibkr:health:read
ibkr_session_renewibkr:health:read
ibkr_kill_switch_statusibkr:health:read
ibkr_accounts_listibkr:accounts:read
ibkr_account_metadataibkr:accounts:read
ibkr_account_summaryibkr:portfolio:read
ibkr_pnl_dailyibkr:portfolio:read
ibkr_pnl_realtimeibkr:portfolio:read
ibkr_positions_listibkr:positions:read
ibkr_portfolio_snapshotibkr:portfolio:read
ibkr_contracts_searchibkr:marketdata:read
ibkr_contract_resolveibkr:marketdata:read
ibkr_market_snapshotibkr:marketdata:read
ibkr_historical_barsibkr:marketdata:read
ibkr_options_chainibkr:options:read
ibkr_option_greeksibkr:options:read
ibkr_market_depthibkr:marketdata:depth:read
ibkr_scanner_runibkr:scanner:read
ibkr_news_listibkr:news:read
ibkr_news_articleibkr:news:read
ibkr_fundamentals_getibkr:fundamentals:read
ibkr_market_sessionibkr:calendar:read
ibkr_market_holidaysibkr:calendar:read
ibkr_currency_rateibkr:currency:read
ibkr_transfer_historyibkr:transfers:read
ibkr_orders_listibkr:orders:read
ibkr_orders_historyibkr:orders:read
ibkr_order_statusibkr:orders:read
ibkr_executions_listibkr:orders:read
ibkr_limits_statusibkr:risk:read
ibkr_audit_tailibkr:audit:read
ibkr_audit_exportibkr:audit:export

Preview and paper tools are discoverable when their scopes are enabled:

ToolScope
ibkr_order_previewibkr:orders:preview
ibkr_bracket_order_previewibkr:orders:preview
ibkr_paper_order_submitibkr:orders:paper:submit
ibkr_paper_order_cancelibkr:orders:paper:cancel
ibkr_paper_order_modifyibkr:orders:paper:modify
ibkr_paper_bracket_order_submitibkr:orders:paper:submit
ibkr_approvals_createibkr:approvals:create

Live tools are discoverable when live scopes are enabled:

ToolScope
ibkr_live_order_submitibkr:orders:live:submit
ibkr_live_order_cancelibkr:orders:live:cancel
ibkr_live_order_modifyibkr:orders:live:modify
ibkr_live_bracket_order_submitibkr:orders:live:submit

Live submit arguments are account_id, approval_id, preview_id, and idempotency_key. Live modify arguments are account_id, broker_order_id, approval_id, preview_id, idempotency_key, and at least one bounded change. The handlers load approval, preview, live policy, writer, market snapshot, and audit state from the server runtime; these values are not trusted from the MCP payload. Successful submits are added to the live reconciliation backlog. Cancel and modify results preserve the broker status, and only terminal states are removed from pending reconciliation.

Bracket submit tools require three approvals that belong to the same server-persisted bracket preview. Mixed approvals from different preview groups are refused before any paper or live writer boundary. Paper bracket submit also persists durable idempotency state and consumes the three approvals after a successful grouped submit.

The first specs/009-mcp-tool-maturity/ additions are consultative and safety read tools: PnL, order history, account metadata, kill switch status, live limits status, MCP audit export, and explicit session renewal. Write-capable modify additions are explicit (ibkr_paper_order_modify and ibkr_live_order_modify), while the generic ibkr_order_modify name remains forbidden.

The same maturity spec adds contextual reads for news, fundamentals, market session/holiday data, FX rates, and transfer history. ibkr_approvals_create is a gateway workflow write, not a broker write: it requires ibkr:approvals:create and an existing unexpired preview persisted by the server.

Forbidden Generic Write Tools

These generic write-like names remain forbidden:

  • ibkr_order_intent_validate
  • ibkr_order_preview_explain
  • ibkr_order_submit
  • ibkr_order_cancel
  • ibkr_order_modify
  • ibkr_order_approve

Use the explicit preview, paper, or live-gated tools instead. Direct calls to forbidden names return READONLY_WRITE_FORBIDDEN and are auditable.

Safety Boundary

Tool outputs must not include broker cookies, tokens, credentials, sensitive headers, local secret paths, or raw Client Portal Gateway session material. Scope checks happen before broker access. Missing scope returns AUTH_MISSING_SCOPE and does not call the backend.