Skip to main content
Glama
tradingmavenfx-cmd

MT5 MCP Server

MT5 MCP Server

一个本地 MCP 服务器,将 MetaTrader 5 终端连接到 Claude。 它可以读取市场数据、账户状态和历史记录,捕获图表截图, 并可以发送实盘订单

要求

  1. MetaTrader 5 终端必须处于运行状态

  2. 必须启用工具 → 选项 → 专家顾问 → “允许算法交易”

  3. 必须已登录账户

如果终端已关闭,所有工具都会返回 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)

市场数据

工具

功能

mt5_status

终端版本、连接、账户、余额、净值、保证金、DEMO/REAL

list_symbols

搜索品种 — 支持通配符(EUR**USD*

symbol_info

小数位数、点、点差、合约规模、手数限制、保证金和掉期利率

get_ticks

一个或多个品种的实时买价/卖价和点差

get_candles

从 M1 到 MN1 的 OHLCV,可按数量或日期范围获取

get_tick_history

原始买价/卖价逐笔数据流,适用于回测

账户

工具

功能

get_positions

未平仓头寸和总浮动盈亏

get_pending_orders

有效的限价单和止损单

get_history_deals

已平仓交易,含利润、佣金和掉期总计

get_history_orders

已下达、已取消或已拒绝的订单

calc_trade

保证金和预期利润,在发送任何订单之前(不会实际下单)

屏幕截图

工具

功能

list_charts

已打开的图表,含品种、时间周期和尺寸

screenshot

终端窗口或单个图表的 PNG 截图

screenshot 并非来自 MetaTrader5 Python API —— 该 API 根本没有截图功能。它基于 Windows 的 PrintWindow 调用构建(mt5_capture.py)。它可以在后台窗口上工作,但不能在最小化窗口上工作

传入 target='window' 可截取整个终端,或传入 target='XAUUSD,M30' 截取单个图表。仅传入 'XAUUSD' 会选择该品种最大的图表。

交易 — 实盘

工具

功能

open_position

市价买入/卖出,SL/TP 可按绝对价格或点数设置

place_pending_order

买入/卖出限价单或止损单,可设置到期时间

modify_position

更改未平仓头寸的 SL/TP

modify_pending_order

更改挂单的价格、SL 或 TP

close_position

全部或部分平仓

cancel_pending_order

删除挂单

close_all_positions

平掉所有头寸,或仅平掉某个品种的头寸

⚠️ 交易工具没有模拟/实盘保护。订单会发送到终端当前登录的账户。经纪商的成交模式会被自动检测,且品种会根据需要添加到市场报价。

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-DDYYYY-MM-DD HH:MMYYYY-MM-DD HH:MM:SS。输出的时间戳也是 UTC。

配置

以下环境变量在 .mcp.json 中是可选的:

变量

用途

MT5_PATH

terminal64.exe 的路径,用于在终端关闭时启动它

MT5_LOGIN / MT5_PASSWORD / MT5_SERVER

登录到其他账户(默认:使用终端当前已登录的账户)

冒烟测试

.venv/Scripts/python.exe -c "import mt5_mcp_server as s; print(s.mt5_status()['account'])"
F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables 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.
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables users to capture real MetaTrader 5 chart snapshots with custom indicators and fetch market data through natural language in Claude Desktop.
    2
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables interaction with MetaTrader 5 for market data, technical analysis, Fibonacci calculations, and trading via MCP clients such as Claude.
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables 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

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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