interactive-brokers
Interactive Brokers MCP Server
claude mcp add --transport stdio code-rabi-interactive-brokers-mcp npx -y interactive-brokers-mcp
How to use
This MCP server provides integration with Interactive Brokers, enabling an AI assistant to access your IB account for real-time market data, account information, positions, and order management. It supports trading capabilities such as placing market, limit, and stop orders (subject to read-only mode), as well as Flex Queries to retrieve historical statements and trade data. The server can operate with browser-based OAuth authentication (default) or in headless mode using credentials for automated environments, making it suitable for automated trading systems or server deployments. Tools are exposed under a unified interface, including get_account_info, get_positions, get_market_data, place_order, get_order_status, get_live_orders, and Flex Query operations like get_flex_query, list_flex_queries, and forget_flex_query. To start, run the MCP server via npx as shown in the Quick Start section, then authorize with IB in the browser or provide credentials in headless mode for unattended operation.
How to install
Prerequisites:
- Node.js 18+ installed on the machine where you will run the MCP server. The package is designed to run directly via npx with no additional installation steps.
Installation steps:
- Ensure Node.js 18+ is installed. Verify with: node -v npm -v
- Run the MCP server using npx (no local install required): npx -y interactive-brokers-mcp
- On first run, a web browser will open to complete Interactive Brokers OAuth authentication. Follow the prompts to authorize the connection.
Optional headless setup (for automated environments):
- Use the same npx command but add environment variables as needed (see Environment Variables in the README for details).
- Example (headless mode with paper trading): { "mcpServers": { "interactive-brokers": { "command": "npx", "args": ["-y", "interactive-brokers-mcp"], "env": { "IB_HEADLESS_MODE": "true", "IB_USERNAME": "your_ib_username", "IB_PASSWORD_AUTH": "your_ib_password", "IB_PAPER_TRADING": "true" } } } }
Note: Store credentials securely and avoid committing them to version control. Use environment variable files or secret management where possible.
Additional notes
Environment variables and configuration options:
- IB_USERNAME: Interactive Brokers username
- IB_PASSWORD_AUTH: Interactive Brokers password or authentication method
- IB_HEADLESS_MODE: Enable headless authentication (true/false)
- IB_PAPER_TRADING: Enable paper trading mode (true/false)
- IB_FLEX_TOKEN: Flex Web Service token for Flex Queries
- IB_READ_ONLY_MODE: Restrict actions to read-only operations (true/false)
Flex Queries: If you plan to use Flex Queries, obtain a Flex Web Service Token and set IB_FLEX_TOKEN in the environment. Flex Queries are automatically saved for reuse and can be managed with list_flex_queries and forget_flex_query tools.
Security considerations: Run this locally or in trusted environments. The MCP server handles sensitive financial data and credentials. Always adhere to security best practices and review permissions before enabling trading features.
Related MCP Servers
any-chat-completions
MCP Server for using any LLM as a Tool
bitbucket
Bitbucket MCP - A Model Context Protocol (MCP) server for integrating with Bitbucket Cloud and Server APIs
time
⏰ Time MCP Server: Giving LLMs Time Awareness Capabilities
unity-editor
An MCP server and client for LLMs to interact with Unity Projects
website-publisher
AI Website builder and publisher MCP. Quickly publish and deploy your AI generated code as real website URL. Support html, css, js, python etc.
xgmem
Global Memory MCP server, that manage all projects data.