
Model Context Protocol (MCP) server exposing Interactive Brokers data via ib_async + FastMCP
概览
Lightweight Model Context Protocol (MCP) server exposing read-only Interactive Brokers data (contracts, historical data, fundamentals, news, portfolio, account) via the asynchronous ib_async library and FastMCP. Ideal for feeding financial data into LLM workflows and autonomous agents while keeping trading disabled. This directory contains an MCP (Model Context Protocol) server that wraps the ib_async library to allow LLMs to interact with Interactive Brokers data. The MCP server provides the following tools for LLM interaction: - : Look up contract details by ticker symbol and optional exchange/currency - : Convert ticker symbol to contract ID (conid) - : Retrieve historical market data with configurable duration, bar size, and data type - : List option-chain parameters (expirations and strikes) for an underlying, with strike-range filtering and pagination - : Batch bid/ask/last/close and model IV/delta for a list of option strikes; defaults to delayed-frozen data (no OPRA...
README
以下为原文 README 节选,完整内容请查看原文。
IB Async MCP Server
Lightweight Model Context Protocol (MCP) server exposing read-only Interactive Brokers data (contracts, historical data, fundamentals, news, portfolio, account) via the asynchronous ib_async library and FastMCP. Ideal for feeding financial data into LLM workflows and autonomous agents while keeping trading disabled.
Overview
This directory contains an MCP (Model Context Protocol) server that wraps the ib_async library to allow LLMs to interact with Interactive Brokers data.
Features
The MCP server provides the following tools for LLM interaction:
1. Contract Lookup and Conversion
- lookup_contract: Look up contract details by ticker symbol and optional exchange/currency
- ticker_to_conid: Convert ticker symbol to contract ID (conid)
2. Market Data
- get_historical_data: Retrieve historical market data with configurable duration, bar size, and data type
3. Options
- get_option_chain: List option-chain parameters (expirations and strikes) for an underlying, with strike-range filtering and pagination
- get_option_quotes: Batch bid/ask/last/close and model IV/delta for a list of option strikes; defaults to delayed-frozen data (no OPRA subscription required)
- get_index_quote: Spot quote (last/close/bid/ask) for an index, useful for strike-from-spot calculations
4. News
- get_news: Retrieve current news articles for a contract
- get_historical_news: Retrieve historical news articles within a date range
5. Fundamental Data
- get_fundamental_data: Retrieve fundamental data including financial summaries, ownership, financial statements, and more
6. Portfolio and Account Information
- get_portfolio: Retrieve portfolio positions and details
- get_account_summary: Retrieve account summary information
- get_positions: Retrieve current positions with contract metadata, including option expiry/strike/right/multiplier fields
Prerequisites
-
Interactive Brokers Account: You need an active IB account
-
IB Gateway or TWS: Download and install either:
- IB Gateway (Stable) - Recommended for API-only use
- IB Gateway (Latest) - Latest features
- Trader Workstation (TWS) - Full trading platform
-
API Configuration:
- Enable API access in TWS/Gateway:
Configure → API → Settingsand check “Enable ActiveX and Socket Clients” - Set appropriate port (default: 7497 for TWS, 4001 for Gateway)
- Add
127.0.0.1to trusted IPs if connecting locally
- Enable API access in TWS/Gateway:
Installation
From source (development)
安装
docker run --rm --add-host host.docker.internal:host-gateway -e IB_HOST=host.docker.internal -e IB_PORT=7497 -e IB_CLIENT_ID=1 ghcr.io/hellek1/ib-mcp:latest配置
{
"mcpServers": {
"ib-async": {
"command": "docker",
"args": [
"run",
"--rm",
"--add-host","host.docker.internal:host-gateway",
"-e","IB_HOST=host.docker.internal",
"-e","IB_PORT=7497",
"-e","IB_CLIENT_ID=1",
"ghcr.io/hellek1/ib-mcp:latest"
]
}
}
}