MetaTrader 4 is an MCP server that provides cross-platform integration between large language model clients and the MetaTrader 4 trading platform over a network. Designed for algorithmic traders, financial developers, and automated trading system builders, it enables AI assistants to inspect account balances, query real-time market quotes, monitor positions, place market or pending orders, and close existing trades. The integration architecture connects a Node.js-based MCP server to a Windows machine running a local HTTP bridge and an MQL4 Expert Advisor attached to a chart in MetaTrader 4. Communication leverages HTTP requests converted into file I/O operations inside the platform. Additionally, the system supports Expert Advisor lifecycle workflows, allowing users to sync MQL4 files, trigger remote compilation with detailed error logs, run strategy backtests with configurable parameters, and read backtest progress reports with automated fallback to JSON status files.
Category: CRM, ERP & E-commerce
Tags: automation, finance, forex, metatrader, trading
Follow these steps to set up and configure the MetaTrader 4 MCP server: 1. On your Linux host, install dependencies and compile the server: bash npm install npm run build 2. On the Windows host running MetaTrader 4, navigate to the windows-server directory, install packages, and start the HTTP bridge on port 8080: cmd npm install npm start 3. Copy mcp/MCP_Ultimate.mq4 to the MT4 MQL4/Experts/ folder, compile it in MetaEditor, attach it to a chart, and verify that DLL imports and automated trading are enabled. 4. Add the server to Claude Code using the command line: bash MT4_HOST=192.168.50.161 MT4_PORT=8080 claude mcp add mt4-server npm run start Alternatively, add it to your client configuration JSON under mcpServers: json { "mcpServers": { "mt4-server": { "command": "node", "args": ["dist/index.js"], "env": { "MT4_HOST": "192.168.50.161", "MT4_PORT": "8080" } } } }
Part of MCP Servers
You build the TypeScript MCP server using npm run build, run the provided Node.js HTTP bridge on your Windows machine hosting MetaTrader 4, compile and attach the MCP_Ultimate.mq4 Expert Advisor to a chart, and then register the server in your MCP client configuration using the target host IP and port.
The server allows AI assistants to retrieve account metrics, read market prices, execute market and pending orders, inspect or close active positions, review trade history, trigger backtests, and sync or compile Expert Advisor code remotely.
It is designed to work with Claude Code and any MCP-compliant client such as Claude Desktop or Cursor that supports stdio-based MCP servers configured with custom environment variables.
Yes, MetaTrader 4 itself and the required Node.js HTTP bridge must run on Windows. However, the MCP server itself can run on a separate Linux machine communicating with the Windows bridge across your local network.
Orders will not execute if automated trading is disabled in MetaTrader 4, if Allow DLL imports is unticked in the Expert Advisor properties, or if the MT4 chart running the bridge Expert Advisor is closed.