ib-async-mcp

ib-async-mcp

An MCP server that provides an interface for the Interactive Brokers API via the ib_async library. It enables users to manage accounts, access real-time and historical market data, and execute or monitor trades through TWS or IB Gateway.

Category
访问服务器

README

ib-async-mcp

MCP (Model Context Protocol) server wrapping ib_async for Interactive Brokers API.

Features

  • Connection Management: Connect/disconnect to TWS or IB Gateway
  • Account Data: Account values, summary, portfolio, positions, P&L
  • Contracts: Create and qualify contracts (stocks, options, futures, forex, crypto, etc.)
  • Market Data: Real-time quotes and historical data
  • Orders: Place, modify, cancel orders (market, limit, stop, stop-limit)
  • Options: Option chains, implied volatility, option pricing
  • Scanners: Market scanners with various criteria
  • News: News providers and articles

Prerequisites

  • Python 3.10+
  • Interactive Brokers TWS or IB Gateway running with API enabled
  • API port configured (default: 7497 for TWS, 4001 for Gateway)

Installation

cd ib-async-mcp
uv sync

Usage

Running the Server

uv run ib-async-mcp

MCP Configuration

Add to your MCP client configuration (e.g., .kiro/settings/mcp.json):

{
  "mcpServers": {
    "ib-async": {
      "command": "uv",
      "args": ["--directory", "/path/to/ib-async-mcp", "run", "ib-async-mcp"],
      "env": {}
    }
  }
}

Or using uvx (after publishing):

{
  "mcpServers": {
    "ib-async": {
      "command": "uvx",
      "args": ["ib-async-mcp"],
      "env": {}
    }
  }
}

Available Tools

Connection

  • connect - Connect to TWS/Gateway
  • disconnect - Disconnect
  • is_connected - Check connection status

Account

  • get_accounts - List managed accounts
  • get_account_values - Account values (balance, margin, etc.)
  • get_account_summary - Account summary
  • get_portfolio - Portfolio with market values
  • get_positions - All positions
  • get_pnl - Profit and loss

Contracts

  • create_contract - Create a contract
  • qualify_contracts - Qualify contracts (fill conId)
  • get_contract_details - Detailed contract info
  • search_symbols - Search for symbols

Market Data

  • get_market_data - Real-time snapshot
  • get_historical_data - Historical bars
  • get_head_timestamp - Earliest available data

Orders

  • place_order - Place new order
  • cancel_order - Cancel order
  • cancel_all_orders - Cancel all orders
  • get_open_orders - List open orders
  • get_open_trades - List open trades
  • get_executions - Execution reports
  • get_fills - Order fills
  • what_if_order - Check margin impact

Options

  • get_option_chain - Option chain
  • calculate_implied_volatility - Calculate IV
  • calculate_option_price - Calculate option price

Scanners

  • get_scanner_parameters - Available scanner params
  • run_scanner - Run market scanner

News

  • get_news_providers - List news providers
  • get_news_article - Get article
  • get_historical_news - Historical headlines

Utility

  • get_current_time - TWS server time

Example Usage

# Connect first
connect(host="127.0.0.1", port=7497, client_id=1)

# Get account info
get_accounts()
get_portfolio()

# Get market data
get_market_data(contract_type="stock", symbol="AAPL")

# Get historical data
get_historical_data(
    contract_type="stock",
    symbol="SPY",
    duration="5 D",
    bar_size="1 hour"
)

# Place an order
place_order(
    contract_type="stock",
    symbol="AAPL",
    action="BUY",
    quantity=100,
    order_type="limit",
    limit_price=150.00
)

License

MIT

Disclaimer

This software is not affiliated with Interactive Brokers Group, Inc. Use at your own risk.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选