Skip to main content
Glama

MetaTrader 5 (MT5) MCP Server & Web GUI Workstation

Python 3.10+ MCP MetaTrader 5 License: MIT

Windows上のMetaTrader 5向けの高性能Model Context Protocol (MCP)サーバーおよびインタラクティブなWeb GUI Workstationです。このプロジェクトは、AIアシスタント(Antigravity、Claude Desktop、Cursorなど)とクオンツトレーダーを、ローカルのMT5インストールに直接接続して、以下を可能にします:

  1. 履歴マーケットデータの取得(M1–MN1のタイムフレームにわたるOHLCVバーとミリ秒精度のティックストリーム)を、高速なParquetおよびCSVエクスポート機能付きで提供します。

  2. ストラテジーバックテストの実行を、内蔵のPythonクオンツエンジンとネイティブMT5ストラテジーテスターの自動化(terminal64.exe /config:tester.ini)を通じて行います。

  3. デモ口座のステータス、エクイティカーブ、アクティブな銘柄、マーケットウォッチの気配値、およびオープンポジションを確認できます。

  4. インタラクティブな金融Web GUI:TradingView Lightweight Charts、リアルタイムテレメトリー、エクイティカーブ可視化機能付きStrategy Studio、アカウントログインマネージャーで構成されています。

  5. 厳格な取引安全ガード:デモおよびライブ注文が明示的な確認なしには実行されないようにします。


アーキテクチャ概要

 ┌────────────────────────────────────────────────────────┐
 │                      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:インタラクティブなタイムフレーム選択(M1M5M15M30H1H4D1)対応の滑らかなローソク足・出来高チャート。

  • 📈 Strategy Backtest Studio:ストラテジーパラメータ(SMA CrossoverRSI ReversalBollinger 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_connect

path, login, password, server

MT5ターミナルへの接続を初期化するか、特定のデモ口座にログインします。

mt5_account_summary

None

デモ口座の残高、純資産、レバレッジ、有効証拠金、および損益を返します。

mt5_terminal_info

None

MT5ビルドバージョン、接続状態、ping、およびデータディレクトリを返します。

2. マーケット探索と履歴データ

ツール

パラメータ

説明

mt5_get_symbols

group(例:*USD*

ワイルドカードフィルタリングを使用して利用可能な銘柄を検索します。

mt5_symbol_details

symbol(例:EURUSD

契約仕様(スプレッド、ポイント、桁数、スワップレート)を返します。

mt5_symbol_current_tick

symbol

リアルタイムのBid、Ask、最終価格を取得します。

mt5_fetch_historical_bars

symbol, timeframe, count, date_from, date_to, export_format

タイムフレーム(M1 から MN1)にわたる履歴OHLCVデータを抽出し、オプションでParquet/CSVエクスポートを行います。

mt5_fetch_ticks

symbol, count, date_from, date_to, export_format

ミリ秒精度のティックストリームを抽出し、オプションでParquet/CSVエクスポートを行います。

3. ストラテジーテストとシミュレーション

ツール

パラメータ

説明

mt5_list_backtest_strategies

None

内蔵バックテストモデル(sma_crossoverrsi_reversalbollinger_bands)を一覧表示します。

mt5_run_strategy_backtest

symbol, timeframe, strategy_name, bars_count, initial_cash, lot_size, params

履歴MT5データでバックテストを実行し、シャープレシオ、最大ドローダウン%、勝率%、プロフィットファクター、取引ログを返します。

mt5_run_native_tester

expert_name, symbol, period, deposit, currency, leverage, model, from_date, to_date, visual

生成された.ini設定とヘッドレスterminal64.exe実行を使用して、ネイティブMT5ストラテジーテスターを自動化します。

4. ポジションと取引(保護付き)

ツール

パラメータ

説明

mt5_get_open_positions

symbol(オプション)

デモ口座のオープンポジションを一覧表示します。

mt5_get_order_history

days, symbol(オプション)

決済済みの約定と履歴注文の実行を一覧表示します。

mt5_place_demo_order

symbol, order_type, volume, sl, tp, explicit_user_approval

explicit_user_approval=Trueを要求する厳格な安全ガード付きでデモ注文を発注します。


テストの実行

接続性、履歴データ抽出、クオンツバックテスター、およびGUI REST APIを検証する包括的なpytestスイートを実行します:

.venv\Scripts\pytest -v

ライセンス

MIT License.

F
license - not found
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • F
    license
    -
    quality
    D
    maintenance
    Enables AI applications to interact with MetaTrader 5 terminals via WebSocket MCP protocol for trading operations and account management.
    4
  • A
    license
    -
    quality
    A
    maintenance
    Exposes 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
  • A
    license
    -
    quality
    A
    maintenance
    Enables AI assistants to trade on MetaTrader 5 using natural language, supporting account management, order placement, and real-time market data.
    1
    MIT
  • A
    license
    -
    quality
    C
    maintenance
    A 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

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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