home / mcp / interactive brokers mcp server
Provides integration with Interactive Brokers for account data, market data, and trade execution via MCP.
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.
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.
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"]
}
}
}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.
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.
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.
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.
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.
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.
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.
- 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.
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.
Retrieve account information and balances
Get current positions and P&L
Real-time market data for symbols
Place market, limit, or stop orders (only if read-only mode is disabled)
Check order execution status
Get all live/open orders for monitoring
Execute a Flex Query and retrieve statements (auto-saves for reuse)
List all previously used Flex Queries
Remove a saved Flex Query from memory