mcp-mt5
Model Context Protocol server for the MetaTrader 4/5 build pipeline. Compile MQL sources, deploy compiled EAs, run Strategy Tester, parse reports, tail logs — all driven by an LLM agent without touching the MetaTrader UI.
Power your agent
पब्लिशर का इंस्टॉल। PlugMCP एंडपॉइंट नहीं।
Host a copy with our keys and logs.
रजिस्ट्री में अभी कोई पैकेज्ड रिलीज़ नहीं है। रिपॉज़िटरी का README देखें.
रिमोट URL या आपकी मशीन पर कमांड? दोनों इंस्टॉल में क्या अंतर है
PlugMCP पर चलाएँ
A new server you create. It is not this listing's official endpoint. Use the publisher install when you want their URL and their credentials.
लॉन्चपब्लिशर से
Model Context Protocol server for the MetaTrader 4/5 build pipeline. Compile MQL sources, deploy compiled EAs, run Strategy Tester, parse reports, tail logs — all driven by an LLM agent without touching the MetaTrader UI.
MCP server for MetaTrader 4/5 build pipeline (compile, deploy, backtest, parse reports)
Use case: an LLM agent edits
.mq5source → compiles → deploys → runs Strategy Tester → reads report → adjusts → repeats. No broker login, no human in the loop, no risk of real-money execution.
For runtime trading, pair this with a live-trading MCP — they target different layers and compose well.
27 tools (plus 16 deprecated aliases until 0.6.0) and 2 resource templates. Every tool carries MCP annotations (read-only / destructive hints), a typed output schema and per-parameter descriptions; failures are reported as tool errors, never as a normal result with an error key.
The pre-0.5.0 tool names still work in 0.5.x as thin wrappers whose descriptions start with DEPRECATED. Set MCP_MT5_LEGACY_TOOLS=0 to hide them and shrink the tool catalogue to the 27 tools above.
pip install mcp-mt5
Requires Windows + an installed MetaTrader 4 or 5 terminal.
Most MCP clients accept a JSON entry under mcpServers. The server inherits its configuration from environment variables:
{
"mcpServers": {
"mt5": {
"command": "mcp-mt5",
"env": {
"MT5_INSTALL": "C:\\Program Files\\MetaTrader 5"
}
}
}
}
Refer to your client's documentation for the exact config file location.
Once registered, ask your agent to call env_info:
{
"edition": "mt5",
"install": "C:\\Program Files\\MetaTrader 5",
"terminal_hash": "<32-char-hex-hash>",
"metaeditor": "C:\\Program Files\\MetaTrader 5\\MetaEditor64.exe",
"experts_dir": "C:\\Users\\<you>\\AppData\\Roaming\\MetaQuotes\\Terminal\\<hash>\\MQL5\\Experts",
"issues": []
}
An empty issues array means everything is wired up correctly.
Resolution priority for the MetaTrader install + data folder:
%APPDATA%\MetaQuotes\Terminal\*\origin.txt for a folder whose origin matches MT5_INSTALLThe server can run inside WSL and drive the Windows MetaTrader install through WSL interop.
The install (/mnt/c/Program Files/MetaTrader 5) and the data folder (scanned under
/mnt/*/Users/*/AppData/Roaming/MetaQuotes/Terminal, matched through origin.txt) are
auto-detected; MT5_INSTALL / MT5_DATA override them. Paths handed to MetaEditor/terminal are
translated with wslpath -w automatically. Interop must be enabled
(/etc/wsl.conf [interop] enabled=true, then wsl --shutdown).
Set MT5_EDITION=mt4 and point MT5_INSTALL at your MT4 install. The server switches to metaeditor.exe (32-bit), terminal.exe, and the MQL4/ data tree automatically.
A typical LLM-driven iteration loop:
1. env_info → verify paths
2. compile_and_deploy source="C:\\...\\MyEA.mq5" → 0 errors, .ex5 deployed ✅
3. patch_tester_ini config="tester.ini" updates={
"Tester.Symbol": "EURUSD",
"Tester.FromDate": "2025.01.01",
"TesterInputs.RiskPct": "1.5"
}
4. run_backtest config="tester.ini" wait=true
5. read_tester_report path=<report_path from step 4> → summary.net_profit = 1234.56
summary.profit_factor = 1.45
6. tail_log mode="tester" lines=200 structured=true → diagnose journal warnings
7. <edit Signal.mqh based on findings>
8. → loop back to step 2
tester.ini; Launch: terminal64.exe /config:tester.ini
; Period codes: M1=1, M5=5, M15=15, H1=16385, H4=16388, D1=16408
; Model: 0=Every tick, 1=1 min OHLC, 4=Real ticks
[Tester]
Expert=MyEA
Symbol=EURUSD
Period=M15
Model=1
FromDate=2024.01.01
ToDate=2024.12.31
Deposit=10000
Currency=USD
Leverage=500
Visual=0
ShutdownTerminal=1 ; required so run_backtest can wait for the run to finish
Report=tester_report
[TesterInputs]
; ParamName=value||start||step||stop||(N=fixed|Y=optimize)
; RiskPct=1.0||0.1||0.1||3.0||N
A more complete sample lives at examples/tester.ini.
git clone https://github.com/PHUICMT/mcp-mt5
cd mcp-mt5
pip install -e ".[dev]"
pytest # runs the test suite (no MetaTrader needed)
ruff check src tests # lints
CI runs on Windows for Python 3.10, 3.11, and 3.12 against every push to main. Tagging a release (e.g. v0.2.0) triggers an OIDC publish to PyPI.
mcp-mt5/
├── src/mcp_mt5/
│ ├── server.py # FastMCP tool definitions
│ ├── paths.py # Layout detection + origin.txt scan
│ ├── parsers.py # Compile log, tester report/journal parsers, encoding helpers
│ ├── analysis.py, lint.py, formatting.py, refactor.py, ast_refactor.py
│ ├── optimization.py # .opt cache reader (documented TesterOptCache layout)
│ ├── reports.py, snapshot.py, smoke.py, workdir.py
├── tests/ # pytest suite, no live MT5 required
├── examples/ # Sample tester.ini + client config
└── .github/workflows/ # CI + PyPI release
Tester/cache/*.opt) are parsed with the layout MetaQuotes published in MQL5 Programming for Traders. Files with an unrecognised record layout are reported as such rather than guessed.All v0.3.x roadmap items shipped in v0.4.0. Future ideas:
extract_function (current implementation is brace-counting + regex)MIT © 2026 PHUICMT
MCP server for MetaTrader 4/5 build pipeline (compile, deploy, backtest, parse reports)
टूल
अभी टूल सूची नहीं है। रिमोट सर्वर को पहले हेल्थ चेक के बाद सूची मिलती है।
FAQ
इस पेज पर Cursor, Claude Desktop, Claude Code या VS Code के लिए stdio कॉन्फ़िग कॉपी करें। यह पब्लिशर का इंस्टॉल इस्तेमाल करता है, PlugMCP प्रॉक्सी नहीं।
इस रिकॉर्ड में कोई ज़रूरी एनवायरनमेंट वेरिएबल दर्ज नहीं है।
MCP Mt5 stdio पर लोकल चलता है।
पिछली जाँच 2026-10-28 को हुई। MCP server for MetaTrader 4/5 build pipeline (compile, deploy, backtest, parse reports)