- Home
- MCP servers
- Interactive Brokers
Interactive Brokers
- javascript
64
GitHub Stars
javascript
Language
6 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": {
"code-rabi-interactive-brokers-mcp": {
"command": "npx",
"args": [
"-y",
"interactive-brokers-mcp"
],
"env": {
"IB_USERNAME": "YOUR_IB_USERNAME",
"IB_FLEX_TOKEN": "YOUR_FLEX_TOKEN",
"IB_AUTH_TIMEOUT": "60",
"IB_HEADLESS_MODE": "true",
"IB_PAPER_TRADING": "true",
"IB_PASSWORD_AUTH": "YOUR_IB_PASSWORD",
"IB_READ_ONLY_MODE": "true"
}
}
}
}You can run an MCP server that connects to Interactive Brokers to let your AI assistants access account data, fetch market information, and place trades. This server handles authentication, trading actions, and optional Flex Queries so you can automate workflows with confidence while keeping sensitive data local to your environment.
How to use
To use this MCP server, start it in your environment and connect your MCP-compatible client. You’ll be able to retrieve account details, view current positions, stream real-time market data, and submit trades such as market, limit, or stop orders. When Flex Queries are enabled, you can request statements and historical data, and the server will remember queries for convenient reuse.
How to install
Prerequisites: ensure you have Node.js 18 or newer installed on your system.
Install and run the MCP server using the provided NPX command. The server runs without Docker or additional installations.
{
"mcpServers": {
"interactive-brokers": {
"command": "npx",
"args": ["-y", "interactive-brokers-mcp"]
}
}
}
Additional setup notes
If you want the server to authenticate without using a browser, enable headless mode and provide credentials in the environment. You can also enable paper trading to test strategies safely.
Security, authentication, and data handling
Treat all credentials as sensitive and store them securely. Prefer environment variables or a secure credential store, and avoid committing credentials to version control. The MCP server communicates with Interactive Brokers using your provided credentials and tokens, so manage access carefully.
Flex Queries and tokens
If you want to use Flex Queries to retrieve statements or historical data, configure a Flex Web Service token and supply it to the server. Flex Queries are automatically saved for easy reuse.
Configuration options
You can customize authentication, paper trading, and Flex Token via environment variables or dedicated configuration fields. The following variables are commonly used to control behavior.
Troubleshooting
If authentication fails, use the automatic web-based flow when available and complete any required two-factor prompts. For automated environments, verify that headless credentials are correct and that network access to Interactive Brokers is allowed.
Support and licensing
This MCP server is community-developed and alpha in state. Use is at your own risk, and there is no warranty. If you encounter issues, open an issue with the project maintainers.
Tools and capabilities
The MCP server exposes a set of tools to interact with your Interactive Brokers account and market data. You can retrieve account information, fetch positions, obtain real-time market data, place orders, and check or monitor live orders. Optional Flex Query tools let you run account statements and historical data requests.
What you can do with the server
- Retrieve account information and balances.\n- Get current positions and P&L.\n- Access real-time market data for symbols.\n- Place market, limit, and stop orders (when not in read-only mode).\n- Check order status and monitor live orders.\n- Execute and manage Flex Queries, with automatic memory for reuse.
Notes on usage flow
For automated environments, you can run in headless mode, enabling non-interactive authentication and operation. In all cases, ensure two-factor authentication steps are completed if triggered by Interactive Brokers.
Available tools
get_account_info
Retrieve account information and balances
get_positions
Get current positions and P&L
get_market_data
Real-time market data for symbols
place_order
Place market, limit, or stop orders (only if read-only mode is disabled)
get_order_status
Check order execution status
get_live_orders
Get all live/open orders for monitoring
get_flex_query
Execute a Flex Query and retrieve statements (auto-saves for reuse)
list_flex_queries
List all previously used Flex Queries
forget_flex_query
Remove a saved Flex Query from memory