Connects Claude AI to your Interactive Brokers account for real-time tracking
IB Portfolio Tracker - MCP Server
An MCP (Model Context Protocol) server that connects Claude AI to your Interactive Brokers account for real-time portfolio tracking, financial news, and sentiment analysis.
What Can You Do?
Once set up, you can ask Claude things like:
- "What's my portfolio value?"
- "Show my positions with P&L"
- "Give me a full news analysis for NVDA" (combines IB + Finnhub + sentiment)
- "What's the sentiment around Tesla?"
- "Show historical data for SPY"
- "What news providers are available from IB?"
All responses come directly from your Interactive Brokers account, IB news feeds (Reuters, Dow Jones, etc.), and optionally Finnhub API.
Quick Start
Prerequisites
- macOS, Linux, or Windows
- Python 3.10+ installed
- Interactive Brokers account
- Claude Desktop or Claude Code (VS Code)
Step 1: Download IB Gateway
IB Gateway is a lightweight app that allows API access to your IBKR account.
- Download from: https://www.interactivebrokers.com/en/trading/ibgateway-stable.php
- Install and log in with your IBKR credentials
- Configure API settings:
- Go to Configure → Settings → API → Settings
- Set Socket port to
4001 - Check Read-Only API (recommended for safety)
- Keep IB Gateway running whenever you want to use the portfolio features
Note: IBKR Desktop app does NOT support API connections. You need IB Gateway or TWS.
Step 2: Get a Finnhub API Key (Optional)
Finnhub provides additional news and social sentiment data. This is optional - IB native news works without it.
- Sign up at: https://finnhub.io/register
- Copy your API key from the dashboard
- Free tier: 60 requests/minute (plenty for personal use)
Step 3: Install the MCP Server
# Clone or download this repository
git clone https://github.com/vinbg/ib-mcp-server.git
cd ib-mcp-server
# Run the setup script
# Mac/Linux:
chmod +x setup.sh
./setup.sh
# Windows:
setup.bat
The setup script will:
- Create a Python virtual environment
- Install all dependencies
- Guide you through configuration
- Test your connections
Step 4: Configure Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"ib-portfolio": {
"command": "/FULL/PATH/TO/ib-mcp-server/.venv/bin/python",
"args": ["-m", "ib_mcp.server"],
"cwd": "/FULL/PATH/TO/ib-mcp-server"
}
}
}
Replace /FULL/PATH/TO/ with your actual path!
Then restart Claude Desktop (Cmd+Q, then reopen).
Optional: Add LunarCrush for Crypto Sentiment
LunarCrush provides social sentiment data for cryptocurrencies. To add it alongside this server:
- Get an API key at: https://lunarcrush.com/developers
- Add to your Claude Desktop config:
{
"mcpServers": {
"ib-portfolio": {
"command": "/FULL/PATH/TO/ib-mcp-server/.venv/bin/python",
"args": ["-m", "ib_mcp.server"],
"cwd": "/FULL/PATH/TO/ib-mcp-server"
},
"LunarCrush": {
"type": "http",
"url": "https://lunarcrush.ai/mcp",
"headers": {
"Authorization": "Bearer YOUR_LUNARCRUSH_API_KEY"
}
}
}
}
Now you can ask Claude about crypto social sentiment alongside your IBKR portfolio!
Available Tools (22 total)
Comprehensive News (RECOMMENDED)
| Tool | Description |
|---|---|
get_comprehensive_news |
All-in-one news analysis - combines IB news, Finnhub news, social sentiment, insider sentiment, and AI-analyzed scores |
Portfolio Tools (requires IB Gateway)
| Tool | Description |
|---|---|
get_account_summary |
Net liquidation value, buying power, cash, margin |
get_positions |
All positions with quantities, cost basis, P&L |
get_portfolio_pnl |
Daily, unrealized, and realized P&L breakdown |
get_position_details |
Detailed info for a specific symbol |
get_open_orders |
List pending orders |
get_executions |
Recent trade fills |
Market Data Tools (requires IB Gateway)
| Tool | Description |
|---|---|
get_quote |
Real-time/delayed quotes (bid, ask, last, volume) |
get_historical_data |
OHLCV historical bars |
get_contract_details |
Symbol info, trading hours |
search_symbols |
Find contracts by name |
IB Native News Tools (requires IB Gateway)
| Tool | Description |
|---|---|
get_ib_news_providers |
List available news sources (Reuters, Dow Jones, etc.) |
get_ib_news |
Get historical news from IB for a symbol |
get_ib_news_article |
Get full article text by article ID |
Finnhub News & Sentiment Tools (requires Finnhub API)
| Tool | Description |
|---|---|
search_news |
Search by symbol or keyword |
get_company_news |
Company-specific headlines |
get_market_news |
General market |
Tools (17)
get_comprehensive_newsCombines IB news, Finnhub news, social sentiment, insider sentiment, and AI-analyzed scores.get_account_summaryRetrieves net liquidation value, buying power, cash, and margin.get_positionsLists all positions with quantities, cost basis, and P&L.get_portfolio_pnlProvides daily, unrealized, and realized P&L breakdown.get_position_detailsProvides detailed info for a specific symbol.get_open_ordersLists pending orders.get_executionsRetrieves recent trade fills.get_quoteRetrieves real-time or delayed quotes including bid, ask, last, and volume.get_historical_dataRetrieves OHLCV historical bars.get_contract_detailsRetrieves symbol info and trading hours.search_symbolsFinds contracts by name.get_ib_news_providersLists available news sources like Reuters and Dow Jones.get_ib_newsGets historical news from IB for a specific symbol.get_ib_news_articleGets full article text by article ID.search_newsSearches news by symbol or keyword.get_company_newsRetrieves company-specific headlines.get_market_newsRetrieves general market news.Environment Variables
FINNHUB_API_KEYOptional API key for additional news and social sentiment data.Configuration
{"mcpServers": {"ib-portfolio": {"command": "/FULL/PATH/TO/ib-mcp-server/.venv/bin/python", "args": ["-m", "ib_mcp.server"], "cwd": "/FULL/PATH/TO/ib-mcp-server"}}}