Interactive Brokers API FastMCP Server
LocalAbout Interactive Brokers API FastMCP Server
Interactive Brokers API FastMCP Server connects Interactive Brokers Gateway to LLMs through FastMCP. It is intended for users who want MCP access to account portfolio data and Gateway connection status.
Key features
- 01Connect through the official IB API
- 02Support simultaneous client connections
- 03Expose tools and resources
- 04Monitor Gateway connection status
- 05Provide error handling and logging
Use cases
- 01Retrieve portfolio positions and account summary
- 02Check Interactive Brokers Gateway status
MCP support
Exposes Interactive Brokers functionality as MCP tools and resources, including a portfolio retrieval tool and a Gateway status resource.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEInteractive Brokers API FastMCP Server
A server implementation for Interactive Brokers' API that allows LLMs to interact with your IB account using the Model Context Protocol (MCP).
Overview
This project creates a middleware server that connects to Interactive Brokers Gateway and exposes its functionality through the FastMCP framework. This allows LLMs like Claude to interact with your IB account, retrieve portfolio information, and potentially execute trades.
Features
- Connect to Interactive Brokers Gateway via the official IB API
- Support multiple simultaneous client connections through FastMCP
- Expose IB functionality as MCP tools and resources
- Connection status monitoring
- Error handling and logging
Prerequisites
- Python 3.11+
- Interactive Brokers Gateway installed and running
- IB account with API access enabled
Installation
- Clone this repository:
git clone https://github.com/karimQuant/ibapi-mcp-server.git
cd ibapi-mcp-server
- Install dependencies:
pip install -e .
Usage
-
Start your IB Gateway and log in
-
Run the server:
a. Using stdio transport (default):
python server.pyb. Using SSE transport:
python server.py ssec. Using SSE transport with custom port:
python server.py sse port=9000d. Using the FastMCP CLI:
fastmcp run server.pye. For development with an interactive testing environment:
fastmcp dev server.py -
Connect client applications (like Claude Desktop) to the server
API Documentation
The FastMCP Server provides the following functionality:
Available Tools
- get_portfolio_tool: Retrieve your current portfolio positions and account summary
Resources
- ibgateway://{host}/{port}: Get the current status of the IB Gateway connection
License
MIT
Contribution
Contributions are welcome! Please feel free to submit a Pull Request.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.