这是一个FastAPI应用程序,为Interactive Brokers(IBKR)交易操作提供了一个MCP(模型上下文协议)服务器。该服务器自动管理一个IBKR Gateway Docker容器,并通过REST API和MCP端点暴露交易功能。
从这个Git仓库直接安装:
# 从主分支安装
helm install ibkr-mcp-server git+https://github.com/your-username/ibkr-mcp-server@main?path=chart
# 从特定版本安装
helm install ibkr-mcp-server git+https://github.com/your-username/ibkr-mcp-server@v1.0.0?path=chart
export IBKR_IB_GATEWAY_USERNAME="您的用户名"
export IBKR_IB_GATEWAY_PASSWORD="您的密码"
docker-compose up -d --build
克隆并设置:
git clone <仓库地址>
cd ibkr-mcp-server
安装依赖:
uv sync
运行服务器:
python main.py --ib-gateway-username=$YOUR_USERNAME --ib-gateway-password=$YOUR_PASSWORD
服务器将在http://localhost:8000启动,API文档位于/docs。MCP服务器将在http://localhost:8000/mcp可用。
这些默认不暴露给MCP
GET /gateway/status - 网关健康和状态GET /gateway/logs - 容器日志GET /ibkr/positions - 当前持仓GET /ibkr/contract_details - 符号的合约信息GET /ibkr/options_chain - 基础合约的期权链GET /ibkr/tickers - 合约ID的市场数据行情GET /ibkr/filtered_options_chain - 根据市场数据标准过滤的期权链GET /ibkr/scanner/instrument_codes - 可用的扫描器工具代码GET /ibkr/scanner/location_codes - 可用的扫描器位置代码GET /ibkr/scanner/filter_codes - 可用的扫描器过滤代码GET /ibkr/scanner/results - 具有指定参数的扫描器结果MIT许可证