HTS(MetaTrader5) Trading MCP
A Model Context Protocol (MCP) server that connects Claude AI with MetaTrader 5 for forex trading operations and market data analysis.
Features
Market Data
- Historical Candles: Retrieve OHLC data for any forex symbol and timeframe
- Multi-Timeframe Analysis: Fetch candle data across multiple timeframes simultaneously
- Account Information: View trading account details and metrics
- Position Tracking: Monitor all open positions
- Order Management: Track pending orders
Trading Operations
- Order Placement: Create market and pending orders (BUY, SELL, LIMIT, STOP)
- Order Modification: Update price levels, SL/TP, and expiration times
- Order Cancellation: Cancel pending orders
- Position Management: Close positions (full/partial) and modify SL/TP levels
Architecture
The system consists of two components:
- MCP Server (Node.js/TypeScript)
- Exposes tools via Model Context Protocol
- Manages command queue for EA communication
- Provides HTTP API for MT5 integration
- MetaTrader 5 EA (MQL5)
- Executes trading operations
- Retrieves market data
- Communicates with MCP server via HTTP
Installation
npm install
npm run build
Configuration
Create a .env file:
HTTP_PORT=3000
Usage
Start the MCP Server
npm start
Configure Claude Desktop
Add to your Claude desktop config:
{
"mcpServers": {
"mcp-server": {
"command": "node",
"args": ["/path/to/trading-mcp/dist/index.js"]
}
}
}
Deploy MT5 EA
- Copy
ea/info-bot.mq5to your MetaTrader 5Expertsfolder - Compile the EA in MetaEditor
- Attach the EA to any chart
- Ensure the EA has the correct HTTP endpoint configured
API Tools
Market Data Tools
get_candles- Historical candle data for a symbolget_bulk_candles- Multi-timeframe candle dataget_accounts- All trading accountsget_account- Specific account by numberget_positions- All open positionsget_orders- All pending orders
Trading Tools
open_order- Create new trading ordermodify_order- Update pending ordercancel_order- Cancel pending orderclose_position- Close open positionmodify_position- Update position SL/TPget_command_queue- View pending commandsget_handler_queue- View command results











