Skip to main content

MCP server wrapping ib_async for Interactive Brokers API

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ib_async_mcp-0.1.0.tar.gz (65.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ib_async_mcp-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file ib_async_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: ib_async_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 65.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ib_async_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f172ce1a8f72df356588807819fa1310e0ecc9b0b42b571604992b67d0cc38a1
MD5 5cc6388c343f75c8da3d08901434619a
BLAKE2b-256 562dd39a2912261c9a5776ec874ac76075399ad11679aaf3cda951078bddb31c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ib_async_mcp-0.1.0.tar.gz:

Publisher: publish.yml on nadavgb-atom/ib-async-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ib_async_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ib_async_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ib_async_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1653506e5fc044be45697f4ab016a846866d7fd0eb83758e192a50b308889695
MD5 fef26bdbd1b403b37f879461424fa282
BLAKE2b-256 1e5bf0ac89cc67bd6cf0ff229b0c56617b0277caa97edc07b81631c0853876cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for ib_async_mcp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on nadavgb-atom/ib-async-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page