home / mcp / ibapi mcp server

IBAPI MCP Server

Interactive Brokers API Multi-Client Protocol Server

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "karimquant-ibapi-mcp-server": {
      "command": "python",
      "args": [
        "server.py"
      ]
    }
  }
}

This Interactive Brokers MCP Server provides a FastMCP middleware layer that lets an LLM safely interact with your IB account through the MCP protocol. It exposes IB Gateway functionality as MCP tools and resources, enabling you to retrieve portfolio information and monitor connection status while maintaining a clean separation between the model and your trading infrastructure.

How to use

You connect your MCP client to the server using the standard MCP transport. Start the server locally, then use a client to access the exposed tools and resources. The server exposes a portfolio retrieval tool and a gateway connection status resource so your client can inspect your IB positions and confirm the IB Gateway is online.

Key capabilities you can leverage include: retrieving your current portfolio positions and account summary, and checking the current status of the IB Gateway connection. Use the client to issue the available MCP actions and read the corresponding results in your workflow.

How to install

Prerequisites you need before installing and running the server are as follows.

  • Python 3.11+
  • Interactive Brokers Gateway installed and running
  • IB account with API access enabled

Install the server package in editable mode from your local copy.

# Step 1: clone the project
git clone https://github.com/karimQuant/ibapi-mcp-server.git
cd ibapi-mcp-server

# Step 2: install dependencies
pip install -e .

Additional sections

Usage with different transports and tooling options is supported for development and production alike.

Run options shown here assume you have an IB Gateway instance already started and logged in.

MCP client commands you can run include starting the server in standard stdio mode, starting the server with Server-Sent Events (SSE) transport, or using the FastMCP CLI or development helpers.

# Start the server using standard stdio transport (default)
python server.py

# Start the server using SSE transport
python server.py sse

# Start the server with SSE transport on a custom port
python server.py sse port=9000

# Run via the FastMCP CLI
fastmcp run server.py

# Development testing environment
fastmcp dev server.py

Available tools

get_portfolio_tool

Retrieves your current portfolio positions and account summary from the Interactive Brokers Gateway through the MCP interface.