Skip to main content
Glama
tradingmavenfx-cmd

MT5 MCP Server

MT5 MCP サーバー

MetaTrader 5 ターミナルを Claude に接続するローカル MCP サーバーです。 市場データ、口座状態、履歴の読み取り、チャートのスクリーンショット取得、 さらにライブ注文の送信が可能です。

必要条件

  1. MetaTrader 5 ターミナルが起動している必要があります

  2. ツール → オプション → エキスパートアドバイザー → 「アルゴリズミックトレーディングを許可」 が有効である必要があります

  3. 口座にログインしている必要があります

ターミナルが閉じている場合、すべてのツールは 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)

市場データ

ツール

機能

mt5_status

ターミナルのビルド、接続状態、口座、残高、純資産、証拠金、DEMO/REAL

list_symbols

銘柄の検索 — ワイルドカード対応(EUR*、*USD*)

symbol_info

桁数、ポイント、スプレッド、契約サイズ、ロット制限、証拠金・スワップレート

get_ticks

1つ以上の銘柄のリアルタイム bid/ask とスプレッド

get_candles

M1 から MN1 までの OHLCV、本数指定または日付範囲指定

get_tick_history

生の bid/ask ティックストリーム。バックテストに有用

口座

ツール

機能

get_positions

保有ポジションと合計変動損益

get_pending_orders

有効な指値・逆指値注文

get_history_deals

利益、手数料、スワップ合計を含む約定履歴

get_history_orders

発注、キャンセル、拒否された注文の履歴

calc_trade

送信前の証拠金と予想利益の計算(注文は発注されません)

画面キャプチャ

ツール

機能

list_charts

開いているチャート(銘柄、時間足、サイズ)

screenshot

ターミナルウィンドウまたは単一チャートの PNG

screenshot は MetaTrader5 Python API によるものではありません。この API には スクリーンショット機能がまったく存在しません。Windows の PrintWindow 呼び出しに基づいて 構築されています(mt5_capture.py)。バックグラウンドウィンドウでは動作しますが、 最小化されたウィンドウでは動作しません。

ターミナル全体の場合は target='window' を、単一チャートの場合は target='XAUUSD,M30' を 渡します。'XAUUSD' のみを渡すと、その銘柄の最も大きなチャートが選択されます。

トレーディング — ライブ

ツール

機能

open_position

成行き買い/売り、SL/TP は絶対価格またはポイントで指定

place_pending_order

買い/売り指値または逆指値、有効期限の指定も可能

modify_position

保有ポジションの SL/TP 変更

modify_pending_order

未約定注文の価格、SL、TP の変更

close_position

全量または一部決済

cancel_pending_order

未約定注文の削除

close_all_positions

全ポジション、または特定銘柄のみの決済

⚠️ トレーディングツールにはデモ/リアル口座のガードはありません。注文は ターミナルがログインしている口座に送信されます。ブローカーの約定モードは 自動的に検出され、必要に応じて銘柄が 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 内でオプションです:

変数

目的

MT5_PATH

terminal64.exe へのパス。ターミナルが閉じている場合の起動に使用

MT5_LOGIN / MT5_PASSWORD / MT5_SERVER

別の口座にログイン(デフォルト:ターミナルがすでに使用している口座)

スモークテスト

.venv/Scripts/python.exe -c "import mt5_mcp_server as s; print(s.mt5_status()['account'])"

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables 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.
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables users to capture real MetaTrader 5 chart snapshots with custom indicators and fetch market data through natural language in Claude Desktop.
    3
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with MetaTrader 5 for market data, technical analysis, Fibonacci calculations, and trading via MCP clients such as Claude.
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables 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.
    16
    -