MT5 MCP Server
MT5 MCP サーバー
MetaTrader 5 ターミナルを Claude に接続するローカル MCP サーバーです。 市場データ、口座状態、履歴の読み取り、チャートのスクリーンショット取得、 さらにライブ注文の送信が可能です。
必要条件
MetaTrader 5 ターミナルが起動している必要があります
ツール → オプション → エキスパートアドバイザー → 「アルゴリズミックトレーディングを許可」 が有効である必要があります
口座にログインしている必要があります
ターミナルが閉じている場合、すべてのツールは MT5 initialize failed を返します。ターミナルを開いて再試行してください。
Related MCP server: metatrader-mcp
インストール
uv venv --python 3.12 .venv
uv pip install --python .venv/Scripts/python.exe -r requirements.txt次に、.mcp.json 内のパスを調整し、Claude Code を再起動します。
ツール(20)
市場データ
ツール | 機能 |
| ターミナルのビルド、接続状態、口座、残高、純資産、証拠金、DEMO/REAL |
| 銘柄の検索 — ワイルドカード対応( |
| 桁数、ポイント、スプレッド、契約サイズ、ロット制限、証拠金・スワップレート |
| 1つ以上の銘柄のリアルタイム bid/ask とスプレッド |
| M1 から MN1 までの OHLCV、本数指定または日付範囲指定 |
| 生の bid/ask ティックストリーム。バックテストに有用 |
口座
ツール | 機能 |
| 保有ポジションと合計変動損益 |
| 有効な指値・逆指値注文 |
| 利益、手数料、スワップ合計を含む約定履歴 |
| 発注、キャンセル、拒否された注文の履歴 |
| 送信前の証拠金と予想利益の計算(注文は発注されません) |
画面キャプチャ
ツール | 機能 |
| 開いているチャート(銘柄、時間足、サイズ) |
| ターミナルウィンドウまたは単一チャートの PNG |
screenshot は MetaTrader5 Python API によるものではありません。この API には
スクリーンショット機能がまったく存在しません。Windows の PrintWindow 呼び出しに基づいて
構築されています(mt5_capture.py)。バックグラウンドウィンドウでは動作しますが、
最小化されたウィンドウでは動作しません。
ターミナル全体の場合は target='window' を、単一チャートの場合は target='XAUUSD,M30' を
渡します。'XAUUSD' のみを渡すと、その銘柄の最も大きなチャートが選択されます。
トレーディング — ライブ
ツール | 機能 |
| 成行き買い/売り、SL/TP は絶対価格またはポイントで指定 |
| 買い/売り指値または逆指値、有効期限の指定も可能 |
| 保有ポジションの SL/TP 変更 |
| 未約定注文の価格、SL、TP の変更 |
| 全量または一部決済 |
| 未約定注文の削除 |
| 全ポジション、または特定銘柄のみの決済 |
⚠️ トレーディングツールにはデモ/リアル口座のガードはありません。注文は ターミナルがログインしている口座に送信されます。ブローカーの約定モードは 自動的に検出され、必要に応じて銘柄が Market Watch に追加されます。
CLI(trade.py)
Claude を使わずに、コマンドラインから直接同じツールを使用できます:
.venv/Scripts/python.exe trade.py buy XAUUSD 0.01 --sl-points 500 --tp-points 1000
.venv/Scripts/python.exe trade.py modify 10090941191 --sl 4345.56 --tp 4360.56
.venv/Scripts/python.exe trade.py close 10090941191
.venv/Scripts/python.exe trade.py close-all --symbol XAUUSD
.venv/Scripts/python.exe trade.py positions
.venv/Scripts/python.exe trade.py calc buy XAUUSD 0.01 --close-price 4360各サブコマンドの詳細は trade.py --help を実行してください。
時刻形式
すべての時刻入力は UTC です:YYYY-MM-DD、YYYY-MM-DD HH:MM、または
YYYY-MM-DD HH:MM:SS。出力タイムスタンプも UTC です。
設定
以下の環境変数は .mcp.json 内でオプションです:
変数 | 目的 |
|
|
| 別の口座にログイン(デフォルト:ターミナルがすでに使用している口座) |
スモークテスト
.venv/Scripts/python.exe -c "import mt5_mcp_server as s; print(s.mt5_status()['account'])"Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Read-only access to your MetaTrader 4 and 5 accounts for AI agents: balances, open positions, trade history with win rate, live quotes, symbol specs and candles. It cannot place, modify or close orders.
Read and trade MT5 accounts, read-only unless you allow, plus MarketLabs calendar, COT and research.
ChartGaze is a service that connects AI assistants to live and historical market data and, with your authorization, to trading-account information and trading actions. It works with MCP-compatible AI tools and supports platforms such as MT5, MT4, cTrader, and crypto exchanges.
Read-only MetaTrader 5 for AI agents: balances, positions, history and prices. Sign in with OAuth.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables comprehensive access to the MetaTrader 5 trading platform for retrieving market data, managing accounts, and executing trading operations. It provides 32 specialized tools for interacting with MT5 functionalities, including historical OHLCV data access, real-time position monitoring, and automated order management.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables users to capture real MetaTrader 5 chart snapshots with custom indicators and fetch market data through natural language in Claude Desktop.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables interaction with MetaTrader 5 for market data, technical analysis, Fibonacci calculations, and trading via MCP clients such as Claude.MIT
- AlicenseAqualityDmaintenanceEnables Claude AI to perform forex trading operations and market data analysis through MetaTrader 5, including order placement, position management, and multi-timeframe candle data retrieval.16MIT