MT5 MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MT5 MCP Serverget EURUSD current price"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MT5 MCP サーバー
MetaTrader 5 (MT5) と接続し、MCP クライアント(Claude Code / Claude Desktop 等)から マーケットデータ取得・テクニカル分析・フィボナッチ算出・売買発注を行える MCP サーバー。
仕様は docs/specification.md を参照。
必要環境
Windows 10/11(MT5 Python API は Windows 専用)
Python 3.12+
MT5 ターミナルがインストール・ログイン済みであること
発注を使う場合: MT5 で「ツール → オプション → エキスパートアドバイザー → アルゴリズム取引を許可」を有効化
Related MCP server: MetaTrader 5 MCP Server
セットアップ
cd C:\Users\jun\mt5-mcp
py -m pip install -r requirements.txt
copy .env.example .env # 必要に応じて編集MT5 が既にログイン済みなら .env の認証情報は省略可能です。
起動
py -m mt5_mcp.server動作確認(発注なし)
py scripts\smoke_test.py USDJPY全ツールが [OK] になれば正常です。
MCP クライアントへの登録
claude_desktop_config.json などに以下を追加:
{
"mcpServers": {
"mt5": {
"command": "py",
"args": ["-m", "mt5_mcp.server"],
"cwd": "C:\\Users\\jun\\mt5-mcp"
}
}
}注意(発注の有効化): 発注の有効/無効は
.envのMT5_TRADE_ENABLEDで決まります。 ただし OS/クライアントの環境変数が.envより優先されます(load_dotenvの既定動作)。 上記 JSON のenvに"MT5_TRADE_ENABLED": "false"を書くと、.envをtrueにしても読み取り専用になります。 発注を有効にしたい場合はenvでこの変数を指定しない(=.envに従う)か、明示的に"true"を渡してください。 サーバ起動ログに発注ツールを登録しました (MT5_TRADE_ENABLED=true)が出れば有効です。 実際の状態は/healthzのtrade_enabledでも確認できます。
リモート公開(Cloudflare トンネル)
MCP を HTTP で公開し、Cloudflare クイックトンネル経由で claude.ai / Cowork 等から接続できます。
サーバ起動とトンネルを 1つのスクリプトで立ち上げます。cloudflared が PATH 上に必要です。
claude.ai / Cowork に登録する場合(-Cowork モード)
claude.ai のカスタムコネクタは静的 Bearer トークンに非対応で、認証は OAuth のみです。
そのためトークン必須で起動すると、claude.ai が 401 を「OAuth が必要」と解釈してOAuth 認証画面を出します。
これを避けるため、認証なし+推測困難な秘密パスで公開する -Cowork モードを使います:
.\start-remote.ps1 -CoworkBearer 認証を無効化(401 を出さない=OAuth 要求が出ない)
パス未指定なら
/mcp-<ランダム>の秘密パスを自動生成表示された コネクタ URL(
https://<random>.trycloudflare.com/mcp-<random>)をそのまま claude.ai / Cowork のカスタムコネクタに登録(認証は「なし」のまま)
⚠️ セキュリティ:
-Coworkモードはトークンが無いため、URL(ホスト名+秘密パス)を知る者は誰でも接続でき、MT5_TRADE_ENABLED=trueなら実発注も可能です。URL は絶対に共有しないでください。トンネルを再起動すると URL は変わります。閲覧のみで十分なら.envのMT5_TRADE_ENABLED=falseを推奨します。
Bearer トークンで保護する場合(既定モード/curl・Claude Code 等向け)
ヘッダーを送れるクライアント用。Authorization: Bearer <token> で認証します:
$env:MT5_MCP_TOKEN = "<長いランダム文字列>" # 省略時は自動生成
.\start-remote.ps1ローカル動作確認(トンネルなし・healthz/認証チェック)
powershell -ExecutionPolicy Bypass -File scripts\test_http.ps1提供ツール(全27ツール)
カテゴリ | ツール |
接続/口座 |
|
マーケット |
|
ヒストリカル |
|
照会 |
|
指標 |
|
フィボナッチ |
|
複合分析 |
|
発注 ⚠️ |
|
発注系は MT5_TRADE_ENABLED=true のときのみ登録されます。
安全機構(発注ガード)
マスタースイッチ:
MT5_TRADE_ENABLED=false(既定)では発注ツール自体を登録しない二段階確認:
confirm=trueの無い発注はorder_checkによるドライラン(プレビュー)に変換ロット上限:
MT5_MAX_LOT超過を拒否シンボルホワイトリスト:
MT5_ALLOWED_SYMBOLSスリッページ上限:
MT5_MAX_SLIPPAGEを強制適用監査ログ: 全発注操作を
~/.mt5_mcp/trade_audit.logに記録
⚠️ 発注機能は必ずデモ口座で十分に検証してから本番口座で使用してください。
ライセンス / 注意
本ソフトウェアは MIT License のもとで公開されています。
本ソフトウェアは無保証です。自動売買・発注に伴う損失について作者は責任を負いません。
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect any MCP client to MetaTrader 4/5 to read prices, manage positions, and place trades.
Trade 16 crypto exchanges + MetaTrader 5 from your AI assistant via one MCP connection.
Trade across 22+ exchanges and brokers from any MCP-capable AI agent, no install required.
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables access to MetaTrader5 market data and trading functionality, including real-time quotes, historical OHLCV data, tick data, symbol information, and technical indicators for forex and other trading instruments.22MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to connect to MetaTrader 5 for trading, market data access, and account management through the Model Context Protocol.216-
- FlicenseNot gradedqualityCmaintenanceEnables trading on MetaTrader5 platform via MCP, including account management, order placement, market data, technical indicators, and signal tools.4-
- FlicenseAqualityDmaintenanceEnables 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-