Interactive Brokers MCP Server
Interactive Brokers MCPサーバー
免責事項: これはコミュニティによって開発された非公式のMCPサーバーであり、Interactive Brokersとは一切関係がなく、推奨もされていません。このソフトウェアはアルファ版であり、完全に動作しない可能性があります。
Interactive Brokersの取引プラットフォームとの統合を提供するModel Context Protocol (MCP) サーバーです。このサーバーを使用すると、AIアシスタントがあなたのIB口座と対話し、市場データの取得、ポジションの確認、注文の発注を行うことができます。
🔒 セキュリティに関する注意

Related MCP server: Interactive Brokers MCP Server
機能
Interactive Brokers API統合: 口座管理、ポジション追跡、リアルタイム市場データ、注文管理(成行、指値、逆指値注文)を含む完全な取引機能
Flex Queryサポート: Flex Queryを実行して、口座明細、約定確認、履歴データを取得します。クエリは自動的に記憶され、簡単に再利用できます
柔軟な認証: ブラウザベースのOAuth認証、または自動化環境向けの資格情報を使用したヘッドレスモードを選択可能
簡単なセットアップ:
npxで直接実行可能 - Dockerや追加のインストールは不要です。すべてのプラットフォーム向けに設定済みのIB GatewayとJavaランタイムが含まれています
セキュリティに関する注意
重要な警告:
財務リスク: 取引には多額の損失リスクが伴います。必ず最初にペーパートレードでテストしてください。
セキュリティ: このソフトウェアは機密性の高い財務データを扱います。ローカル環境でのみ実行し、公開サーバーでは決して実行しないでください。
無保証: この非公式ソフトウェアにはいかなる保証もありません。自己責任で使用してください。
投資助言ではありません: このツールは自動化のみを目的としており、投資助言ではありません。
前提条件
追加のインストールは不要です! このパッケージには以下が含まれています:
すべてのプラットフォーム(Linux、macOS、Windows)向けの事前設定済みIB Gateway
IB Gateway用のJava Runtime Environment (JRE)(Alpineベースのコンテナ(例:
node:lts-alpine、supergateway)用のmusl-libcビルドを含む)必要なすべての依存関係
必要なものは以下の通りです:
Interactive Brokers口座(ペーパーまたはライブ取引)
Node.js 18以上(MCPサーバー実行用)
クイックスタート
このMCPサーバーをCursor/Claudeの設定に追加してください:
{
"mcpServers": {
"interactive-brokers": {
"command": "npx",
"args": ["-y", "interactive-brokers-mcp"]
}
}
}サーバーを初めて使用する際、Interactive BrokersのOAuth認証フローのためにWebブラウザウィンドウが自動的に開きます。IBの資格情報でログインし、接続を承認してください。
ヘッドレスモードの設定
自動化環境や、認証にブラウザを使用したくない場合は、MCPサーバーの設定でヘッドレスモードを有効にできます:
{
"mcpServers": {
"interactive-brokers": {
"command": "npx",
"args": ["-y", "interactive-brokers-mcp"],
"env": {
"IB_HEADLESS_MODE": "true",
"IB_USERNAME": "your_ib_username",
"IB_PASSWORD_AUTH": "your_ib_password"
}
}
}
}
ヘッドレスモードでは、サーバーはブラウザウィンドウを開かずに資格情報を使用して自動的に認証を行います。これは以下の場合に便利です:
自動取引システム
ディスプレイのないサーバー環境
CI/CDパイプライン
ブラウザの操作が望ましくない状況
重要: ヘッドレスモードであっても、Interactive Brokersが二要素認証(2FA)を要求する場合があります。2FAがトリガーされた場合、ヘッドレス認証は、あなたが設定した方法(モバイルアプリ、SMSなど)で2FAプロセスを完了するのを待機してから続行します。
ペーパートレードを有効にするには、環境変数に "IB_PAPER_TRADING": "true" を追加してください:
{
"mcpServers": {
"interactive-brokers": {
"command": "npx",
"args": ["-y", "interactive-brokers-mcp"],
"env": {
"IB_HEADLESS_MODE": "true",
"IB_USERNAME": "your_ib_username",
"IB_PASSWORD_AUTH": "your_ib_password",
"IB_PAPER_TRADING": "true"
}
}
}
}セキュリティ上の注意: 資格情報は安全に保管し、バージョン管理システムには決してコミットしないでください。環境変数ファイルや安全な資格情報管理システムの使用を検討してください。
Flex Queryの設定(オプション)
口座明細や履歴データを取得するためにFlex Queryを使用するには、Flex Web Serviceトークンを設定する必要があります:
{
"mcpServers": {
"interactive-brokers": {
"command": "npx",
"args": ["-y", "interactive-brokers-mcp"],
"env": {
"IB_FLEX_TOKEN": "your_flex_token_here"
}
}
}
}Flexトークンの取得方法:
Interactive Brokers口座管理にログインします
設定 → 口座設定 に移動します
レポート → Flex Web Service に移動します
Flex Web Serviceトークンを生成または取得します
Flex Web Serviceを有効にする詳細な手順については、IB Flex Web Serviceガイドを参照してください。
Flex Queryの作成:
口座管理の レポート → Flex Query に移動します
クエリテンプレートを作成またはカスタマイズします
クエリの横にある情報アイコンをクリックして、クエリIDを確認します
Flex Queryの作成とカスタマイズに関する完全なガイドについては、IB Flex Queriesガイドを参照してください。
注: Flex Queryを初めて実行すると、MCPサーバーはAPIから取得した名前で自動的に保存します。今後の実行では、IDまたは保存された名前でクエリを参照できます。
Flex Queryの機能:
自動メモリ: Flex Queryを実行すると、将来の使用のために自動的に保存されます
簡単な再利用: 以前に使用したクエリは記憶されるため、クエリIDを繰り返しコピーする必要はありません
フレンドリーネーム: クエリを初めて実行する際に、オプションでわかりやすい名前を付けることができます
クエリの削除:
forget_flex_queryツールを使用して、不要になったクエリを削除できます
設定変数
機能 | 環境変数 | コマンドライン引数 |
ユーザー名 |
|
|
パスワード |
|
|
ヘッドレスモード |
|
|
ペーパートレード |
|
|
認証タイムアウト |
|
|
Flexトークン |
| N/A |
読み取り専用モード |
|
|
利用可能なMCPツール
取引および口座管理
ツール | 説明 |
| 口座情報と残高を取得 |
| 現在のポジションと損益を取得 |
| シンボルのリアルタイム市場データを取得 |
| 成行、指値、または逆指値注文を発注(読み取り専用モードが無効な場合のみ) |
| 注文の執行状況を確認 |
| 監視用にすべてのアクティブ/未決済注文を取得 |
Flex Query (IB_FLEX_TOKENが必要)
ツール | 説明 |
| Flex Queryを実行して明細を取得(再利用のために自動保存) |
| 以前に使用したすべてのFlex Queryを一覧表示 |
| 保存されたFlex Queryをメモリから削除 |
トラブルシューティング
認証の問題:
自動的に開くWebインターフェースを使用してください
必要な二要素認証をすべて完了してください
ライブ取引が失敗する場合は、ペーパートレードモードを試してください
サポート
このサーバー: このリポジトリでIssueを作成してください。
ライセンス
MITライセンス - 詳細はLICENSEファイルを参照してください。
貢献者に感謝
このプロジェクトをより良くするために貢献してくださったすべての方々に深く感謝いたします。
Available Tools
14 toolsactivate_alertA
Activate a previously created alert. Usage: { "accountId": "<id>", "alertId": "<alertId>" }.
Inputs: alertId (required), accountId (required).
authenticateA
Authenticate with Interactive Brokers. Usage: { "confirm": true }.
Inputs: confirm (required).
confirm_orderB
Manually confirm an order that requires confirmation. Usage: { "replyId": "742a95a7-55f6-4d67-861b-2fd3e2b61e3c", "messageIds": ["o10151", "o10153"] }.
Inputs: replyId (required), messageIds (required).
create_alertC
Create a new trading alert. Usage: { "accountId": "<id>", "alertRequest": { "alertName": "Price Alert", "conditions": [{ "conidex": "265598", "type": "price", "operator": ">", "triggerMethod": "last", "value": "150" }] } }.
Inputs: accountId (required), alertRequest (required).
delete_alertC
Delete an alert. Usage: { "accountId": "<id>", "alertId": "<alertId>" }.
Inputs: alertId (required), accountId (required).
get_account_infoB
Get account information and balances. Usage: { "confirm": true }.
Inputs: confirm (required).
get_alertsC
Get all trading alerts for an account. Usage: { "accountId": "<id>" }.
Inputs: accountId (required).
get_live_ordersA
Get all live/open orders for monitoring and validation. Usage: {} for all accounts or { "accountId": "<id>" } for a specific account. This is the recommended way to validate that market orders were executed successfully after placing them.
Inputs: accountId.
get_market_dataA
Get real-time market data. Usage: { "symbol": "AAPL" } or { "symbol": "AAPL", "exchange": "NASDAQ" }.
Inputs: symbol (required), exchange.
get_option_chainA
Get option expirations and strikes for an underlying symbol. Usage: { "symbol": "AAPL" } or { "symbol": "AAPL", "exchange": "SMART" }.
Inputs: symbol (required), exchange.
get_order_statusA
Get the status of a specific order. Usage: { "orderId": "12345" }.
Inputs: orderId (required).
get_positionsC
Get current positions. Usage: {} or { "accountId": "<id>" }.
Inputs: accountId (required).
place_orderA
Place a trading order. Examples:
Market buy:
{ "accountId":"abc","symbol":"AAPL","action":"BUY","orderType":"MKT","quantity":1 }Limit sell:
{ "accountId":"abc","symbol":"AAPL","action":"SELL","orderType":"LMT","quantity":1,"price":185.5 }Stop sell:
{ "accountId":"abc","symbol":"AAPL","action":"SELL","orderType":"STP","quantity":1,"stopPrice":180 }Option buy:
{ "accountId":"abc","symbol":"AAPL","secType":"OPT","expiry":"JAN27","strike":200,"right":"C","action":"BUY","orderType":"LMT","quantity":1,"price":4.5 }Option by conid:
{ "accountId":"abc","conid":123456789,"secType":"OPT","action":"BUY","orderType":"MKT","quantity":1 }Suppress confirmations:
{ "accountId":"abc","symbol":"AAPL","action":"BUY","orderType":"MKT","quantity":1,"suppressConfirmations":true }
Inputs: action (required), quantity (required), accountId (required), orderType (required), +11 more.
resolve_option_conidA
Resolve a specific option contract conid. Usage: { "symbol": "AAPL", "expiry": "JAN27", "strike": 200, "right": "C" } or add { "exchange": "SMART" }.
Inputs: right (required), expiry (required), strike (required), symbol (required), +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Most tools have distinct purposes (alerts vs orders vs account data), but get_live_orders and get_order_status could be confused since both relate to order monitoring. get_alerts vs create/activate/delete_alert are clear, and get_option_chain vs resolve_option_conid are related but distinct enough.
The naming follows a consistent verb_noun pattern (get_, create_, activate_, delete_, place_, confirm_). Minor deviation: 'authenticate' lacks a noun object, and 'resolve_option_conid' is slightly more verbose than the others, but overall the pattern is predictable.
14 tools is well-scoped for a trading platform server covering authentication, account info, market data, orders, and alerts. Each tool addresses a distinct workflow need without excessive overlap or bloat.
The server covers core trading workflows: authentication, account/position queries, market data, order placement/status/confirmation, and alert lifecycle (create, activate, delete, list). Missing order cancellation/modification and position closing are notable gaps, but the primary use cases are covered.
Maintenance
Related MCP Connectors
Connect brokerage accounts to AI assistants: holdings, orders, asset lookup, and approved trading.
Unified financial infrastructure connecting AI agents directly to trade live/demo brokerage accounts, Web3 non-custodial wallets, real-time market data across equities, ETFs, crypto, forex, options, DeFi swaps, and prediction markets, institutional research feeds, and algorithmic strategy backtesters.
AI agents backtest, paper trade and live trade via your broker. Free to connect; OAuth.
Send trade alerts from AI agents to your broker: stocks, options, futures, crypto and perps.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI models with secure access to Interactive Brokers trading data and functionality, enabling account management, market data retrieval, and trading operations through natural language interactions.18MIT
- FlicenseNot gradedqualityDmaintenanceConnects AI assistants to Interactive Brokers for intelligent portfolio management, options analysis, risk monitoring, and automated trading strategy suggestions. Enables real-time account tracking, Greeks calculations, option chain analysis, and playbook-based risk adjustments through natural language.5-
- AlicenseAqualityDmaintenanceEnables AI agents to trade on Interactive Brokers: check quotes, balance, positions, and execute buy/sell orders (including fractional shares by dollar amount) via the Client Portal API.2015MIT
- AlicenseAqualityDmaintenanceEnables LLM agents to interact with Interactive Brokers accounts for market data, account info, and order entry with built-in risk controls and a two-step confirmation flow.9MIT