Get the FREE Ultimate OpenClaw Setup Guide →

metatrader

Model Context Protocol (MCP) to enable AI LLMs to trade using MetaTrader platform

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio ariadng-metatrader-mcp-server python -m metatrader_mcp_server \
  --env MT5_LOGIN="Your MT5 login (optional if provided via args/CLI)" \
  --env MT5_SERVER="Your MT5 server name (e.g., MetaQuotes-Demo)" \
  --env MT5_PASSWORD="Your MT5 password (optional if provided via args/CLI)"

How to use

MetaTrader MCP Server acts as a bridge between AI assistants and the MetaTrader 5 trading platform. It exposes a programmable interface that lets AI chat clients query market data, account information, and place or manage trades via natural language or REST API calls. The server can be used directly as a Python module, or exposed via REST endpoints for chat integrations like Claude Desktop or Open WebUI. Typical workloads include asking for current prices, retrieving account balance and margin details, or issuing trade commands such as buying or selling instruments with stop loss and take profit parameters. With its REST API option, you can integrate trading capabilities into your chat flows without embedding MT5 SDKs in your frontend.

Usage scenarios include querying real-time quotes, requesting historical candles, creating market or limit orders, and managing open positions. The server supports interfacing through multiple clients and can be run locally or exposed on a network for remote AI services. By keeping credentials on your machine and offering flexible deployment (CLI, REST, or library pattern), it balances accessibility with security for AI-assisted trading workflows.

How to install

Prerequisites

  • Python 3.10 or higher
  • pip (comes with Python)
  • MetaTrader 5 terminal installed and configured

Installation steps

  1. Create and activate a Python virtual environment (optional but recommended)
python3 -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
  1. Install the MCP server package
pip install metatrader-mcp-server
  1. Run the MCP server
# Basic run (module entrypoint)
python -m metatrader_mcp_server
  1. If you prefer to pass credentials via environment variables, export them before running:
export MT5_LOGIN=your_mt5_login
export MT5_PASSWORD=your_mt5_password
export MT5_SERVER=MetaQuotes-Demo

Then run the server as above. You can also bind to specific host/port or provide additional flags as supported by the package (consult docs for CLI options).

Additional notes

Tips and tips:

  • If using Claude Desktop or Open WebUI, you can configure the MCP server through a config snippet that points to the Python module (see mcp_config example).
  • Keep MT5 credentials secure; prefer providing them via environment variables or secure vaults rather than embedding in code or logs.
  • The server can expose REST endpoints for market data, account info, and order management. Use the /api/v1 paths described in the docs for integration.
  • If you encounter connection issues to MT5, verify MT5 terminal is running, the login server and path are correct, and that port/firewall settings allow the local host to be reached by your AI client.
  • For advanced setups, you can run behind a reverse proxy or containerize the server for consistent environments.
  • Check the project’s docs for any MT5 path overrides to handle non-standard MT5 installations.

Related MCP Servers

Sponsor this space

Reach thousands of developers