MCP server for Interactive Brokers — read positions, orders, P&L, and trade via the IBKR Client Portal API.
Built for use with Claude Code, Claude Desktop, and any MCP-compatible client.
- Account: Net liquidation, buying power, cash balance, excess liquidity
- Positions: Open positions with real-time P&L, market value, average cost
- Orders: View all orders (open, filled, cancelled)
- Market Data: Real-time quotes, contract search
- Order Placement: Market, limit, stop, and stop-limit orders (disabled by default)
- An Interactive Brokers account (Pro or Lite)
- Client Portal Gateway running locally
- Node.js 18+
Download the gateway from IBKR, then:
cd clientportal-gw
bin/run.sh root/conf.yamlLog in at https://localhost:5000 in your browser. The gateway session stays alive as long as the server keeps sending heartbeats (handled automatically by this MCP server).
git clone https://github.com/YOUR_USERNAME/ibkr-mcp.git
cd ibkr-mcp
npm install
npm run buildCopy .env.example to .env and fill in your account ID:
cp .env.example .env| Variable | Description | Default |
|---|---|---|
IBKR_GATEWAY_URL |
Client Portal Gateway URL | https://localhost:5000 |
IBKR_ACCOUNT_ID |
Your IBKR account ID | (required) |
IBKR_ALLOW_ORDERS |
Enable order placement | false |
IBKR_PAPER |
Paper trading mode | true |
Add to ~/.claude/mcp.json:
{
"mcpServers": {
"ibkr": {
"command": "node",
"args": ["/path/to/ibkr-mcp/dist/index.js"],
"env": {
"IBKR_ACCOUNT_ID": "YOUR_ACCOUNT_ID",
"IBKR_PAPER": "true",
"NODE_TLS_REJECT_UNAUTHORIZED": "0"
}
}
}
}| Tool | Description |
|---|---|
account_summary |
Account balances, buying power, net liquidation |
auth_status |
Check gateway authentication status |
reauthenticate |
Trigger gateway reauthentication |
get_positions |
All open positions with P&L |
get_orders |
All orders in current session |
search_contract |
Search for a contract by symbol |
get_quote |
Real-time market quote by contract ID |
place_order |
Place an order (requires IBKR_ALLOW_ORDERS=true) |
Order placement is disabled by default. You must explicitly set IBKR_ALLOW_ORDERS=true to enable it. This is intentional — start with read-only access on a paper account before enabling trading.
The IBKR_PAPER=true default connects to the paper trading port. Switch to false only when you're ready for live trading.
MIT