IBKR MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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: mcp-ibkr-agent
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
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
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.
Paper trading for AI agents: 45 stock markets, virtual money, real broker fees, live or replayed.
Guardrails for trading agents. Built-in risk management, 100+ tools for strategy R&D, 12+ venues.
Free crypto-futures paper trading and live market data for AI agents. 31 tools; no key for data.
Related MCP Servers
- 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
- AlicenseAqualityCmaintenanceEnables 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.2015MIT
- AlicenseAqualityCmaintenanceEnables LLM agents to interact with Interactive Brokers accounts for market data, account info, and order entry with built-in risk controls and a two-step confirmation flow.9MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to connect to local brokerage interfaces (TWS, IB Gateway, and Client Portal Web API), automatically detecting whichever is running. Provides tools for account and portfolio data, market quotes and historical bars, contract and option-chain lookup, and staging or canceling orders.MIT