← MCP server and skill grades

metatrader-mcp-server

ariadng/metatrader-mcp-server

C
Type
MCP server
Scanned
Nov 17, 2026
Version
bd2ff591e32c
Files read
177

This project connects AI assistants, web clients, and WebSocket consumers to a local MetaTrader 5 terminal so they can view account data, stream market prices, and place or close real-money trades. Its biggest risk is that its network servers—including the default MCP SSE mode on port 8080 and the optional HTTP API—have no password protection and disable or bypass browser origin checks, allowing anyone on the same network or a malicious website you visit to execute trades on your brokerage account.

What it can reach

Other
Reads MetaTrader 5 account balances, equity, margin, open positions, pending orders, and deal history, and places, modifies, cancels, or closes real-money trades up to 100 lots per order.
Secrets
Reads your MetaTrader 5 account login, password, and broker server name from command-line flags and environment variables or a .env file.
System
Launches and communicates with the local MetaTrader 5 terminal executable (terminal64.exe or terminal.exe) through the MetaTrader5 Python library.
Network
Can open local and network servers for MCP SSE/HTTP (0.0.0.0:8080 by default), the REST API (127.0.0.1:8000 by default), and the WebSocket quote stream (0.0.0.0:8765 by default).
Files
Searches standard MetaTrader 5 installation folders (or a configured path) for the terminal executable and reads .env files in the working directory.

Findings

1 high1 medium2 low
  1. HighMCP server defaults to unauthenticated 0.0.0.0 SSE listener with DNS rebinding protection disabled

    src/metatrader_mcp/utils.py:24

    Unless '--transport stdio' is passed, metatrader-mcp-server starts an unauthenticated SSE server bound to all network interfaces (0.0.0.0:8080) and explicitly turns off FastMCP's DNS rebinding protection. Anyone on the same network can connect to port 8080 to view account history and execute or close real-money trades. Because DNS rebinding protection is disabled, even if a firewall blocks external network access as suggested in the README, any malicious website opened in a browser on the same machine can attack 127.0.0.1:8080 via DNS rebinding and trade on the account without AI involvement.

    Fix: Default MCP_TRANSPORT to 'stdio' and MCP_HOST to '127.0.0.1', keep enable_dns_rebinding_protection enabled, and require authentication before exposing remote SSE or HTTP transports.

  2. MediumUnauthenticated HTTP API server with wildcard CORS allows websites and network peers to execute trades

    src/metatrader_openapi/main.py:45

    When metatrader-http-server is run, all /api/v1 endpoints—including placing market and pending orders, closing positions, and reading account balances—are served without any authentication and with CORSMiddleware configured to allow all origins ('*'), methods, and headers. Even when bound to the default 127.0.0.1:8000 address, any website visited in a local browser can send cross-origin requests to read account data or place real-money trades, and running with '--host 0.0.0.0' (as shown in the README Quick Start) exposes full trading control to anyone on the network.

    Fix: Require an API key or bearer token on all /api/v1 routes, restrict allow_origins to specific trusted origins instead of '*', add Host header validation, and remove '--host 0.0.0.0' from setup examples.

  3. LowWebSocket quote server binds to 0.0.0.0 with no authentication or Origin check

    src/metatrader_quote/server.py:183

    When metatrader-quote-server is started, it binds to 0.0.0.0:8765 by default and accepts WebSocket connections without authentication or browser Origin validation. Any device on the local network or any website opened in the user's browser can connect to ws://localhost:8765 and read the broker's symbol list, live bid/ask quotes, and account-currency point values.

    Fix: Default the bind host to '127.0.0.1', pass an explicit origins allowlist to websockets serve(), and require token authentication if remote streaming is needed.

  4. LowCLI entry points force cleartext MetaTrader password onto the command line

    src/metatrader_mcp/cli.py:9

    All three installed CLI commands (metatrader-mcp-server, metatrader-http-server, and metatrader-quote-server) mark '--password' as required=True during argument parsing with no environment variable fallback. Although the README advises putting PASSWORD in a .env file instead of on the command line, omitting '--password' causes the CLI to exit immediately with an error, forcing users to expose their brokerage password in process listings and shell history visible to other local users or monitoring tools.

    Fix: Make '--login', '--password', and '--server' optional on the CLI and read them from environment variables or .env after load_dotenv() runs.