Skip to main content

Complete MCP server for MT5: Through the MCP protocol, it allows [Trades, Orders, History, Graphic Objects, Terminal Logs, Compilation, etc.]

Project description

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

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)
  • 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

Quick Start

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) 
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

Notes:

  • To run backtests, you need to add the ea Runner.ex5 (from releases) to any chart.

5. Use in Claude

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

Repository Structure

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

Requirements

  • Python >= 3.10
  • Dependencies listed in dependencies.json (or sub-dependencies of this repo)

Installation

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).

Available Tools

Trade Operations (19 Functions)

  • Opening: open_trade, open_limit, open_stop
  • Management: position_list, position_get_* (double/integer/string), position_close, position_modify
  • Orders: order_list, order_close, order_modify, order_get_* (double/integer/string)
  • History: history_deal_list, history_deal_get_* (double/integer/string)

Market Data & Symbols (10 Functions)

  • OHLC: copy_open, copy_high, copy_low, copy_close, copy_tick_volume
  • Symbols: symbol_info_* (double/integer/string), symbol_select, symbols_total

Graphic Objects (5 Functions)

  • object_create, object_delete, object_integer, object_double, object_string

Chart Management (6 Functions)

  • chart_list, chart_open, chart_close, chart_get_integer, chart_get_double, chart_redraw

Code & Terminal (4 Functions)

  • compile_mql5, execute_backtest, run_ea, get_expert_logs

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mt5_mcp_by_leo-1.0.1.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mt5_mcp_by_leo-1.0.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file mt5_mcp_by_leo-1.0.1.tar.gz.

File metadata

  • Download URL: mt5_mcp_by_leo-1.0.1.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for mt5_mcp_by_leo-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6d6c3bf80f2c0da071e30b1c32b82196df22b516646e13e943ff4eacecd53ee0
MD5 829a1d49d61c5da5fc393c52ff0cfda9
BLAKE2b-256 699f202a0bd34d70ec3803e9df38922d101eddaa955ae391ab0913199eacc7d7

See more details on using hashes here.

File details

Details for the file mt5_mcp_by_leo-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: mt5_mcp_by_leo-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for mt5_mcp_by_leo-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 55df1164a253f00ecf7050956c6de167aff995385e9f6411f6bb2ea293562974
MD5 20d30701e537658a219f6ca18dffce9e
BLAKE2b-256 b62482017ecf78790245be2c96d29aaefe3c985b3aec66d08e60f333b5ca8115

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page