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-server Show me my current portfolio"
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
A professional Model Context Protocol (MCP) server for Interactive Brokers API integration, designed for use with Claude Desktop and Claude Code.
Features
✅ Multi-Account Support - Switch between multiple IBKR accounts
✅ Short Selling Analysis - Shortable shares, borrow rates, margin requirements
✅ Real-time Market Data - Live quotes, historical data, options chains
✅ Portfolio Management - Positions, P&L, account summaries
✅ Trading Operations - Place, modify, cancel orders (with safety checks)
✅ Auto-Reconnection - Handles TWS/Gateway restarts gracefully
✅ Production Ready - Proper error handling, logging, and monitoring
Related MCP server: IBKR-MCP-Server
Quick Start
Prerequisites
Python 3.10 or higher
Interactive Brokers account with TWS or IB Gateway
Claude Desktop or Claude Code
Installation
Clone the repository:
git clone https://github.com/yourusername/ibkr-mcp-server.git cd ibkr-mcp-serverRun the setup script:
# macOS/Linux chmod +x scripts/setup.sh ./scripts/setup.sh # Windows scripts\setup.batConfigure your settings:
cp .env.example .env # Edit .env with your IBKR settingsStart TWS/IB Gateway and enable API connections
Test the server:
python -m ibkr_mcp_server.main --test
Claude Integration
Claude Desktop:
Add to your claude_desktop_config.json:
{
"mcpServers": {
"ibkr": {
"command": "python",
"args": ["-m", "ibkr_mcp_server.main"],
"cwd": "/path/to/ibkr-mcp-server"
}
}
}Claude Code:
claude mcp add ibkr 'python -m ibkr_mcp_server.main' --cwd /path/to/ibkr-mcp-serverUsage Examples
Basic Operations
# Get portfolio across all accounts
"Show me my current portfolio"
# Switch accounts
"Switch to account DU7654321"
# Market data
"Get real-time quotes for AAPL, TSLA, MSFT"Short Selling Analysis
# Complete short selling analysis
"Analyze short selling for GME, AMC, BBBY - show availability, borrow costs, and margin requirements"
# Check specific account
"Check shortable shares for TSLA in my paper trading account"Trading Operations
# Place orders (paper trading recommended)
"Place a limit order to buy 100 shares of AAPL at $150"
# Check margin requirements
"What are the margin requirements for shorting 200 shares of TSLA?"Available Tools
Tool | Description |
| Current portfolio positions and P&L |
| Account balances and key metrics |
| Switch between IBKR accounts |
| Short selling availability |
| Margin requirements for securities |
| Stock borrow rates (short selling costs) |
| Complete short selling analysis |
| Real-time market quotes |
| Historical price data |
| Place trading orders (with safety checks) |
| Check IBKR connection status |
Configuration
Environment Variables
# IBKR Connection
IBKR_HOST=127.0.0.1
IBKR_PORT=7497 # 7497=TWS Paper, 7496=TWS Live, 4001=Gateway
IBKR_CLIENT_ID=1
IBKR_IS_PAPER=true
# Logging
LOG_LEVEL=INFO
# Safety
ENABLE_LIVE_TRADING=false # Set to true for live trading
MAX_ORDER_SIZE=1000 # Maximum order sizeTWS/Gateway Setup
Start TWS or IB Gateway
Go to Configuration → API → Settings
Enable "ActiveX and Socket Clients"
Set socket port (7497 for paper, 7496 for live)
Add 127.0.0.1 to "Trusted IPs"
Check "Download open orders on connection"
Development
Setup Development Environment
pip install -e ".[dev]"
pre-commit installRunning Tests
pytest tests/ -vCode Quality
black ibkr_mcp_server/
isort ibkr_mcp_server/
mypy ibkr_mcp_server/Deployment
Auto-start on Boot (macOS)
python scripts/install_service.py --platform macosAuto-start on Boot (Linux)
python scripts/install_service.py --platform linuxDocker Deployment
docker build -t ibkr-mcp-server .
docker run -d --name ibkr-mcp -p 8080:8080 ibkr-mcp-serverDocumentation
Safety & Disclaimers
⚠️ Important Safety Notes:
Always test with paper trading first
Verify all data in TWS before making trading decisions
This software is for educational purposes
Use at your own risk
No warranty provided
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests
Submit a pull request
License
MIT License - see LICENSE file for details.
Support
Available Tools
8 toolsget_accountsB
Get available IBKR accounts and current account
Inputs: no named parameters.
get_account_summaryB
Get account balances and key metrics from IBKR
Inputs: account.
get_connection_statusB
Check IBKR TWS/Gateway connection status and account information
Inputs: no named parameters.
get_margin_requirementsC
Get margin requirements for securities
Inputs: symbols (required), account.
get_portfolioC
Retrieve current portfolio positions and P&L from IBKR
Inputs: account.
short_selling_analysisA
Complete short selling analysis: availability, margin requirements, and summary
Inputs: symbols (required), account.
switch_accountB
Switch between IBKR accounts
Inputs: account_id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose: check_shortable_shares vs short_selling_analysis are differentiated by scope (single check vs comprehensive analysis); get_accounts vs get_account_summary vs get_portfolio cover different account aspects; get_connection_status and switch_account are unique. No significant overlap.
Tools follow a consistent snake_case naming pattern with verb_noun structure (e.g., get_account_summary, get_portfolio). One exception is short_selling_analysis which is noun_verb but still readable and fits the pattern.
8 tools is appropriate for the domain of financial account information and short selling analysis. Not excessive, and each tool contributes a distinct function without unnecessary duplication.
The server covers account information, portfolio, margin, and short selling analysis, but lacks essential trading operations like order placement, modification, or market data retrieval. The surface is focused on analysis and account management, leaving a notable gap for execution.
Maintenance
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
Hosted MCP server for MT4 and MT5: read accounts, prices and candles, and place or close orders.
Related MCP Servers
- AlicenseBqualityDmaintenanceMCP server for Interactive Brokers API, enabling account management, trading, market data, options, scanners, and news via natural language.333MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for Interactive Brokers TWS API that enables AI assistants to retrieve portfolio, account information, and real-time market prices.23Apache 2.0
- AlicenseNot gradedqualityDmaintenanceAn MCP server for Interactive Brokers, enabling account management, trading operations, and market data queries.8MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for Interactive Brokers that exposes portfolio data, market quotes, trading, and analysis to any MCP-compatible AI client, with support for EU investors and safety-gated trading.1MIT