MT5 Multi-Account MCP
Click on "Deploy 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 Multi-Account MCPWhat's my total P&L today across all accounts?"
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 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 BRelated MCP server: MetaTrader 5 MCP Server
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.txtConfigure
Copy the template and edit it with your accounts:
copy mt5_mcp\cuentas.example.json mt5_mcp\cuentas.jsonEach account entry:
Field | Meaning |
| Label you use in the tools (e.g. |
| Full path to that terminal's |
| Default symbol for that account (brokers name it differently, e.g. |
| Suffix of the EA's CSV files in |
| The terminal's folder under |
|
|
| 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_ejecucioncannot execute.Explicit, auditable execution: execution tools are separate, prefixed
ejecutar_, gated per account, with an optionalmax_lotescap 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 -vUnit tests (config, router, gating, analytics, indicators, file readers) run without MetaTrader 5. Live checks require the terminals open.
License
MIT — see LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
Trade 16 crypto exchanges + MetaTrader 5 from your AI assistant via one MCP connection.
Connect any MCP client to MetaTrader 4/5 to read prices, manage positions, and place trades.
Trade across 22+ exchanges and brokers from any MCP-capable AI agent, no install required.
Unified financial infrastructure connecting AI agents directly to trade live/demo brokerage accounts, Web3 non-custodial wallets, real-time market data across equities, ETFs, crypto, forex, options, DeFi swaps, and prediction markets, institutional research feeds, and algorithmic strategy backtesters.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with the MetaTrader 5 trading platform for market data analysis, placing trades, and managing trading positions. Provides comprehensive access to forex and financial market operations through the Model Context Protocol.1-
- AlicenseNot gradedqualityCmaintenanceEnables comprehensive access to the MetaTrader 5 trading platform for retrieving market data, managing accounts, and executing trading operations. It provides 32 specialized tools for interacting with MT5 functionalities, including historical OHLCV data access, real-time position monitoring, and automated order management.1MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to connect to MetaTrader 5 for trading, market data access, and account management through the Model Context Protocol.67 PyPI220MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to trade on MetaTrader 5 using natural language, supporting account management, order placement, and real-time market data.1MIT