loading…
Search for a command to run...
loading…
Connects Claude AI to Interactive Brokers accounts to enable real-time portfolio tracking, position management, and historical market data retrieval. It also in
Connects Claude AI to Interactive Brokers accounts to enable real-time portfolio tracking, position management, and historical market data retrieval. It also integrates financial news and sentiment analysis from multiple sources, including Finnhub and IB native feeds.
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.
Once set up, you can ask Claude things like:
All responses come directly from your Interactive Brokers account, IB news feeds (Reuters, Dow Jones, etc.), and optionally Finnhub API.
IB Gateway is a lightweight app that allows API access to your IBKR account.
4001Note: IBKR Desktop app does NOT support API connections. You need IB Gateway or TWS.
Finnhub provides additional news and social sentiment data. This is optional - IB native news works without it.
# 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:
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).
LunarCrush provides social sentiment data for cryptocurrencies. To add it alongside this server:
{
"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!
| Tool | Description |
|---|---|
get_comprehensive_news |
All-in-one news analysis - combines IB news, Finnhub news, social sentiment, insider sentiment, and AI-analyzed scores |
| 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 |
| 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 |
| 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 |
| Tool | Description |
|---|---|
search_news |
Search by symbol or keyword |
get_company_news |
Company-specific headlines |
get_market_news |
General market news |
get_social_sentiment |
Reddit/Twitter sentiment metrics |
get_insider_sentiment |
Insider trading signals |
| Tool | Description |
|---|---|
analyze_news_sentiment |
AI sentiment analysis on news |
analyze_text_sentiment |
Analyze any custom text |
| Tool | Description |
|---|---|
check_connection_status |
Check IB and API connections |
All settings are in the .env file:
# Interactive Brokers Connection
IB_HOST=127.0.0.1
IB_PORT=4001 # 4001=Gateway Paper, 4002=Gateway Live
# News API
FINNHUB_API_KEY=your_finnhub_key_here
# Sentiment Model
SENTIMENT_MODEL=vader # "vader" (fast) or "finbert" (accurate, 500MB model)
# Logging
LOG_LEVEL=INFO
| Port | Application | Mode |
|---|---|---|
| 4001 | IB Gateway | Paper Trading |
| 4002 | IB Gateway | Live Trading |
| 7497 | TWS | Paper Trading |
| 7496 | TWS | Live Trading |
This server is READ-ONLY by default:
.env (never committed to git)Your credentials never leave your machine. The MCP server runs locally and communicates only with:
.env.envwhich python3 in terminalcd ib-mcp-server
source .venv/bin/activate
python -c "
from ib_async import IB
import asyncio
async def test():
ib = IB()
await ib.connectAsync('127.0.0.1', 4001, clientId=99)
print('Connected!')
print('Accounts:', ib.managedAccounts())
ib.disconnect()
asyncio.run(test())
"
ib-mcp-server/
├── setup.sh # Mac/Linux setup script
├── setup.bat # Windows setup script
├── pyproject.toml # Python dependencies
├── .env.example # Configuration template
├── .env # Your configuration (gitignored)
├── README.md # This file
├── claude.md # Claude Code documentation
└── src/ib_mcp/
├── server.py # MCP server entry point
├── config.py # Configuration management
└── clients/
├── ib_client.py # Interactive Brokers API
├── news_client.py # Finnhub API
└── sentiment.py # Sentiment analysis
MIT License - feel free to use, modify, and share.
This software is for informational purposes only. It does not constitute financial advice. Always verify information independently before making investment decisions. The authors are not responsible for any financial losses incurred through the use of this software.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"ib-portfolio-tracker-mcp-server": {
"command": "npx",
"args": []
}
}
}