IBKR MCP Server logo

IBKR MCP Server

Community
ArjunDivecha

Interactive Brokers MCP Server for Claude Desktop/Code

PublisherArjunDivecha
Repositoryibkr-mcp-server
LanguagePython
Forks
24
Stars
35
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    IBKR MCP Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    35 stars and 24 forks from the linked repository.

IBKR MCP Server

A professional Model Context Protocol (MCP) server for Interactive Brokers API integration, designed for use with Claude Desktop and Claude Code.

CI Python 3.10+ License: MIT

Features

  • ✅ Multi-Account Support - Switch between multiple IBKR accounts
  • ✅ Short Selling Analysis - Shortable shares, borrow rates, margin requirements
  • ✅ Real-time Market Data - Live quotes, historical data, options chains
  • ✅ Portfolio Management - Positions, P&L, account summaries
  • ✅ Trading Operations - Place, modify, cancel orders (with safety checks)
  • ✅ Auto-Reconnection - Handles TWS/Gateway restarts gracefully
  • ✅ Production Ready - Proper error handling, logging, and monitoring

Quick Start

Prerequisites

  • Python 3.10 or higher
  • Interactive Brokers account with TWS or IB Gateway
  • Claude Desktop or Claude Code

Installation

  1. Clone the repository:

    bash
    git clone https://github.com/yourusername/ibkr-mcp-server.git
    cd ibkr-mcp-server
  2. Run the setup script:

    bash
    # macOS/Linux
    chmod +x scripts/setup.sh
    ./scripts/setup.sh
    
    # Windows
    scripts\setup.bat
  3. Configure your settings:

    bash
    cp .env.example .env
    # Edit .env with your IBKR settings
  4. Start TWS/IB Gateway and enable API connections

  5. Test the server:

    bash
    python -m ibkr_mcp_server.main --test

Claude Integration

Claude Desktop: Add to your claude_desktop_config.json:

json
{
  "mcpServers": {
    "ibkr": {
      "command": "python",
      "args": ["-m", "ibkr_mcp_server.main"],
      "cwd": "/path/to/ibkr-mcp-server"
    }
  }
}

Claude Code:

bash
claude mcp add ibkr 'python -m ibkr_mcp_server.main' --cwd /path/to/ibkr-mcp-server

Usage Examples

Basic Operations

python
# Get portfolio across all accounts
"Show me my current portfolio"

# Switch accounts
"Switch to account DU7654321"

# Market data
"Get real-time quotes for AAPL, TSLA, MSFT"

Short Selling Analysis

python
# Complete short selling analysis
"Analyze short selling for GME, AMC, BBBY - show availability, borrow costs, and margin requirements"

# Check specific account
"Check shortable shares for TSLA in my paper trading account"

Trading Operations

python
# Place orders (paper trading recommended)
"Place a limit order to buy 100 shares of AAPL at $150"

# Check margin requirements
"What are the margin requirements for shorting 200 shares of TSLA?"

Available Tools

ToolDescription
get_portfolioCurrent portfolio positions and P&L
get_account_summaryAccount balances and key metrics
switch_accountSwitch between IBKR accounts
check_shortable_sharesShort selling availability
get_margin_requirementsMargin requirements for securities
get_borrow_ratesStock borrow rates (short selling costs)
short_selling_analysisComplete short selling analysis
get_market_dataReal-time market quotes
get_historical_dataHistorical price data
place_orderPlace trading orders (with safety checks)
get_connection_statusCheck IBKR connection status

Configuration

Environment Variables

env
# IBKR Connection
IBKR_HOST=127.0.0.1
IBKR_PORT=7497  # 7497=TWS Paper, 7496=TWS Live, 4001=Gateway
IBKR_CLIENT_ID=1
IBKR_IS_PAPER=true

# Logging
LOG_LEVEL=INFO

# Safety
ENABLE_LIVE_TRADING=false  # Set to true for live trading
MAX_ORDER_SIZE=1000  # Maximum order size

TWS/Gateway Setup

  1. Start TWS or IB Gateway
  2. Go to Configuration → API → Settings
  3. Enable "ActiveX and Socket Clients"
  4. Set socket port (7497 for paper, 7496 for live)
  5. Add 127.0.0.1 to "Trusted IPs"
  6. Check "Download open orders on connection"

Development

Setup Development Environment

bash
pip install -e ".[dev]"
pre-commit install

Running Tests

bash
pytest tests/ -v

Code Quality

bash
black ibkr_mcp_server/
isort ibkr_mcp_server/
mypy ibkr_mcp_server/

Deployment

Auto-start on Boot (macOS)

bash
python scripts/install_service.py --platform macos

Auto-start on Boot (Linux)

bash
python scripts/install_service.py --platform linux

Docker Deployment

bash
docker build -t ibkr-mcp-server .
docker run -d --name ibkr-mcp -p 8080:8080 ibkr-mcp-server

Documentation

Safety & Disclaimers

⚠️ Important Safety Notes:

  • Always test with paper trading first
  • Verify all data in TWS before making trading decisions
  • This software is for educational purposes
  • Use at your own risk
  • No warranty provided

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "arjundivecha-ibkr-mcp-server": {
      "command": "",
      "args": []
    }
  }
}

Use IBKR MCP Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once IBKR MCP Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add IBKR MCP Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the IBKR MCP Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "arjundivecha-ibkr-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "ibkr-mcp-server"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the IBKR MCP Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the IBKR MCP Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use IBKR MCP Server to help me with this task?
IBKR MCP Server
Sure. I read it.
Here is what I found using IBKR MCP Server.

Frequently asked questions

What is the IBKR MCP Server MCP server used for?

IBKR MCP Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use IBKR MCP Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use IBKR MCP Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use IBKR MCP Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With IBKR MCP Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect IBKR MCP Server MCP to TypingMind?

IBKR MCP Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does IBKR MCP Server MCP provide in TypingMind?

IBKR MCP Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use IBKR MCP Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If IBKR MCP Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇