- Home
- MCP servers
- Ibkr
Ibkr
- python
0
GitHub Stars
python
Language
4 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
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.
How to use
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.
How to install
Prerequisites are required before you begin.
pip install -r requirements.txt
Or install dependencies individually:
pip install mcp ib_insync pydantic
Configure 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 Gateway
Start the MCP server after dependencies are installed and configuration is in place.
python server.py
Configuration and usage notes
Start commands and minimal configuration are shown below. The server runs and waits for MCP client connections via stdio.
python server.py
Available tools
connect_ibkr
Establish a connection to Interactive Brokers TWS or IB Gateway to enable subsequent actions.
disconnect_ibkr
Terminate the connection to Interactive Brokers.
get_account_summary
Retrieve account metrics such as cash value, net liquidation, buying power, and realized/unrealized PnL.
get_positions
Fetch all current positions with details like symbol, quantity, cost basis, value, and P&L.
get_market_data
Request real-time market data for a specific symbol, including bid, ask, last price, and volume.
get_historical_data
Obtain historical market data for a symbol with a specified duration and bar size.
place_order
Submit market or limit orders for a given symbol and quantity.
cancel_order
Cancel an existing order by its identifier.
get_open_orders
List all open orders currently active.
get_executions
Retrieve recent trade executions within a given timeframe.
get_option_chain
Fetch option chains for a symbol to view available strikes and expirations.