← MCP server and skill grades

mcp-metatrader5-server

Qoyyuum/mcp-metatrader5-server

C
Type
MCP server
Scanned
Nov 17, 2026
Version
817d40196217
Files read
40

This MCP server connects an AI assistant to a local MetaTrader 5 terminal on Windows to read market data, view account history, and place or manage trades. Its biggest risks are that a prompt-injected AI agent can place unwanted live trades or pass an arbitrary executable path to initialize() to launch other programs on the user's computer.

What it can reach

Other
Reads trading account details, market prices, open positions, and trade history, and places, modifies, or closes financial orders in MetaTrader 5.
System
Connects to the local MetaTrader 5 terminal process over Windows IPC and launches the terminal executable when it is not already running.
Secrets
Reads MetaTrader 5 login credentials (MT5_LOGIN, MT5_USERNAME, MT5_PASSWORD, MT5_SERVER) from environment variables and any .env file loaded by python-dotenv.
Network
Communicates with broker trading servers through the MetaTrader 5 terminal, and listens on a local HTTP port (127.0.0.1:8000 by default) when MT5_MCP_TRANSPORT=http is set.

Findings

1 high2 medium
  1. HighAgent can launch arbitrary executables via initialize(pathObject/path) parameter

    src/mcp_mt5/main.py:565

    The initialize tool accepts an unchecked path parameter from the AI agent and passes it directly to mt5.initialize(path=path), overriding MT5_PATH even when the user configured one in the environment. On Windows, the MetaTrader5 library automatically starts the executable at path if no terminal at that path is already running. If the AI agent reads untrusted content containing a prompt injection, it can be tricked into calling initialize with another local executable or a remote Windows network share (UNC path), launching arbitrary programs or exposing Windows login hashes.

    Fix: Ignore caller-supplied path arguments when MT5_PATH is configured in the environment, reject UNC paths, and validate that any path points to an expected local terminal64.exe or terminal.exe binary.

  2. MediumHTTP transport mode runs without authentication or Origin checks

    src/mcp_mt5/__init__.py:24

    When MT5_MCP_TRANSPORT=http is enabled, the server starts an HTTP listener (127.0.0.1:8000 by default, or another interface via MT5_MCP_HOST) with no password, token, or Origin check. While HTTP mode is running, any local program, a malicious website visited in the user's browser (for example via DNS rebinding), or anyone on the network if bound beyond localhost can invoke tools like order_send or initialize directly with no AI involved.

    Fix: Configure bearer token authentication and strict Origin and Host header checks before enabling HTTP transport.

  3. MediumStored MT5_PASSWORD can be used in login attempts to an agent-chosen server

    src/mcp_mt5/main.py:633

    The login tool falls back to MT5_LOGIN, MT5_PASSWORD, and MT5_SERVER independently for each omitted argument rather than treating them as a single credential set. When a user stores MT5_PASSWORD in the server environment to keep it hidden from the AI, a prompt-injected agent can call login with an attacker-controlled server address (such as host:port) and omit password, causing MetaTrader 5 to attempt authentication against that server using the stored MT5_PASSWORD.

    Fix: Only use MT5_PASSWORD from the environment when both login and server also come from the environment (or match MT5_LOGIN and MT5_SERVER), and require an explicit password whenever server or login is overridden.