mt5-mcp
MetaTrader 5 (MT5) MCP Server & Web GUI Workstation
Windows上のMetaTrader 5向けの高性能Model Context Protocol (MCP)サーバーおよびインタラクティブなWeb GUI Workstationです。このプロジェクトは、AIアシスタント(Antigravity、Claude Desktop、Cursorなど)とクオンツトレーダーを、ローカルのMT5インストールに直接接続して、以下を可能にします:
履歴マーケットデータの取得(M1–MN1のタイムフレームにわたるOHLCVバーとミリ秒精度のティックストリーム)を、高速なParquetおよびCSVエクスポート機能付きで提供します。
ストラテジーバックテストの実行を、内蔵のPythonクオンツエンジンとネイティブMT5ストラテジーテスターの自動化(
terminal64.exe /config:tester.ini)を通じて行います。デモ口座のステータス、エクイティカーブ、アクティブな銘柄、マーケットウォッチの気配値、およびオープンポジションを確認できます。
インタラクティブな金融Web GUI:TradingView Lightweight Charts、リアルタイムテレメトリー、エクイティカーブ可視化機能付きStrategy Studio、アカウントログインマネージャーで構成されています。
厳格な取引安全ガード:デモおよびライブ注文が明示的な確認なしには実行されないようにします。
アーキテクチャ概要
┌────────────────────────────────────────────────────────┐
│ AI Client │
│ (Antigravity / Claude Desktop / Cursor) │
└───────────────────────────┬────────────────────────────┘
│ MCP Protocol (stdio)
┌───────────────────────────▼────────────────────────────┐
│ MT5 MCP Server (Python) │
│ - FastMCP Server (`src/mt5_mcp/server.py`) │
│ - Data Caching & Parquet/CSV Export Engine │
│ - Quantitative Strategy Backtesting Engine │
└─────────────┬────────────────────────────┬─────────────┘
│ │
┌─────────────▼──────────────┐ ┌──────────▼─────────────┐
│ MetaTrader5 Python API │ │ MT5 Native Tester Auto │
│ - copy_rates_range() │ │ - tester.ini builder │
│ - copy_ticks_range() │ │ - terminal64.exe CLI │
│ - account_info() / login()│ │ - Report XML/HTML │
└─────────────┬──────────────┘ └──────────┬─────────────┘
│ │
┌─────────────▼────────────────────────────▼─────────────┐
│ MetaTrader 5 Windows Terminal │
│ (Demo Account Connected) │
└────────────────────────────────────────────────────────┘Related MCP server: Meta-Trader-MCP
インストールと前提条件
1. 要件
Windows 10 / 11 (64-bit)
MetaTrader 5 デスクトップターミナルがインストールされていること
Python 3.10, 3.11, or 3.12 (64-bit)
uv(推奨)または標準のpip
2. MT5でアルゴリズム取引を有効にする
MetaTrader 5ターミナルで次の操作を行います:
ツール -> オプション -> エキスパートアドバイザー の順に移動します。
アルゴリズミック取引を許可にチェックを入れます。
DLLインポートを許可にチェックを入れます(カスタムインジケーターで必要な場合)。
3. 仮想環境のセットアップ
# Clone the repository
git clone https://github.com/remomein05/mt5-mcp.git
cd mt5-mcp
# Create virtual environment and install dependencies
uv venv --python 3.12 .venv
.venv\Scripts\activate
uv pip install -e ".[dev]"Web GUI Workstation(インタラクティブダッシュボード)
このリポジトリには、TradingViewチャート、リアルタイムマーケットウォッチ、ストラテジーバックテストスタジオ、アカウント管理を備えた、金融グレードの専用Web GUIダッシュボードが含まれています:
# Launch via console script
mt5-mcp-gui
# Or launch via Python module
.venv\Scripts\python -m mt5_mcp.gui --port 8000次に、ブラウザで**http://127.0.0.1:8000**を開きます。
GUI機能:
📊 TradingView Lightweight Charts:インタラクティブなタイムフレーム選択(
M1、M5、M15、M30、H1、H4、D1)対応の滑らかなローソク足・出来高チャート。📈 Strategy Backtest Studio:ストラテジーパラメータ(
SMA Crossover、RSI Reversal、Bollinger Bands)を設定し、シミュレーションを実行して、エクイティ成長曲線、KPI(シャープレシオ、最大ドローダウン%、勝率%)、および決済済み取引ログを確認できます。📦 Historical Data Exporter:ローソク足データをParquetおよびCSVファイルにワンクリックですぐに抽出できます。
🔍 Market Watch:ワイルドカード検索(例:
*USD*、Crypto*)によるリアルタイムの銘柄探索と、ライブの変動スプレッドインジケーター。⚙️ MT5 Connect & Account Login Modal:アクティブなMT5ターミナルにシームレスに接続するか、カスタムのログインID、パスワード、ブローカー/サーバー、およびオプションの実行ファイルパスを使用して任意のデモ口座に切り替え/ログインできます(Enterキーで送信、Escキーで閉じる)。
📋 Open Positions & Native MT5 Tester Panel:オープン中の取引を表示し、バッチ
.ini設定を使用してネイティブMQL5エキスパートアドバイザーをヘッドレスで自動化します。
MCPクライアント設定
Claude Desktop / Antigravity / Cursor (mcp_config.json)
MT5 MCPサーバーをMCPクライアント設定に追加します:
{
"mcpServers": {
"mt5": {
"command": "C:\\Users\\<USER>\\source\\repos\\mt5_mcp\\.venv\\Scripts\\python.exe",
"args": [
"-m",
"mt5_mcp.server"
],
"env": {
"PYTHONUNBUFFERED": "1"
}
}
}
}利用可能なMCPツール
1. 接続とアカウント管理
ツール | パラメータ | 説明 |
|
| MT5ターミナルへの接続を初期化するか、特定のデモ口座にログインします。 |
| None | デモ口座の残高、純資産、レバレッジ、有効証拠金、および損益を返します。 |
| None | MT5ビルドバージョン、接続状態、ping、およびデータディレクトリを返します。 |
2. マーケット探索と履歴データ
ツール | パラメータ | 説明 |
|
| ワイルドカードフィルタリングを使用して利用可能な銘柄を検索します。 |
|
| 契約仕様(スプレッド、ポイント、桁数、スワップレート)を返します。 |
|
| リアルタイムのBid、Ask、最終価格を取得します。 |
|
| タイムフレーム( |
|
| ミリ秒精度のティックストリームを抽出し、オプションでParquet/CSVエクスポートを行います。 |
3. ストラテジーテストとシミュレーション
ツール | パラメータ | 説明 |
| None | 内蔵バックテストモデル( |
|
| 履歴MT5データでバックテストを実行し、シャープレシオ、最大ドローダウン%、勝率%、プロフィットファクター、取引ログを返します。 |
|
| 生成された |
4. ポジションと取引(保護付き)
ツール | パラメータ | 説明 |
|
| デモ口座のオープンポジションを一覧表示します。 |
|
| 決済済みの約定と履歴注文の実行を一覧表示します。 |
|
|
|
テストの実行
接続性、履歴データ抽出、クオンツバックテスター、およびGUI REST APIを検証する包括的なpytestスイートを実行します:
.venv\Scripts\pytest -vライセンス
MIT License.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceEnables AI applications to interact with MetaTrader 5 terminals via WebSocket MCP protocol for trading operations and account management.4
- Alicense-qualityAmaintenanceExposes a unified AI interface to MetaTrader 5 over the Model Context Protocol, enabling live quotes, historical data, technical indicators, order execution, position management, and headless backtests.MIT
- Alicense-qualityAmaintenanceEnables AI assistants to trade on MetaTrader 5 using natural language, supporting account management, order placement, and real-time market data.1MIT
- Alicense-qualityCmaintenanceA local-first MCP server that bridges AI coding agents with MetaTrader 5 for inspection, market data, MQL5 development, compiling, Strategy Tester review, workspace sync, logs, audit trails, demo trading, and carefully gated live trading.MIT
Related MCP Connectors
Connect any MCP client to MetaTrader 4/5 to read prices, manage positions, and place trades.
MCP server exposing the Backtest360 engine API as tools for AI agents.
Build, backtest, and deploy quantitative trading strategies from your AI agent.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/remomein05/mt5-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server