ibapi
Interactive Brokers API Multi-Client Protocol Server
claude mcp add --transport stdio karimquant-ibapi-mcp-server python server.py
How to use
The ibapi MCP server provides a middleware layer that connects to the Interactive Brokers Gateway via the official IB API and exposes IB functionality through the FastMCP framework. This enables large language models and automation clients to query account information, retrieve portfolio positions, and, potentially, place trades through a defined set of MCP tools and resources. The server exposes a dedicated tool for obtaining portfolio data and an ibgateway resource that reflects the current connection status to the IB Gateway, allowing clients to monitor connectivity before issuing commands.
To use the server, first ensure your IB Gateway is running with API access enabled and that you can connect from the machine hosting the MCP server. Start the server using one of the supported methods (standard stdio, SSE, or via FastMCP CLI). Once the server is up, client applications can discover and invoke the available MCP tools, such as get_portfolio_tool, and reference resources like ibgateway://host/port to verify the gateway connection status before attempting privileged actions.
Typical client flows include querying your portfolio and account summary through get_portfolio_tool, validating the IB Gateway state via the ibgateway resource, and then using the MPC’s command set to perform actions or fetch real-time data as permitted by your IB account configuration.
How to install
Prerequisites:
- Python 3.11+
- Interactive Brokers Gateway installed and running
- An IB account with API access enabled
Installation steps:
# 1. Clone the repository
git clone https://github.com/karimQuant/ibapi-mcp-server.git
cd ibapi-mcp-server
# 2. Install the package in editable mode
pip install -e .
If you need to install additional dependencies or utilities, install them as you would for a typical Python project. Ensure your environment has network access to the IB Gateway host and port, and that the IB Gateway is configured to allow API connections from the MCP server host.
Optionally, you can verify the installation by listing installed packages or running a quick import test in Python to ensure the package loads without errors.
Additional notes
Tips and known considerations:
- Ensure Python 3.11+ is actively used in your environment to match the server's requirements.
- The MCP server relies on a running IB Gateway with API access enabled; connectivity issues will appear in logs and should be resolved by checking firewall rules and IB Gateway settings.
- If you encounter connection errors, verify host/port in the ibgateway resource string (ibgateway://host/port) and confirm the gateway allows connections from the MCP server.
- Logs are your friend: enable verbose logging if available to diagnose issues with IB API calls, portfolio retrieval, or tool execution.
- The available tool currently exposed is get_portfolio_tool for retrieving portfolio positions and account summary; future updates may add more MCP tools and resources.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP