MT5 MCP Server
MT5 MCP Server
一个本地 MCP 服务器,将 MetaTrader 5 终端连接到 Claude。 它可以读取市场数据、账户状态和历史记录,捕获图表截图, 并可以发送实盘订单。
要求
MetaTrader 5 终端必须处于运行状态
必须启用工具 → 选项 → 专家顾问 → “允许算法交易”
必须已登录账户
如果终端已关闭,所有工具都会返回 MT5 initialize failed — 打开终端后重试。
Related MCP server: metatrader-mcp
安装
uv venv --python 3.12 .venv
uv pip install --python .venv/Scripts/python.exe -r requirements.txt然后调整 .mcp.json 中的路径,并重启 Claude Code。
工具 (20)
市场数据
工具 | 功能 |
| 终端版本、连接、账户、余额、净值、保证金、DEMO/REAL |
| 搜索品种 — 支持通配符( |
| 小数位数、点、点差、合约规模、手数限制、保证金和掉期利率 |
| 一个或多个品种的实时买价/卖价和点差 |
| 从 M1 到 MN1 的 OHLCV,可按数量或日期范围获取 |
| 原始买价/卖价逐笔数据流,适用于回测 |
账户
工具 | 功能 |
| 未平仓头寸和总浮动盈亏 |
| 有效的限价单和止损单 |
| 已平仓交易,含利润、佣金和掉期总计 |
| 已下达、已取消或已拒绝的订单 |
| 保证金和预期利润,在发送任何订单之前(不会实际下单) |
屏幕截图
工具 | 功能 |
| 已打开的图表,含品种、时间周期和尺寸 |
| 终端窗口或单个图表的 PNG 截图 |
screenshot 并非来自 MetaTrader5 Python API —— 该 API 根本没有截图功能。它基于 Windows 的 PrintWindow 调用构建(mt5_capture.py)。它可以在后台窗口上工作,但不能在最小化窗口上工作。
传入 target='window' 可截取整个终端,或传入 target='XAUUSD,M30' 截取单个图表。仅传入 'XAUUSD' 会选择该品种最大的图表。
交易 — 实盘
工具 | 功能 |
| 市价买入/卖出,SL/TP 可按绝对价格或点数设置 |
| 买入/卖出限价单或止损单,可设置到期时间 |
| 更改未平仓头寸的 SL/TP |
| 更改挂单的价格、SL 或 TP |
| 全部或部分平仓 |
| 删除挂单 |
| 平掉所有头寸,或仅平掉某个品种的头寸 |
⚠️ 交易工具没有模拟/实盘保护。订单会发送到终端当前登录的账户。经纪商的成交模式会被自动检测,且品种会根据需要添加到市场报价。
CLI (trade.py)
同样的工具,无需 Claude,直接从命令行运行:
.venv/Scripts/python.exe trade.py buy XAUUSD 0.01 --sl-points 500 --tp-points 1000
.venv/Scripts/python.exe trade.py modify 10090941191 --sl 4345.56 --tp 4360.56
.venv/Scripts/python.exe trade.py close 10090941191
.venv/Scripts/python.exe trade.py close-all --symbol XAUUSD
.venv/Scripts/python.exe trade.py positions
.venv/Scripts/python.exe trade.py calc buy XAUUSD 0.01 --close-price 4360运行 trade.py --help 可查看每个子命令的帮助。
时间格式
所有时间输入均为 UTC:YYYY-MM-DD、YYYY-MM-DD HH:MM 或 YYYY-MM-DD HH:MM:SS。输出的时间戳也是 UTC。
配置
以下环境变量在 .mcp.json 中是可选的:
变量 | 用途 |
|
|
| 登录到其他账户(默认:使用终端当前已登录的账户) |
冒烟测试
.venv/Scripts/python.exe -c "import mt5_mcp_server as s; print(s.mt5_status()['account'])"This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- 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 gradedqualityCmaintenanceEnables users to capture real MetaTrader 5 chart snapshots with custom indicators and fetch market data through natural language in Claude Desktop.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables interaction with MetaTrader 5 for market data, technical analysis, Fibonacci calculations, and trading via MCP clients such as Claude.MIT
- FlicenseAqualityDmaintenanceEnables Claude AI to perform forex trading operations and market data analysis through MetaTrader 5, including order placement, position management, and multi-timeframe candle data retrieval.16
Related MCP Connectors
Connect any MCP client to MetaTrader 4/5 to read prices, manage positions, and place trades.
Global stock research, ML forecasts, valuation signals, screeners & portfolio tracking in Claude
Trade Robinhood through natural language in Claude Code.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/tradingmavenfx-cmd/mt5-tradingview-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server