Get the FREE Ultimate OpenClaw Setup Guide →

interactive-brokers

Interactive Brokers MCP Server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Ensure Node.js 18+ is installed. Verify with: node -v npm -v
  2. Run the MCP server using npx (no local install required): npx -y interactive-brokers-mcp
  3. 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):

  1. Use the same npx command but add environment variables as needed (see Environment Variables in the README for details).
  2. 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

Sponsor this space

Reach thousands of developers