MT5 MCP Server
Click on "Install 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 ServerRun a multi-symbol backtest on my GoldScalper EA"
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 Server v2.1
37-tool MCP server for MetaTrader 5 β the most complete LLM-to-MT5 bridge. Full autonomous pipeline from strategy description to PDF report, with proper risk metrics (Sharpe, Sortino, Calmar) and validation checks. Write EAs, compile, backtest, optimize, Monte Carlo, Kelly sizing, live trade, monitor portfolio β all through MCP.
Highlights
π€ Autonomous Pipeline β Describe a strategy β get a complete PDF report with Monte Carlo, Kelly, risk metrics
π 37 MCP tools β every MT5 operation available to LLMs
π Proper Risk Metrics β Annualized Sharpe, Sortino, Calmar with sanity checks
π΄ Live Trading β Place orders, manage positions, monitor portfolio from any LLM
Related MCP server: OpenFinClaw CLI
Tools Overview (37)
π Backtest & Optimization (5)
Tool | Description |
| Single backtest with full parameter control |
| Genetic/complete parameter optimization |
| Test EA on multiple symbols, aggregate results |
| Parse tester log into structured trade data |
| Read .opt files with best passes |
βοΈ EA Development (6)
Tool | Description |
| Write/update .mq5 source (auto-compile) |
| Compile .mq5 β .ex5 via MetaEditor |
| Read full MQL5 source |
| Extract all input params with types/defaults |
| List all installed EAs |
| Raw tester log for debugging |
π Advanced Analytics (6)
Tool | Description |
| 1000-sim robustness with P5/P95 confidence |
| Rolling OOS validation, overfitting detection |
| Kelly Criterion, Optimal F, Risk of Ruin |
| Expectancy, Z-score, streaks |
| v2.1 Sharpe, Sortino, Calmar + validation |
| Export results to CSV |
π΄ Live Trading (6)
Tool | Description |
| Market & pending orders (buy/sell/limit/stop) |
| Open positions with real-time P&L |
| Close by ticket or close all |
| Modify SL/TP on open positions |
| Balance, equity, margin, leverage |
| Historical deals with P&L |
π Portfolio Management (7)
Tool | Description |
| 0-100 score + verdict + recommendations |
| Correlation matrix, diversification score |
| Markowitz optimal weights, max Sharpe |
| Equal risk, Kelly, inverse-DD allocation |
| Live P&L, concentration, margin |
| Convert results to returns series |
| Connection and account status |
π€ Autonomous Pipeline (2)
Tool | Description |
| v2.0 Generate MQL5 EA from natural language |
| v2.0 Full auto: CreateβCompileβScreenβCorrelateβOptimizeβMCβKellyβRobustnessβReport |
π‘ Data Access (5)
Tool | Description |
| OHLC bar data for any symbol/timeframe |
| Raw tick data with spread stats |
| All available trading symbols |
| Real-time bid/ask for multiple symbols |
| Spread, swap, margin, tick value |
Quick Start
git clone https://github.com/Boschi404/mt5-mcp-server.git
cd mt5-mcp-server
pip install -r requirements.txtRegister with MCP Client
Hermes Agent:
hermes mcp add mt5-backtest --command "C:/Python311/python" --args "/path/to/server.py" --timeout 600Claude Desktop (claude_desktop_config.json):
{"mcpServers": {"mt5-backtest": {"command": "python", "args": ["/path/to/server.py"]}}}Autonomous Pipeline
One command to run 9 phases:
run_autonomous_pipeline(
strategy_name="GoldBreakout",
strategy_description="Channel breakout M15, EMA50 H4 trend filter, SL 700pts, TP 3000pts"
)Phases:
Create β Generate MQL5 code with all parameters
Compile β Compile to .ex5 + error check
Screen β Test on 15+ major symbols (1M OHLC)
Correlate β Find uncorrelated candidates (0-100 diversification score)
Optimize β Genetic optimization on tick data with fixed risk
Monte Carlo β 1000 simulations, skip 10% random trades
Kelly β Position sizing from real trade stats (max 15% DD)
Robustness β 100 random 6-month backtests
Report β Full HTML report with Sharpe, Sortino, Calmar + validation
Output: Desktop/pipelines/StrategyName_TIMESTAMP/ with organized subfolders per phase.
Risk Metrics (v2.1)
get_risk_metrics computes proper risk-adjusted returns:
Metric | Formula |
Sharpe | (Return β RiskFree) / StdDev Γ βPeriods |
Sortino | (Return β RiskFree) / DownsideStdDev Γ βPeriods |
Calmar | AnnualizedReturn / MaxDrawdown |
Automatic validation checks:
Sharpe > 10? β β οΈ WARNING: suspiciously high
Sortino >> Sharpe? β β Positive skew confirmed
Profit Factor > 100? β β οΈ WARNING: likely look-ahead bias
Win Rate > 95%? β β οΈ WARNING: survivorship bias
Example Workflows
Full Pipeline (EA β Live)
1. build_strategy_code("Channel breakout, SL 700, TP 3000") β get MQL5 code
2. write_expert("GoldScalper", code) β save + compile
3. run_multi_backtest("GoldScalper", ["XAUUSD","DAXEUR","NDQUSDc"]) β screen
4. analyze_portfolio_diversification(returns) β score: 72/100 β
5. run_autonomous_pipeline("GoldScalper") β full auto
6. place_order("XAUUSD", "buy_stop", volume=0.05, ...) β go live
7. get_portfolio_health() β monitorRisk Check
LLM β get_risk_metrics()
β Sharpe: 1.85 (institutional quality)
β Sortino: 3.12 (positive skew)
β Max DD: 8.4%
β Data Quality: GOOD
β Validation: 3 checks passed, 0 warningsArchitecture
mt5-mcp-server/
βββ server.py # MCP server (37 tools)
βββ backtest.py # MT5 tester orchestrator
βββ analytics.py # Monte Carlo, Walk-Forward, Kelly
βββ risk_metrics.py # v2.1 Proper Sharpe/Sortino/Calmar
βββ trading.py # Live order execution
βββ portfolio.py # Correlation, efficient frontier
βββ data.py # Bar/tick data, symbols, prices
βββ batch.py # Multi-symbol testing
βββ pipeline.py # v2.0 Autonomous pipeline orchestrator
βββ strategy_builder.py # v2.0 MQL5 code generator
βββ report_generator.py # v2.0 HTML/PDF report generator
βββ requirements.txtVersion History
Version | Tools | Highlights |
v1.0 | 5 | Basic backtest + log parsing |
v1.1 | 11 | Optimization, EA dev, compilation |
v1.2 | 17 | Monte Carlo, Walk-Forward, Kelly, CSV |
v1.3 | 30 | Live trading, portfolio, data access |
v1.4 | 34 | Batch testing, diversification scoring |
v2.0 | 36 | Autonomous pipeline, strategy builder, PDF reports |
v2.1 | 37 | Proper Sharpe/Sortino/Calmar + validation checks |
License
MIT β use it, fork it, ship it.
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
- MIT
- Flicense-qualityCmaintenanceEnables quant research, strategy generation, backtesting, and paper trading from natural language prompts, integrating with AI agents via an MCP server.Last updated60
- AlicenseAqualityCmaintenanceAn MCP server that exposes trading analytics β technical indicators, portfolio state, risk metrics, and backtest results β as tools an LLM agent can call.Last updated5MIT
- 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.Last updatedMIT
Related MCP Connectors
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for Gainium β manage trading bots, deals, and balances via AI assistants
Connect any MCP client to MetaTrader 4/5 to read prices, manage positions, and place trades.
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/Boschi404/mt5-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server