IBKR-MCP
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 โ Model Context Protocol Server for Interactive Brokers
An institutional-grade Model Context Protocol (MCP) server connecting Claude Desktop, Cursor IDE, Antigravity, and autonomous AI agents directly to Interactive Brokers (TWS & IB Gateway). Query account balances, stream real-time quotes, inspect 0DTE options chains, preview margin requirements, and execute paper trades with strict Human-in-the-Loop safety guardrails.
๐ผ Need Custom Quantitative Systems, Trading Bots, or Broker Integrations?
I engineer high-performance algorithmic execution engines, institutional broker APIs, and AI quantitative assistants for funds, prop traders, and private desks.
๐ฌ Telegram: @JanzebBlockdev
๐ผ Fiverr Profile: Verified Quantitative Developer (Fiverr)
๐ง Email:
jahanzaibchanna70@gmail.com
๐๏ธ System Architecture
flowchart LR
subgraph AI_Clients["๐ค AI Clients & LLMs"]
Claude["Claude Desktop"]
Cursor["Cursor IDE"]
Agents["Autonomous Quant Agents"]
end
subgraph MCP_Server["๐ IBKR-MCP Server"]
Router["MCP Protocol Engine\n(Tools โข Resources โข Prompts)"]
Guard["Safety Guardrails\n(Read-Only โข Token Auth โข Risk Ceiling)"]
Fallback["Simulation Engine\n(Zero-Downtime Offline Mode)"]
end
subgraph IBKR_System["๐๏ธ Interactive Brokers"]
TWS["TWS / IB Gateway\n(Socket Port 7497 / 7496)"]
Exchanges["CME โข NYSE โข NASDAQ โข CBOE"]
end
Claude <-->|"MCP JSON-RPC / stdio"| Router
Cursor <-->|"MCP JSON-RPC / stdio"| Router
Agents <-->|"MCP Transport / SSE"| Router
Router --> Guard
Guard -->|"Authorized Actions"| TWS
Guard -.->|"Offline Fallback"| Fallback
TWS <--> ExchangesRelated MCP server: Interactive Brokers MCP Server
โก Core Capabilities
๐ก๏ธ Institutional Safety Guardrails (Human-in-the-Loop)
Read-Only by Default: Read operations (
get_account_summary,get_market_quote) are always accessible; order placement requires explicit opt-in.No Unintended Live Orders: Hard prohibition on live account execution unless
ALLOW_LIVE_TRADING=true.Explicit Confirmation Token: Orders require
confirm=Trueflag to prevent hallucinated trades.Max Capital Ceilings: Orders exceeding
MAX_ORDER_VALUE_USDare automatically intercepted.
๐ Real-Time Account & Portfolio Intelligence
Instant lookup of Net Liquidation Value, Total Cash, Available Funds, and Buying Power.
Full position tracking across Equities, Options, and Futures with real-time unrealized PnL.
๐ Multi-Asset Quotes & Level 1 Market Data
Real-time Bid, Ask, Last, Volume, High, Low, and VWAP for US Equities, ETFs, and Index Futures (
ES,NQ,MES).
๐งฎ Options Chain & Greeks Analytics
ATM Implied Volatility (IV), IV Rank, Delta, Gamma, Theta, Vega, and Open Interest.
๐ Pre-Flight Order Preview
Calculates notional value, margin requirement, and estimated commissions before submitting any order.
๐งช Seamless Simulation Fallback
Test prompts and tool-calling flows out-of-the-box even on weekends or when TWS is closed.
๐ ๏ธ Interactive Brokers TWS API Setup
To connect IBKR-MCP to your Trader Workstation (TWS) or IB Gateway, configure these settings:
Required Settings in TWS:
Open TWS Global Configuration
->API->Settings.Check Enable ActiveX and Socket Clients.
Uncheck
Read-Only API(if you wish to allow paper order execution).Set Socket port:
7497for TWS Paper Trading (Recommended)7496for TWS Live Trading4002for IB Gateway Paper Trading4001for IB Gateway Live Trading
Verify Allow connections from localhost only is checked, or add
127.0.0.1to Trusted IPs:
๐ Quickstart
1. Installation
git clone https://github.com/jahanzaib-codes/IBKR-MCP.git
cd IBKR-MCP
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/macOS
source .venv/bin/activate
pip install -r requirements.txt2. Configure Environment
Copy the example configuration:
cp .env.example .envEdit .env:
IBKR_HOST=127.0.0.1
IBKR_PORT=7497 # 7497 = TWS Paper
IBKR_CLIENT_ID=42
IBKR_READ_ONLY=true # Set false to enable paper executions
MAX_ORDER_VALUE_USD=10000.0 # Risk ceiling
ALLOW_LIVE_TRADING=false # Enforce paper trading only๐ค Client Integrations
1. Claude Desktop Configuration
Add the server to your claude_desktop_config.json:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"ibkr": {
"command": "python",
"args": [
"c:/Users/Jahanzaib/Desktop/Tauric Reserch/IBKR-MCP/server.py"
],
"env": {
"IBKR_HOST": "127.0.0.1",
"IBKR_PORT": "7497",
"IBKR_READ_ONLY": "true"
}
}
}
}2. Cursor IDE Integration
In Cursor, go to Settings -> Features -> MCP:
Click + Add New MCP Server.
Name:
ibkrType:
commandCommand:
python <ABSOLUTE_PATH_TO_IBKR-MCP>/server.py
๐งฐ MCP Tool Specifications
Tool Name | Parameters | Description |
|
| Verifies TWS socket connection, latency, port status (7497), and safety guardrails. |
|
| Retrieves Net Liquidation, Cash, Buying Power, Realized/Unrealized PnL. |
|
| Returns all open Equities, Options, and Futures positions with average cost. |
|
| Fetches real-time Bid, Ask, Last, Volume, and VWAP. |
|
| Retrieves IV Rank, ATM IV, Delta, Gamma, Theta, and Vega. |
|
| Pre-calculates margin impact, commissions, and risk checks before order submission. |
|
| Submits paper order with safety verification ( |
|
| Cancels active order with confirmation. |
|
| Lists all working, submitted, and partially filled orders. |
๐ MCP Resources & Prompts
Resources
ibkr://account/summaryโ Real-time stream of account equity.ibkr://portfolio/positionsโ Active portfolio holdings.ibkr://system/diagnosticsโ TWS socket connectivity metrics.
Prompts
portfolio_risk_reviewโ Directs the LLM to analyze portfolio concentration, margin cushion, and sector risk.trade_idea_evaluationโ Guides the LLM to inspect market quotes, evaluate options Greeks, and run pre-flight previews.premarket_briefingโ Daily morning briefing summarizing futures levels and overnight risk.
๐ฌ Example Agent Conversations
User: "What's my buying power in Interactive Brokers and do I have any open SPY positions?"
Claude: [Calls get_account_summary & list_portfolio_positions]
"Your current Net Liquidation Value is $125,480.50 with $250,961.00 in Buying Power.
You currently hold 100 shares of SPY at an average cost of $585.20 (Unrealized PnL: +$720.00)."
User: "Preview buying 10 shares of NVDA at market price."
Claude: [Calls preview_order(symbol="NVDA", action="BUY", quantity=10)]
"Trade Preview:
โข Notional Value: $1,442.00
โข Estimated Commission: $1.00
โข Initial Margin Requirement: $360.50
โข Risk Status: APPROVED (Under $10,000 threshold)
Would you like me to submit this paper order? Please confirm."๐ License
Distributed under the MIT License. See LICENSE for details.
๐ Maintained by Jahanzaib
GitHub: @jahanzaib-codes
Telegram: @JanzebBlockdev
Email:
jahanzaibchanna70@gmail.com
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
Connect brokerage accounts to AI assistants: holdings, orders, asset lookup, and approved trading.
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.
Agentic brokerage access to a US brokerage account: quotes, orders, positions, cash and documents.
Personal finance, bank account, and shared memory connector for Claude, ChatGPT, Gemini Spark & more
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.14138 npm228MIT
- FlicenseNot gradedqualityDmaintenanceConnects AI assistants to Interactive Brokers for intelligent portfolio management, options analysis, risk monitoring, and automated trading strategy suggestions. Enables real-time account tracking, Greeks calculations, option chain analysis, and playbook-based risk adjustments through natural language.5-
- FlicenseNot gradedqualityCmaintenanceConnects Claude AI to Interactive Brokers accounts to enable real-time portfolio tracking, position management, and historical market data retrieval. It also integrates financial news and sentiment analysis from multiple sources, including Finnhub and IB native feeds.-
- AlicenseNot gradedqualityDmaintenanceConnects your TastyTrade trading account to AI assistants like Claude Desktop and ChatGPT for conversational trading and portfolio management.5MIT