Provides access to Interactive Brokers data, orders, and account management via MCP.
Configuration
View docs{
"mcpServers": {
"jinyiabc-ibkr-mcp": {
"command": "python",
"args": [
"C:\\path\\to\\ibkr-mcp-server\\server.py"
]
}
}
}You run a dedicated MCP server that lets your applications interact with Interactive Brokers through the TWS API or IB Gateway. It exposes practical tools to manage accounts, fetch market data, place and view orders, and retrieve executions and option chains, all from a local or remote client using the MCP protocol.
You start the MCP server locally and connect your MCP client to it. The server exposes tools that let you log in to IBKR via TWS or IB Gateway, fetch account details, pull real-time and historical market data, place and manage orders, and retrieve executions and option chains. Establish a local connection first, then issue requests through the MCP client to perform common trading tasks without directly interacting with IBKR endpoints.
Prerequisites are required before you begin.
pip install -r requirements.txt
```
Or install dependencies individually:
```
pip install mcp ib_insync pydanticConfigure the TWS or IB Gateway for API access so the MCP server can connect.
1) Start TWS or IB Gateway
2) Log in with your credentials
3) Go to File ā Global Configuration ā API ā Settings
4) Enable "Enable ActiveX and Socket Clients"
5) Note the Socket Port (7497 for paper trading, 7496 for live)
6) Add 127.0.0.1 to Trusted IPs
7) Restart TWS/IB GatewayStart the MCP server after dependencies are installed and configuration is in place.
python server.pyStart commands and minimal configuration are shown below. The server runs and waits for MCP client connections via stdio.
python server.pyEstablish a connection to Interactive Brokers TWS or IB Gateway to enable subsequent actions.
Terminate the connection to Interactive Brokers.
Retrieve account metrics such as cash value, net liquidation, buying power, and realized/unrealized PnL.
Fetch all current positions with details like symbol, quantity, cost basis, value, and P&L.
Request real-time market data for a specific symbol, including bid, ask, last price, and volume.
Obtain historical market data for a symbol with a specified duration and bar size.
Submit market or limit orders for a given symbol and quantity.
Cancel an existing order by its identifier.
List all open orders currently active.
Retrieve recent trade executions within a given timeframe.
Fetch option chains for a symbol to view available strikes and expirations.