Complete MCP server for MT5: Through the MCP protocol, it allows [Trades, Orders, History, Graphic Objects, Terminal Logs, Compilation, etc.]
  • MQL5 69.1%
  • Python 30.1%
  • MQL4 0.8%
Find a file
2026-05-01 17:39:22 +00:00
mt5_mcp_by_leo - Fixed RunBacktest description 2026-04-30 16:14:44 -05:00
Src 2026-05-01 12:23:03 -05:00
.gitignore new files added 2026-04-28 14:43:15 -05:00
dependencies.json Actualizar dependencies.json 2026-04-28 19:51:53 +00:00
FullMt5McpByLeo.mqproj - Fixed RunBacktest description 2026-04-30 16:14:44 -05:00
FUNCTIONS.txt 2026-04-29 21:15:35 -05:00
LICENSE new files added 2026-04-28 12:26:36 -05:00
pyproject.toml - Fixed RunBacktest description 2026-04-30 16:14:44 -05:00
README.md Actualizar README.md 2026-05-01 17:39:22 +00:00

Universal MCP Server for MetaTrader 5 Trading & Data Operations


Overview

FullMt5McpByLeo is a complete, production-ready MCP server that enables Claude and other AI assistants to control MetaTrader 5 directly. Execute trades, retrieve market data, manage charts, analyze trading history, and automate MT5 operations through natural language.


Main Features (MCP Functions)

Trade Operations

Execute and manage trading positions and orders:

  • Open Positions: Execute market trades (buy/sell) with immediate or pending orders
  • Position Management: Modify stops/profits, close positions (full or partial)
  • Order Management: Create, modify, and cancel pending limit/stop orders
  • Trading History: Query completed deals with profit/loss analysis

Market Data & Symbols

Access real-time and historical data:

  • OHLC Data: Retrieve candlestick data (open, high, low, close, volume, spread, etc..)
  • Tick data: Retrieve Tick data (last, ask, bid, flags, etc..)
  • Symbol Information: Get symbol properties (digits, spreads, swaps, volumes)
  • Market Watch: Manage symbol selection and availability

Graphic Objects

Create and modify chart visualizations:

  • Draw Objects: Create trend lines, rectangles, text labels, arrows
  • Object Properties: Modify colors, styles, prices, text
  • Chart Annotations: Add visual markers and indicators to charts

Chart Management

Control chart windows and redraw operations:

  • Chart Operations: Open, close, list active charts
  • Chart Properties: Read chart dimensions, colors, price ranges
  • Visual Updates: Force chart redraw for real-time updates

Code & Terminal

Compile and execute Expert Advisors:

  • Compilation: Compile MQL5 source to EX5 bytecode
  • Backtesting: Run historical tests with multiple tick modeling
  • EA Execution: Run Expert Advisors in real-time
  • Logging: Retrieve EA logs for debugging and monitoring
  • Terminal and Account: Obtaing terminal and acount info_* (integer, string, double)

Repository Structure

FullMt5McpByLeo/
├── Src/                              # MQL5 Backend Functions
│    ....
├── mt5_mcp_by_leo/                   # Python MCP Server
│    ....

Requirements

  • For repo code
  • For user use:

Installation of repo code

cd "C:\Users\YOUR USER\AppData\Roaming\MetaQuotes\Terminal\YOUR ID\MQL5\Shared Projects"
tsndep install "https://forge.mql5.io/nique_372/FullMt5McpByLeo.git"
  • For use tsndep command requerid tsndep pacakage (avaible in pypi).. This command automatically downloads all dependencies and installs all requirements from the repositories.
  • If any part of the system is private, then it will fail... contact me so I can give you access (if it's a product, you can buy it; if you have any questions, don't hesitate to contact me).

Quick Start (for final users)

1. Install Pacakage

pip install mt5-mcp-by-leo

2. Configure Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "mt5_mcp_by_leo": {
      "command": "python",
      "args": ["-m", "mt5_mcp_by_leo", "--host", "127.0.0.1", "--port", "9999"]
    }
  }
}

3. Configure MetaTrader 5

In MT5: ToolsOptionsAllowed URLs for WebRequest

  • Add 127.0.0.1 or host you configured.
  • Click Accept
  • Enable AutoTrading and DLL imports

4. Compile & Attach EA

MetaEditor: Open Src/Mt5Mcp.mq5 → Compile (F5) Or Dowland Mt5Mcp.ex5 of releases (last version).
MT5: Drag Mt5Mcp.ex5 onto your chart and cofigure it, The parameters of the EA, such as port/host, must match the JSON of Claude Desktop

5. Use in Claude

Open a 0.01 lot BUY on EURUSD with SL at 1.0800 and TP at 1.0900

License

Read Full License

By downloading or using this repository, you accept the license terms.


Documentation


Contact


Copyright © 2026 Niquel Mendoza (nique_372).
TSN Trading Systems ecosystem.