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.
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_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 -v
Unit tests (config, router, gating, analytics, indicators, file readers) run without MetaTrader 5. Live checks require the terminals open.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。