Interactive Brokers MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
pip install interactive-brokers-mcp
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add ibkr-mcp -- node "<FULL_PATH_TO_IBKR_MCP>/dist/index.js"

Replace <FULL_PATH_TO_IBKR_MCP>/dist/index.js with the actual folder you prepared in step 1.

README.md

MCP server for Interactive Brokers Gateway for market data and account access

ibkr-mcp

MCP server for Interactive Brokers Gateway — 6 tools for market data and account access via Claude.

Tools

Tool Description
get_ibkr_market_data Historical OHLCV bars for any contract
get_ibkr_positions Current portfolio positions and P&L
get_ibkr_account Account summary (balances, margin, NAV)
get_ibkr_contract Contract lookup and details
get_ibkr_option_prices Option chain pricing
get_ibkr_snapshot Real-time quote snapshot

Install

pip install interactive-brokers-mcp

Prerequisites

  • IB Gateway or TWS running
  • API access enabled in Gateway/TWS settings
  • Host/port/client ID matching your environment variables

Environment Variables

Variable Default Description
IBKR_GATEWAY_HOST 127.0.0.1 Gateway hostname
IBKR_GATEWAY_PORT 7496 Gateway port
IBKR_CLIENT_ID 1 API client ID
IBKR_TIMEOUT 10 Connection timeout (seconds)
IBKR_READONLY false Read-only mode
IBKR_AUTHORIZED_ACCOUNTS Comma-separated account whitelist
IBKR_CACHE_DIR Optional cache directory override

The package auto-loads .env from the package directory and parent.

Usage

Claude Code

claude mcp add ibkr-mcp -- ibkr-mcp

Or in ~/.claude.json:

{
  "mcpServers": {
    "ibkr-mcp": {
      "type": "stdio",
      "command": "ibkr-mcp"
    }
  }
}

Standalone

ibkr-mcp          # via installed entry point
python -m ibkr.server   # via module

License

MIT

Tools (6)

get_ibkr_market_dataRetrieves historical OHLCV bars for any contract.
get_ibkr_positionsRetrieves current portfolio positions and P&L.
get_ibkr_accountRetrieves account summary including balances, margin, and NAV.
get_ibkr_contractPerforms contract lookup and returns details.
get_ibkr_option_pricesRetrieves option chain pricing.
get_ibkr_snapshotRetrieves a real-time quote snapshot for a contract.

Environment Variables

IBKR_GATEWAY_HOSTGateway hostname
IBKR_GATEWAY_PORTGateway port
IBKR_CLIENT_IDAPI client ID
IBKR_TIMEOUTConnection timeout in seconds
IBKR_READONLYRead-only mode
IBKR_AUTHORIZED_ACCOUNTSComma-separated account whitelist
IBKR_CACHE_DIROptional cache directory override

Configuration

claude_desktop_config.json
{"mcpServers": {"ibkr-mcp": {"type": "stdio", "command": "ibkr-mcp"}}}

Try it

What is my current portfolio balance and total P&L?
Get the historical OHLCV data for AAPL for the last 30 days.
Look up the contract details for TSLA.
Show me the current real-time quote for SPY.
What are the current option prices for NVDA expiring next month?

Frequently Asked Questions

What are the key features of Interactive Brokers MCP Server?

Access real-time market data and snapshots. Retrieve historical OHLCV bars for technical analysis. View account summaries including margin and NAV. Query portfolio positions and P&L data. Perform contract lookups and option chain pricing.

What can I use Interactive Brokers MCP Server for?

Automating portfolio performance reporting for traders. Integrating market data analysis directly into AI-assisted research workflows. Quickly checking account margin and balances during trading sessions. Retrieving historical price data for custom strategy backtesting.

How do I install Interactive Brokers MCP Server?

Install Interactive Brokers MCP Server by running: pip install interactive-brokers-mcp

What MCP clients work with Interactive Brokers MCP Server?

Interactive Brokers MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Interactive Brokers MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare