home / mcp / metatrader 5 mcp server

MetaTrader 5 MCP Server

Provides MT5 market data access, trade execution, and history analysis for MCP clients via the MT5 API.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "af7007-mcp-trader": {
      "command": "uv",
      "args": [
        "run",
        "mt5mcp"
      ],
      "env": {
        "MT5_MCP_HOST": "127.0.0.1",
        "MT5_MCP_PORT": "8000",
        "MT5_MCP_TRANSPORT": "http or stdio (default is stdio)"
      }
    }
  }
}

You can run an MCP server that connects to MetaTrader 5 to access market data, place trades, and analyze trading activity. This server exposes a clean interface for AI assistants to interact with MT5, making it easier to build automated trading workflows and data-driven insights.

How to use

To start using the MT5 MCP server, run it in stdio mode for MCP clients like Claude Desktop. This keeps the server ready to communicate with your AI assistant without setting up an HTTP transport.

How to install

Prerequisites you need before installation are Python 3.11 or higher and the MetaTrader 5 terminal installed on Windows. You also need a MetaTrader 5 account (demo or real). You will also rely on uv as the runtime to manage the MCP server.

How to use the server with an MCP client

Start the MCP server in stdio mode so MCP clients can connect directly. The quickest way is to execute the standard startup command below.

uv run mt5mcp

Available tools

initialize

Initializes the MT5 terminal connection and prepares the environment for MT5 interactions.

login

Logs into a trading account using account credentials and server information.

shutdown

Closes the connection to the MT5 terminal and cleans up resources.

get_symbols

Returns the list of all available trading symbols from MT5.

get_symbol_info

Fetches detailed information about a specific trading symbol.

get_symbol_info_tick

Retrieves the latest tick data for a given symbol.

copy_rates_from_pos

Gets historical bar data from a specific position for a symbol and timeframe.

copy_rates_from_date

Gets historical bar data starting at a specific date.

copy_rates_range

Retrieves historical bars within a date range for a symbol.

copy_ticks_from_pos

Fetches tick data from a specified position.

copy_ticks_from_date

Fetches tick data from a specified date.

copy_ticks_range

Fetches ticks within a date range.

order_send

Sends an order to the trade server with a detailed request.

order_check

Validates if an order can be placed with the provided parameters.

positions_get

Retrieves open positions for a symbol and group.

positions_get_by_ticket

Fetches an open position by its ticket number.

orders_get

Gets active orders for a symbol and group.

orders_get_by_ticket

Gets an active order by its ticket.

history_orders_get

Retrieves historical orders based on filters like symbol, group, and date range.

history_deals_get

Retrieves historical deals based on filters like symbol, group, and date range.