MT5-Quant
MCP server for MT5 strategy development on macOS/Linux. 89 tools to compile, backtest, analyze, optimize, debug crashes, and manage MQL5 Expert Advisors — no Windows required.
You: "Backtest MyEA Jan-Mar, what caused the February drawdown?"
Claude: [compile → clean → backtest → analyze 1,847 deals]
→ Feb 14: BUY grid at L6, locking lot 1.75× base
→ Cutloss fired 17 points later
→ Recommendation: cap locking multiplier to ≤1.2×
Why MT5-Quant
Focus: Backtest organization, reporting, and analytics — capabilities MT5 itself doesn't provide.
Others typically run on Windows using the MetaTrader5 Python package, providing full terminal operations. MT5-Quant fills the gap: organizing backtest reports, extracting deal-level insights, and managing optimization workflows — none of which MT5 or its Python API expose natively.
Quick Start
Install MT5-Quant
Option A — Cargo (recommended, needs Rust toolchain)
cargo install mt5-quant --locked
Option B — Pre-built binaries (no toolchain)
# macOS Apple Silicon
curl -LO https://github.com/masdevid/mt5-quant/releases/latest/download/mcp-mt5-quant-macos-arm64.tar.gz
tar xzf mcp-mt5-quant-macos-arm64.tar.gz # → mcp-mt5-quant-macos/mt5-quant
# Linux x64
curl -LO https://github.com/masdevid/mt5-quant/releases/latest/download/mcp-mt5-quant-linux-x64.tar.gz
tar xzf mcp-mt5-quant-linux-x64.tar.gz # → mcp-mt5-quant-linux/mt5-quant
Move the binary somewhere on your PATH (e.g. /usr/local/bin or ~/.local/bin) so clients can launch it as mt5-quant.
Option C — Register with your LLM client (copy-paste)
Claude Code
claude mcp add mt5-quant -- mt5-quant --stdio
Claude Desktop — ~/Library/Application Support/Claude/claude_desktop_config.json
{ "mcpServers": { "mt5-quant": { "command": "mt5-quant", "args": ["--stdio"] } } }
Cursor — .cursor/mcp.json (same JSON shape as Claude Desktop)
{ "mcpServers": { "mt5-quant": { "command": "mt5-quant", "args": ["--stdio"] } } }
opencode — .opencode/opencode.jsonc
{ "mcp": { "mt5-quant": { "type": "local", "command": ["mt5-quant", "--stdio"], "enabled": true } } }
Codex CLI — ~/.codex/config.toml
[mcp_servers.mt5-quant]
command = "mt5-quant"
args = ["--stdio"]
Then finish setup (auto-detects Wine + MT5 paths):
bash scripts/setup.sh
Tip: you can also just ask your LLM coding agent to do all of the above: "Please install mt5-quant from https://github.com/masdevid/mt5-quant — download or build it, run its
scripts/setup.shto auto-detect Wine and MT5 paths, and register it as an MCP server."
First Backtest
Run a backtest on MyEA from 2025.01.01 to 2025.03.31
The AI runs the full pipeline: compile → clean cache → backtest → extract → analyze.
MCP Tools (89)
Core workflow
Granular Analytics (individual analysis)
Use these for targeted analysis, or analyze_report to run all at once.
Deal-Level Analytics (New)
Monitoring
Reports & logs
History & baseline
Cache management
Pre-flight & Validation
Debugging & Diagnostics (New)
Project Management
History & Comparison
.set file — read / write
.set file — analysis & generation
Search & Discovery
Full schema: docs/MCP_TOOLS.md
Troubleshooting
Run verify_setup from your LLM first — it checks all paths and returns actionable hints.
For crashes or unexplained failures during backtest/compile/optimization:
diagnose_wine— Check Wine installation and prefix healthsearch_mt5_errors— Find crash causes in logscheck_mt5_process+kill_mt5_process— Detect and kill stuck processesget_backtest_crash_info— Investigate failed backtest reports
Documentation
Full index with reading order: docs/INDEX.md
Acknowledgements
MT5-Quant stands on the shoulders of exceptional open-source projects:
- Rust — The language that makes zero-cost abstractions, memory safety, and fearless concurrency practical
- Tokio — The async runtime powering all concurrent operations
- Wine — Making MT5 execution possible on macOS and Linux without Windows licensing
- MetaTrader 5 — MetaQuotes' trading platform (trademark of MetaQuotes Software Corp.)
- rusqlite — Ergonomic SQLite bindings for Rust
- serde — The serialization framework making config and report handling painless
- scraper — HTML parsing for MT5 report extraction
- tempfile — Secure temporary file handling
Special thanks to the Model Context Protocol (MCP) team at Anthropic for defining the standard that makes AI-powered development workflows possible.
Disclaimer
Not Financial Advice. MT5-Quant is a development and analysis tool for algorithmic trading strategies. It does not provide investment advice, trading recommendations, or guarantee profitability. All backtest results are historical simulations and do not guarantee future performance.
Use at Your Own Risk. Trading financial instruments carries substantial risk of loss. The authors and contributors of MT5-Quant accept no liability for:
- Trading losses incurred using strategies developed or tested with this tool
- Data loss or corruption from backtest operations
- Bugs, errors, or incorrect analysis results
- System crashes, Wine compatibility issues, or MT5 failures
Software Warranty. This software is provided "as-is" without warranty of any kind, express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, or non-infringement. See LICENSE for full terms.
Third-Party Software. MT5-Quant interacts with MetaTrader 5, Wine, and other third-party software. Users are responsible for complying with all applicable licenses and terms of service for these dependencies. MetaTrader is a trademark of MetaQuotes Software Corp. MT5-Quant is not affiliated with, endorsed by, or sponsored by MetaQuotes.
Regulatory Compliance. Users are responsible for ensuring their trading activities comply with applicable financial regulations in their jurisdiction. Automated trading may be restricted or require licensing in some regions.
License
MIT