ibkr-mcp
Click on "Install 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., "@ibkr-mcppreview a buy order for 10 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.
ibkr-mcp — an LLM-driven trading agent for Interactive Brokers
A Model Context Protocol server that exposes an Interactive Brokers account — account data, market data, and order entry — as a set of tools an LLM agent (Claude Desktop, Claude Code, any MCP client) can call. It pairs that with a pre-trade risk engine and a two-step confirm-before-trade flow so an autonomous model can't fat-finger a live account.
The whole thing runs offline out of the box against a built-in market
simulator, so it's reviewable with zero setup — no TWS, no IB Gateway, no
network, not even the mcp package for the demo and tests.
python examples/demo_cli.py # full preview -> place -> blocked-order flow, offline
python tests/test_risk.py # 7 risk-engine tests
python tests/test_session.py # 6 session/safety-flow testsWhy this design
Letting an LLM place trades is the interesting, dangerous part. Three decisions carry the design:
The agent never touches the broker SDK directly. Tools talk to a
TradingSession, which talks to aBrokerinterface. Two implementations sit behind that interface — a liveib_asyncbackend and an in-memory simulator — so the agent-facing contract is identical whether you're on a paper account or running offline.Trading is a two-step handshake, not one tool call. The model must
preview_order(...)first; that returns the live quote, the estimated notional, a risk decision, and — only if risk passes and trading is enabled — a single-useconfirmation_token. Onlyplace_order(token)submits. The order is re-validated against the risk limits at execution time, because price and position may have moved since the preview.Safe by default. With no configuration you get the
mockbackend with trading disabled (read-only). Going live is an explicit, multi-flag opt-in.
Related MCP server: IBKR TWS MCP Server
Architecture
MCP client (Claude)
│ stdio / JSON-RPC
▼
┌──────────────────┐ tool docstrings = the agent's contract
│ server.py │ get_status · get_account_summary · get_positions
│ (FastMCP tools) │ get_quote · get_open_orders · get_trades
└────────┬─────────┘ preview_order ──► place_order · cancel_order
▼
┌──────────────────┐ two-step order flow, single-use confirmation tokens,
│ session.py │ execution-time re-validation
└────┬───────────┬─┘
▼ ▼
┌─────────┐ ┌──────────────────┐
│ risk.py │ │ broker/ (Broker) │
│ pre- │ │ ├─ mock.py ◄── offline simulator (default)
│ trade │ │ └─ ibkr.py ◄── live ib_async → TWS / IB Gateway
│ checks │ └──────────────────┘
└─────────┘Everything except server.py (FastMCP) and broker/ibkr.py (ib_async) is pure
standard library, which is why the simulator and tests need no dependencies.
Tool catalog
Tool | Purpose |
| Backend, connection, trading on/off, active risk limits |
| Net liquidation, cash, buying power, P&L |
| Open positions with cost basis and unrealized P&L |
| Bid / ask / last / mid snapshot |
| Working (unfilled) orders |
| Execution blotter |
| Step 1 — risk-check an order, return a confirmation token |
| Step 2 — submit a previewed, re-validated order |
| Cancel a working order |
Risk controls (risk.py)
Enforced before any order is accepted, and again at execution time:
per-order quantity cap
per-order notional cap
resulting position notional cap
short-selling switch (off by default)
optional symbol whitelist
daily order count cap
All are configurable via environment variables (see .env.example).
Running it
Offline demo / tests (no install)
python examples/demo_cli.py
python tests/test_risk.py && python tests/test_session.pyAs an MCP server
pip install "mcp[cli]"
python -m ibkr_mcp.server # serves over stdioRegister it with an MCP client using examples/claude_desktop_config.example.json.
Against a real (paper) IBKR account
pip install ib_asyncLaunch TWS or IB Gateway with the API enabled, logged into a paper account (account id starts with
DU).Set the environment and run:
export IBKR_BACKEND=ib export IBKR_TRADING_ENABLED=true export IBKR_PORT=7497 # paper TWS export IBKR_ACCOUNT_ID=DUxxxxxxx python -m ibkr_mcp.server
Safety: keep
IBKR_TRADING_ENABLED=falsefor read-only analysis. Point at a paper account before ever enabling trades. The risk caps are the backstop, not the first line of defense — the read-only default is.
Layout
ibkr_mcp/
models.py dataclasses: Quote, Position, Order, Trade, AccountSummary
config.py env-driven Settings + RiskLimits (safe defaults)
risk.py pure pre-trade risk engine
session.py two-step order flow, token store, re-validation
server.py FastMCP tool layer (the agent contract)
broker/
base.py abstract Broker interface
mock.py offline market simulator
ibkr.py live ib_async backend
examples/ offline demo + MCP client config
tests/ risk + session/safety-flow testsLicense
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/Kris-Wang05/ibkr-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server