
MCP server connecting Claude to Interactive Brokers TWS — portfolio, market data & order management via natural language
概览
MCP (Model Context Protocol) server that connects Claude to Interactive Brokers TWS via ib_insync. Use natural language to check your portfolio, pull market data, and place orders — all from Claude Desktop, Claude Code, or any MCP-compatible client. The installer will: 1. Find or install Python 3.10+ 2. Create a virtual environment and install dependencies 3. Let you choose Paper or Live trading port 4. Configure Claude Desktop automatically 5. Configure Claude Code (CLI) if installed 1. ib_prepare_order — validates the contract, builds the order, and returns a 2. Claude shows the order details to you and waits for explicit approval 3. ib_submit_order — submits the order only after confirmation (token expires in 5 minutes) - Python 3.10+ - TWS or IB Gateway running and logged in - TWS API enabled (Edit → Global Configuration → API → Settings) Edit ~/Library/Application Support/Claude/claude_desktop_config.
README
以下为原文 README 节选,完整内容请查看原文。
claude-tws-connect
MCP (Model Context Protocol) server that connects Claude to Interactive Brokers TWS via ib_insync. Use natural language to check your portfolio, pull market data, and place orders — all from Claude Desktop, Claude Code, or any MCP-compatible client.
Quick Start
macOS:
git clone https://github.com/danielkristofik/mcp_claude_ibkr.git
cd mcp_claude_ibkr
./install.sh
Linux (Ubuntu/Debian):
git clone https://github.com/danielkristofik/mcp_claude_ibkr.git
cd mcp_claude_ibkr
./install-linux.sh
The installer will:
- Find or install Python 3.10+
- Create a virtual environment and install dependencies
- Let you choose Paper or Live trading port
- Configure Claude Desktop automatically
- Configure Claude Code (CLI) if installed
Features
| Tool | Description | Read-only |
|---|---|---|
ib_account_summary |
Account overview — liquidation value, cash, margin, buying power | Yes |
ib_positions |
Portfolio positions with market value and P&L | Yes |
ib_pnl |
Daily P&L — realized and unrealized | Yes |
ib_fundamental_data |
Fundamentals — P/E, EPS, market cap, dividends, 52-week range | Yes |
ib_margin_impact |
Margin impact estimate for a hypothetical order (what-if) | Yes |
ib_market_data |
Real-time snapshot (bid/ask/last/volume) + Greeks for options | Yes |
ib_historical_data |
Historical OHLCV bars | Yes |
ib_scanner |
Market scanner (top gainers, losers, most active, etc.) | Yes |
ib_contract_details |
Contract details | Yes |
ib_option_chains |
Option expirations and strikes | Yes |
ib_open_orders |
Active orders | Yes |
ib_executions |
Today’s executions / fills | Yes |
ib_prepare_order |
Prepare an order for review (step 1/2) | Yes |
ib_submit_order |
Submit a confirmed order (step 2/2) | No |
ib_cancel_order |
Cancel an active order | No |
Order Safety
Orders use a two-step confirmation flow:
ib_prepare_order— validates the contract, builds the order, and returns a confirmation token- Claude shows the order details to you and waits for explicit approval
ib_submit_order— submits the order only after confirmation (token expires in 5 minutes)
Manual Installation
Prerequisites
- Python 3.10+
- TWS or IB Gateway running and logged in
- TWS API enabled (Edit → Global Configuration → API → Settings)
Setup
git clone https://github.com/danielkristofik/mcp_claude_ibkr.git
cd mcp_claude_ibkr
# Create virtual environment
python3 -m venv venv
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"ibkr": {
"command": "/FULL/PATH/TO/claude-tws-connect/venv/bin/python",
"args": ["/FULL/PATH/TO/claude-tws-connect/ibkr_mcp.py"]
}
}
}