Skip to main content
Glama

Interactive Brokers MCP Server

by code-rabi
MIT License
139
4
  • Linux
  • Apple

Interactive Brokers MCP Server

⚠️ DISCLAIMER: This is an unofficial, community-developed MCP server and is NOT affiliated with or endorsed by Interactive Brokers. This software is in Alpha state and may not work perfectly.

A Model Context Protocol (MCP) server that provides integration with Interactive Brokers' trading platform. This server allows AI assistants to interact with your IB account to retrieve market data, check positions, and place trades.

🔒 Security Notice

⚠️ IMPORTANT WARNINGS:

  • Financial Risk: Trading involves substantial risk of loss. Always test with paper trading first.
  • Security: This software handles sensitive financial data. Only run locally, never on public servers.
  • No Warranty: This unofficial software comes with no warranties. Use at your own risk.
  • Not Financial Advice: This tool is for automation only, not financial advice.

✨ Features

  • Account Management: Get account information and balances
  • Position Tracking: View current positions and P&L
  • Market Data: Real-time market data for stocks and instruments
  • Order Management: Place market, limit, and stop orders
  • Order Monitoring: Check order status and execution details

Prerequisites

No additional installations required! This package includes:

  • Pre-configured IB Gateway for all platforms (Linux, macOS, Windows)
  • Java Runtime Environment (JRE) for IB Gateway
  • All necessary dependencies

You only need:

  • Interactive Brokers account (paper or live trading)
  • Node.js 18+ (for running the MCP server)

Quick Start

Add this MCP server to your Cursor/Claude configuration:

{ "mcpServers": { "interactive-brokers": { "command": "npx", "args": ["-y", "interactive-brokers-mcp"] } } }

When you first use the server, a web browser window will automatically open for the Interactive Brokers OAuth authentication flow. Log in with your IB credentials to authorize the connection.

Headless Mode Configuration

For automated environments or when you prefer not to use a browser for authentication, you can enable headless mode by configuring it in your MCP server configuration:

{ "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" } } } }

In headless mode, the server will automatically authenticate using your credentials without opening a browser window. This is useful for:

  • Automated trading systems
  • Server environments without a display
  • CI/CD pipelines
  • Situations where browser interaction is not desired

Important: Even in headless mode, Interactive Brokers may still require two-factor authentication (2FA). When 2FA is triggered, the headless authentication will wait for you to complete the 2FA process through your configured method (mobile app, SMS, etc.) before proceeding.

To enable paper trading, add "IB_PAPER_TRADING": "true" to your environment variables:

{ "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" } } } }

Security Note: Store credentials securely and never commit them to version control. Consider using environment variable files or secure credential management systems.

Configuration Variables

FeatureEnvironment VariableCommand Line Argument
UsernameIB_USERNAME--ib-username
PasswordIB_PASSWORD_AUTH--ib-password-auth
Headless ModeIB_HEADLESS_MODE--ib-headless-mode
Paper TradingIB_PAPER_TRADING--ib-paper-trading
Auth TimeoutIB_AUTH_TIMEOUT--ib-auth-timeout

Available MCP Tools

ToolDescription
get_account_infoRetrieve account information and balances
get_positionsGet current positions and P&L
get_market_dataReal-time market data for symbols
place_orderPlace market, limit, or stop orders
get_order_statusCheck order execution status

Troubleshooting

Authentication Problems:

  • Use the web interface that opens automatically
  • Complete any required two-factor authentication
  • Try paper trading mode if live trading fails

Support

  • This Server: Open an issue in this repository.

License

MIT License - see LICENSE file for details.

Deploy Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

Enables AI assistants to interact with Interactive Brokers trading accounts to retrieve market data, check positions, and place trades. Includes pre-configured IB Gateway and handles OAuth authentication automatically.

  1. 🔒 Security Notice
    1. ✨ Features
      1. Prerequisites
        1. Quick Start
          1. Headless Mode Configuration
            1. Configuration Variables
              1. Available MCP Tools
                1. Troubleshooting
                  1. Support
                    1. License

                      Related MCP Servers

                      • A
                        security
                        F
                        license
                        A
                        quality
                        Transforms AI assistants into autonomous crypto trading agents with real-time market analysis, portfolio management, and trade execution across 17+ blockchains.
                        Last updated -
                        32
                        19
                        15
                      • A
                        security
                        F
                        license
                        A
                        quality
                        Enables AI assistants to interact with IG Trading API for forex, indices, and commodities trading. Provides 21 tools for account management, position trading, order placement, market data analysis, and watchlist management.
                        Last updated -
                        21
                        15
                        1
                      • -
                        security
                        A
                        license
                        -
                        quality
                        Enables AI assistants to interact with the QuantConnect cloud platform for algorithmic trading. Supports creating and managing trading strategies, running backtests, deploying live algorithms, and performing comprehensive trading operations through the QuantConnect API.
                        Last updated -
                        Apache 2.0
                        • Linux
                      • -
                        security
                        A
                        license
                        -
                        quality
                        Enables AI assistants to interact with OKX trading accounts through read-only access to retrieve portfolio information, trading positions, order history, and account analytics. Provides secure, local processing of trading data without storing sensitive information or enabling trade execution.
                        Last updated -
                        11
                        3
                        MIT License

                      View all related MCP servers

                      MCP directory API

                      We provide all the information about MCP servers via our MCP API.

                      curl -X GET 'https://glama.ai/api/mcp/v1/servers/code-rabi/interactive-brokers-mcp'

                      If you have feedback or need assistance with the MCP directory API, please join our Discord server