home / mcp / metatrader 5 mcp server
Provides MT5 market data access, trade execution, and history analysis for MCP clients via the MT5 API.
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.
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.
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.
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 mt5mcpInitializes the MT5 terminal connection and prepares the environment for MT5 interactions.
Logs into a trading account using account credentials and server information.
Closes the connection to the MT5 terminal and cleans up resources.
Returns the list of all available trading symbols from MT5.
Fetches detailed information about a specific trading symbol.
Retrieves the latest tick data for a given symbol.
Gets historical bar data from a specific position for a symbol and timeframe.
Gets historical bar data starting at a specific date.
Retrieves historical bars within a date range for a symbol.
Fetches tick data from a specified position.
Fetches tick data from a specified date.
Fetches ticks within a date range.
Sends an order to the trade server with a detailed request.
Validates if an order can be placed with the provided parameters.
Retrieves open positions for a symbol and group.
Fetches an open position by its ticket number.
Gets active orders for a symbol and group.
Gets an active order by its ticket.
Retrieves historical orders based on filters like symbol, group, and date range.
Retrieves historical deals based on filters like symbol, group, and date range.