Get the FREE Ultimate OpenClaw Setup Guide →

IB_MCP

This project provides an Interactive Brokers (IB) API interface using the Model Context Protocol (MCP).

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio rcontesti-ib_mcp docker run -i --rm rcontesti/ib_mcp \
  --env MCP_HOST="0.0.0.0" \
  --env MCP_PATH="/mcp" \
  --env MCP_PORT="5002" \
  --env GATEWAY_PORT="5055" \
  --env GATEWAY_BASE_URL="https://localhost"

How to use

This MCP server implements an Interactive Brokers (IB) Web API based MCP (Model Context Protocol) server. It exposes a dedicated MCP endpoint that routes requests to the IB Web API via the Client Portal Gateway, enabling programmatic access to IB account data, positions, orders, and other IB Web API resources through MCP-compliant clients. You can deploy it inside a Docker container and then connect your MCP-enabled tooling or VS Code MCP integration to the server URL. The server is designed to work behind an IB Client Portal Gateway for authenticated access and uses HTTPS through the gateway. Use the provided endpoints to discover, query, and execute operations against your IB account, with endpoints generated manually where automated router generation is not yet available. To integrate with your editor or tooling, configure the MCP server URL (for example http://localhost:5002/mcp/) in your MCP-enabled IDE, and ensure the Client Portal Gateway authentication flow is accessible from the same host. The server exposes time and IB Web API related routes, and you can extend it as new routers are added.

How to install

Prerequisites:

  • Docker installed on your machine
  • Access to the Internet to pull the MCP image

Step-by-step:

  1. Install Docker:
  2. Pull and run the IB MCP server image:
    • Run: docker run -d --name ib-mcp-server -p 5002:5002 -p 5055:5055 --env GATEWAY_BASE_URL=https://localhost --env GATEWAY_PORT=5055 --env MCP_HOST=0.0.0.0 --env MCP_PORT=5002 --env MCP_PATH=/mcp rcontesti/ib_mcp
  3. Verify the server:
  4. Configure MCP client/tools:
    • Point your MCP client to http://localhost:5002/mcp/ and use the MCP Server configuration as described in the repository documentation.

Notes:

  • If you use docker-compose, adapt the service to expose port 5002 and pass necessary environment variables.
  • The gateway must be authenticated via the browser on the same host for multi-container setups.

Prerequisites recap:

  • Docker Engine
  • Access to the IB Client Portal Gateway (for authentication)
  • Basic MCP client or VS Code MCP integration configured to the server URL

Additional notes

Tips and common issues:

  • Ensure the Client Portal Gateway is running and accessible on the same host when using the multi-container setup.
  • Endpoints are currently manually built for IB REST API routes due to OpenAPI spec validation issues; expect some endpoints to be added progressively.
  • If the MCP session times out, use the /iserver/auth/ssodh/init and /tickle endpoints as described in the repository notes to re-establish a session and keep connections alive.
  • For VS Code integration, you can add the MCP server in settings.json or in .vscode/mcp.json to enable discovery and usage of the IB MCP server.
  • Use the gateway URL and port combination that matches your deployment (the example uses 5055 for the gateway and 5002 for MCP).

Related MCP Servers

Sponsor this space

Reach thousands of developers