MT5 Multi-Account MCP

MT5 Multi-Account MCP

Enables read and execution access to multiple MetaTrader 5 accounts, allowing an AI assistant to manage positions, P&L, prices, indicators, history, logs, and trades across accounts.

Category
Visit Server

README

MT5 Multi-Account MCP

An MCP server that gives an AI assistant (Claude, etc.) direct read and optional execution access to multiple MetaTrader 5 accounts at once — positions, P&L, prices, indicators, history and logs, plus opening and closing trades — without screenshots.

⚠️ Disclaimer — read this. This software can place, modify and close REAL orders in MetaTrader 5. Use it entirely at your own risk. Test on a DEMO account first. It is provided "AS IS", without warranty of any kind; the authors are not liable for any financial loss. Execution is OFF by default — every account is read-only unless you explicitly set permitir_ejecucion: true.

Why this exists

The official MetaTrader5 Python package is a singleton per process: one initialize() connects to exactly one terminal, so you cannot read two accounts from a single process. This server solves that by launching one worker subprocess per account, each holding its own live connection. A parent process (FastMCP over stdio) routes every call to the right account's worker and reads CSV/log files directly.

MCP client ──stdio──▶ parent (FastMCP)
                       ├── router ──▶ worker(Account A) ──▶ MT5 terminal A
                       └── router ──▶ worker(Account B) ──▶ MT5 terminal B

Features

Read tools: account info, open positions, pending orders, deal history, P&L by channel/symbol/day, live price/candles/spread, locally-computed indicators (RSI/MACD/ATR/Bollinger/EMA/SMA), the EA's CSV files and the Experts logs.

Execution tools (opt-in): open market order, open pending order, modify SL/TP, close position (full or partial), cancel pending order.

Requirements

  • Windows, with one or more MetaTrader 5 terminals open and logged in (the worker attaches to the running terminal; it never asks for your password).
  • Python 3.11+ (tested on 3.14).

Install

python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txt

Configure

Copy the template and edit it with your accounts:

copy mt5_mcp\cuentas.example.json mt5_mcp\cuentas.json

Each account entry:

Field Meaning
nombre Label you use in the tools (e.g. "Broker1")
terminal_path Full path to that terminal's terminal64.exe
simbolo Default symbol for that account (brokers name it differently, e.g. XAUUSD, XAUUSD.r)
sufijo_csv Suffix of the EA's CSV files in Common\Files (optional)
terminal_hash The terminal's folder under ...\Terminal\<hash> (for reading Experts logs)
permitir_ejecucion true enables execution tools for that account. Default false (read-only)
max_lotes Optional per-order volume cap. If omitted, no cap

Root keys: magic_ejecucion (the magic number this server stamps on its orders) and common_files / terminals_root paths.

cuentas.json is gitignored so you never commit real accounts.

Register in your MCP client

.mcp.json (or your client's config):

{
  "mcpServers": {
    "mt5": {
      "command": "C:\\path\\to\\repo\\.venv\\Scripts\\python.exe",
      "args": ["-m", "mt5_mcp.server"],
      "cwd": "C:\\path\\to\\repo"
    }
  }
}

Restart the client; tools appear as mt5 / mcp__mt5__*.

Tools

Read-only: cuentas, health, account_info, positions, orders, comparar, deals, pnl_por_canal, pnl_por_simbolo, stats_dia, precio, velas, spread, indicadores, leer_csv_ea, experts_log.

Execution (require permitir_ejecucion: true): ejecutar_abrir_mercado, ejecutar_abrir_pendiente, ejecutar_modificar_sltp, ejecutar_cerrar, ejecutar_cancelar_pendiente.

Tool names and code comments are in Spanish (the project's original language). Functionality is language-independent.

Security model

  • Read-only by default: an account without permitir_ejecucion cannot execute.
  • Explicit, auditable execution: execution tools are separate, prefixed ejecutar_, gated per account, with an optional max_lotes cap and their own magic number.
  • Your MCP client asks for approval before each execution tool call.
  • No credentials: it connects to the already-open terminal.
  • No outbound network: only the local terminal and files.

Tests

.\.venv\Scripts\python.exe -m pytest mt5_mcp/tests -v

Unit tests (config, router, gating, analytics, indicators, file readers) run without MetaTrader 5. Live checks require the terminals open.

License

MIT — see LICENSE.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured