IBKR MCP Server
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., "@IBKR MCP ServerShow my positions and P&L, then precheck a 100-share AAPL order at $190"
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 Server
An MCP server that gives AI agents 38 tools to query and trade through Interactive Brokers, built on ib_async and FastMCP.
This project is designed and testedonly with IBKR PAPER accounts.
Six tools can place, modify or cancel real orders (place_order, place_bracket_order, place_combo_order, modify_order, cancel_order, cancel_all_open_orders).
Use at your own risk. Nothing here is financial advice, and the authors accept no liability for any losses.
Features
Orders (10)
place_order,place_bracket_order,place_combo_order— submit stock, option, bracket and combo ordersmodify_order,cancel_order,cancel_all_open_orders— change or cancel ordersprecheck_order— risk-only dry check (hours, notional, price distance, buying power, concentration)get_live_orders,get_order_status,get_executions— order and fill tracking
Account and data (16)
get_positions,get_account_summary,get_portfolio_snapshot,get_pnl_per_position,get_daily_pnl_history,classify_positions_by_strategyget_market_data,get_historical_bars,get_52w_context,get_option_chainget_fundamentals,get_earnings_date,get_dividend_calendar(via yfinance)get_exchange_hours,resolve_symbol,screen_universe
Options analytics (9)
get_market_data_with_greeks,bs_price,implied_volatility,greeks_from_priceprob_itm,expected_moveevaluate_multi_leg,pmcc_evaluator,roll_analyzer
Diagnostics (3)
healthcheck,get_recent_errors,get_server_info
Related MCP server: Open Paper Trading MCP
Safety by design
Live-price gate on
place_order: the order is blocked if no live price is available, or if a limit price deviates from the mid/last/close reference by more thanIBKR_ORDER_PRICE_TOLERANCE_PCT(default2.0%).precheck_orderrisk limits (configurable, evaluated when the tool is called):IBKR_MAX_ORDER_NOTIONAL— max order notional, default5000.0(blocker)IBKR_MAX_PRICE_DISTANCE_PCT— max limit-price distance from reference, default0.10(blocker)IBKR_MAX_CONCENTRATION_PCT— max post-trade position share of net liquidation, default0.20(warning)It also blocks when the exchange is closed or the order exceeds buying power.
Paper port by default: the server connects to
127.0.0.1:4002.
TheIBKR_MAX_* limits are enforced by precheck_order, not inside the order-placing tools. The agent (or your prompt/policy) must call precheck_order before placing orders.
Quick start
Requirements: Python 3.11+, and IB Gateway or TWS running in paper mode with the API enabled (default Gateway paper port 4002).
git clone https://github.com/ettore-pedemonti/ibkr-mcp-server.git
cd ibkr-mcp-server
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python server.py # speaks MCP over stdioExample MCP client configuration (e.g. Claude Desktop):
{
"mcpServers": {
"ibkr": {
"command": "/path/to/ibkr-mcp-server/.venv/bin/python",
"args": ["/path/to/ibkr-mcp-server/server.py"],
"env": {
"IB_HOST": "127.0.0.1",
"IB_PORT": "4002",
"IB_CLIENT_ID": "10"
}
}
}
}Configuration
All settings are environment variables.
Variable | Default | Description |
|
| IB Gateway / TWS host |
|
| API port (4002 = Gateway paper) |
|
| Client ID used by the server |
|
| Max order notional in |
|
| Max limit-price distance from reference (fraction) in |
|
| Concentration warning threshold (fraction of net liquidation) |
|
| Max limit-price deviation (in %) enforced by the |
|
| IB market data type (1 live, 2 frozen, 3 delayed, 4 delayed-frozen) |
Testing
test_all_tools.py is a read-only regression script: it calls the read-only tools and skips the order-mutating ones. It requires a running IB Gateway/TWS in paper mode.
TEST_IB_CLIENT_ID=99 python test_all_tools.pyTEST_IB_CLIENT_ID (default 99) sets the client ID used by the script, so it does not clash with a running server.
Roadmap
Enforce the
IBKR_MAX_*risk limits inside the order-placing tools, not only inprecheck_orderUnit tests with a mocked
ib_asyncGitHub Actions CI
rufflinting and type hints
License
This server cannot be deployed
Maintenance
Related MCP Connectors
Unified financial infrastructure connecting AI agents directly to trade live/demo brokerage accounts, Web3 non-custodial wallets, real-time market data across equities, ETFs, crypto, forex, options, DeFi swaps, and prediction markets, institutional research feeds, and algorithmic strategy backtesters.
Free crypto-futures paper trading and live market data for AI agents. 29 tools; no key for data.
Agentic brokerage access to a US brokerage account: quotes, orders, positions, cash and documents.
- FensoryOAuthcom.fensory
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables 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.1493 npm223MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI agents with tools for paper trading stocks, options, ETFs, and bonds, including advanced options strategies and risk analysis, using real market data without financial risk.16Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Interactive Brokers through 48 tools for market data, orders, account management, and more, via the MCP protocol.MIT
- AlicenseAqualityDmaintenanceEnables AI agents to trade on Interactive Brokers: check quotes, balance, positions, and execute buy/sell orders (including fractional shares by dollar amount) via the Client Portal API.2014MIT