Lightweight Model Context Protocol (MCP) server exposing read-only Interactive Brokers data (contracts, historical data, fundamentals, news, portfolio, account) via the asynchronous ibasync 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 ibasy
Add this skill
npx mdskills install Hellek1/ib-mcp@Hellek1? Sign in with GitHub to claim this listing.Comprehensive read-only IB data access with excellent documentation and deployment flexibility
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:
Interactive Brokers Account: You need an active IB account
IB Gateway or TWS: Download and install either:
API Configuration:
Configure → API → Settings and check "Enable ActiveX and Socket Clients"127.0.0.1 to trusted IPs if connecting locallygit clone https://github.com/Hellek1/ib-mcp.git
cd ib-mcp
pip install poetry
poetry install
The default mode runs as a spawnable MCP server communicating via standard input/output. This is ideal for integration with MCP clients like Claude Desktop.
# Using default settings (TWS on localhost:7497)
poetry run ib-mcp-server
# Custom IB Gateway connection
poetry run ib-mcp-server --host 127.0.0.1 --port 4001 --client-id 1
# Help with all options
poetry run ib-mcp-server --help
HTTP mode runs a persistent server that listens on a host and port, enabling multi-client access and network connectivity.
# Local HTTP server
poetry run ib-mcp-server --transport http --http-host 127.0.0.1 --http-port 8000
# Listen on all interfaces (for Docker/remote access)
poetry run ib-mcp-server --transport http --http-host 0.0.0.0 --http-port 8000
# Using environment variables
IB_MCP_TRANSPORT=http IB_MCP_HTTP_HOST=127.0.0.1 IB_MCP_HTTP_PORT=8000 poetry run ib-mcp-server
Security Note: HTTP mode binds to localhost (127.0.0.1) by default. For remote access, place behind a reverse proxy with proper authentication and use a protected network.
--host: IB Gateway/TWS host (default: 127.0.0.1)--port: IB Gateway/TWS port (default: 7497 for TWS, use 4001 for Gateway)--client-id: Unique client ID for the connection (default: 1)--transport: Transport protocol - stdio (default) or http--http-host: HTTP server host (default: 127.0.0.1)--http-port: HTTP server port (default: 8000)You can also use environment variables instead of flags:
IB_HOSTIB_PORTIB_CLIENT_IDIB_MCP_TRANSPORTIB_MCP_HTTP_HOSTIB_MCP_HTTP_PORTFlags override environment variables if both are provided.
| Use Case | STDIO | HTTP |
|---|---|---|
| Claude Desktop integration | ✅ Recommended | ❌ Not supported |
| Local single-client usage | ✅ Simple setup | ⚠️ Overkill |
| Multi-client access | ❌ Not possible | ✅ Supported |
| Remote/network access | ❌ Not possible | ✅ Supported |
| Docker deployment | ✅ Simple | ✅ More flexible |
| Production usage | ✅ Secure by default | ⚠️ Needs auth/proxy |
docker build -t ib-mcp .
On macOS/Windows Docker Desktop you can reach host via host.docker.internal (already the default):
docker run --rm -it \
-e IB_HOST=host.docker.internal \
-e IB_PORT=7497 \
-e IB_CLIENT_ID=1 \
ghcr.io/hellek1/ib-mcp
On Linux you may need to add --add-host host.docker.internal:host-gateway and ensure the TWS/Gateway port is accessible:
docker run --rm -it \
--add-host host.docker.internal:host-gateway \
-e IB_HOST=host.docker.internal \
-e IB_PORT=7497 \
ghcr.io/hellek1/ib-mcp
Override arguments directly if preferred:
docker run --rm -it ghcr.io/hellek1/ib-mcp --host host.docker.internal --port 4001 --client-id 2
Run as an HTTP server for multi-client or remote access:
# Local access
docker run --rm -it -p 8000:8000 \
-e IB_HOST=host.docker.internal \
-e IB_PORT=7497 \
-e IB_MCP_TRANSPORT=http \
-e IB_MCP_HTTP_HOST=0.0.0.0 \
-e IB_MCP_HTTP_PORT=8000 \
ghcr.io/hellek1/ib-mcp
# Or using command line arguments
docker run --rm -it -p 8000:8000 \
ghcr.io/hellek1/ib-mcp \
--host host.docker.internal --port 7497 \
--transport http --http-host 0.0.0.0 --http-port 8000
The HTTP server will be available at http://localhost:8000/mcp/.
The server communicates via stdio using the MCP protocol. It can be integrated with MCP-compatible tools and LLM applications.
Example MCP client configuration (e.g. Claude Desktop) using Docker:
{
"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"
]
}
}
}
Notes:
--add-host line on macOS/Windows Docker Desktop (it's only needed on Linux).For HTTP mode, connect to the server at http://localhost:8000/mcp/ using any MCP-compatible HTTP client.
lookup_contract(symbol, sec_type="STK", exchange="SMART", currency="USD")
ticker_to_conid(symbol, sec_type="STK", exchange="SMART", currency="USD")
get_historical_data(symbol, duration="1 M", bar_size="1 day", data_type="TRADES", exchange="SMART", currency="USD")
get_news(symbol, provider_codes="", exchange="SMART", currency="USD")
get_historical_news(symbol, start_date, end_date, provider_codes="", max_count=10, exchange="SMART", currency="USD")
get_fundamental_data(symbol, report_type="ReportsFinSummary", exchange="SMART", currency="USD")
Available report types:
ReportsFinSummary: Financial summaryReportsOwnership: Ownership informationReportsFinStatements: Financial statementsRESC: Research reportsCalendarReport: Calendar eventsget_portfolio(account="")
get_account_summary(account="")
get_positions(account="")
get_positions returns a markdown table with account, symbol, security type,
position, average cost, currency, exchange, local symbol, trading class, and
contract ID. Option positions also include expiry, strike, right, and multiplier.
Once connected to an LLM through MCP, you can ask questions like:
The server automatically converts XML-formatted fundamental data to markdown for better readability in LLM interactions.
The server includes comprehensive error handling and will provide meaningful error messages when:
"Cannot connect to Interactive Brokers"
"No contract found"
"No market data"
feat/xyzpoetry installpre-commit installpoetry run pytest -qpoetry version patch # or minor / major
poetry build
poetry publish --username __token__ --password
git tag v$(poetry version -s)
git push --tags
Licensed under the BSD 3-Clause License. Contributions welcome.
Install via CLI
npx mdskills install Hellek1/ib-mcpIB Async MCP Server is a free, open-source AI agent skill. Lightweight Model Context Protocol (MCP) server exposing read-only Interactive Brokers data (contracts, historical data, fundamentals, news, portfolio, account) via the asynchronous ibasync 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 ibasy
Install IB Async MCP Server with a single command:
npx mdskills install Hellek1/ib-mcpThis downloads the skill files into your project and your AI agent picks them up automatically.
IB Async MCP Server works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Gemini Cli, Amp, Roo Code, Goose. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.