metatrader-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@metatrader-mcpCapture a chart screenshot of EURUSD on H1 timeframe"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MetaTrader 5 MCP Server
A lightweight Model Context Protocol (MCP) server for MetaTrader 5 that provides real chart snapshots directly from your MT5 terminal - no browser automation needed!
π Features
οΏ½ Real MT5 Screenshots: Captures actual charts from your MetaTrader 5 terminal with ALL your custom indicators
πΉ Market Data: Fetch current prices, spreads, and symbol information
π Lightweight: Expert Advisor + file-based communication (no Selenium, no browser)
π§ Easy Integration: Works seamlessly with Claude Desktop
π¨ What You See Is What You Get: Captures charts exactly as they appear in MT5
β‘ Fast: Direct chart capture via MQL5's ChartScreenShot function
οΏ½ Secure: File-based communication, no network ports required
Related MCP server: MT5 MCP Server
ποΈ Architecture
This system uses an innovative approach:
MQL5 Expert Advisor: Runs inside MT5, captures real charts using
ChartScreenShot()File-Based Protocol: Commands/responses via shared text files (UTF-16 LE encoding)
Python MCP Server: Communicates with EA, serves charts to Claude Desktop
MetaTrader5 API: For market data and symbol information
Key Advantage: Captures REAL MT5 charts with all your custom indicators, drawings, and settings - exactly as you see them!
π Prerequisites
Windows OS (MetaTrader 5 requirement)
MetaTrader 5 installed (download here)
Python 3.10+
π Quick Start
Step 1: Install Dependencies
cd d:\Desktop\metatrader-mcp
pip install -e .Step 2: Install Expert Advisor
Copy the EA:
Open MT5 β
FileβOpen Data FolderNavigate to
MQL5\Experts\Copy
expert_advisor\MCPChartCapture.mq5to this folder
Compile the EA:
In MT5, press
F4to open MetaEditorOpen
MCPChartCapture.mq5Press
F7to compile (should show "0 errors")
Attach to a chart:
Open any chart in MT5 (e.g., EURUSD H1)
In Navigator (
Ctrl+N), expandExpert AdvisorsDrag
MCPChartCaptureonto the chartIn the dialog, go to
Commontab:β Allow automated trading
Click
OK
Enable AutoTrading:
Click the
AutoTradingbutton in MT5 toolbar (or pressCtrl+E)You should see a π on the chart
Step 3: Test the Setup
python test_ea_connection.pyExpected output:
β
Connected to MT5 v5370
β
EA Response: EA is running
β
Screenshot saved: output\EURUSD_H1_20251101_024101.png
All tests passed! β
Step 4: Configure Claude Desktop
Locate config file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Add MCP server:
{ "mcpServers": { "metatrader5": { "command": "python", "args": ["-m", "metatrader_mcp.server"], "cwd": "d:\\Desktop\\metatrader-mcp" } } }Restart Claude Desktop
Test it! Ask Claude:
Show me a screenshot of EURUSD H1 chart
π οΈ Available Tools
1. capture_chart_screenshot
Capture a real screenshot from MT5 terminal with all your indicators.
Parameters:
symbol(string): Trading pair (e.g., "EURUSD", "XAUUSD", "BTCUSD")timeframe(string): Chart timeframe - M1, M5, M15, M30, H1, H4, D1, W1, MN1
Returns: Path to the captured screenshot (PNG, 1920x1080)
Example:
Capture a screenshot of XAUUSD 15-minute chart2. list_symbols
Get available trading symbols from MT5.
Parameters:
group(string, optional): Filter by group (e.g., "Forex", "Crypto")
Returns: List of symbols with descriptions
Example:
Show me all Forex symbols3. get_current_price
Get real-time market data for a symbol.
Parameters:
symbol(string): Trading pair
Returns: Current bid, ask, spread, time
Example:
What's the current price of EURUSD?4. get_timeframes
List all supported timeframes.
Returns: Available timeframe codes
π Supported Timeframes
Code | Description |
M1 | 1 minute |
M5 | 5 minutes |
M15 | 15 minutes |
M30 | 30 minutes |
H1 | 1 hour |
H4 | 4 hours |
D1 | Daily |
W1 | Weekly |
MN1 | Monthly |
ποΈ Project Structure
metatrader-mcp/
βββ expert_advisor/
β βββ MCPChartCapture.mq5 # MQL5 Expert Advisor for chart capture
βββ src/
β βββ metatrader_mcp/
β βββ server.py # Main MCP server
β βββ mt5_handler.py # MT5 connection & market data
β βββ chart_generator.py # EA communication & screenshot handling
βββ output/ # Captured screenshots (auto-created)
βββ test_ea_connection.py # Test EA connectivity
βββ pyproject.toml # Python dependencies
βββ README.mdπ§ Troubleshooting
β EA not responding / Timeout errors
Solutions:
Check the EA is attached to a chart (you should see π)
Enable AutoTrading in MT5 (
Ctrl+E)Check Experts log in MT5 for errors
Try removing and reattaching the EA
β "MT5 initialization failed"
Solutions:
Verify MT5 is installed:
C:\Program Files\MetaTrader 5\terminal64.exeOpen MT5 at least once to initialize
If custom install path, set
MT5_PATHenvironment variable
β Screenshot file not found
Solutions:
Ensure EA is running (check for π on chart)
Check Experts log for errors
Verify AutoTrading is enabled
Try capturing a chart that's already open
β "Could not fetch data for symbol"
Solutions:
The symbol must exist in your MT5 (check Market Watch)
Symbol names are case-sensitive
Try with "EURUSD" first to test
β Encoding errors / Garbled text
Solution: This is fixed! The system uses UTF-16 LE encoding for EA communication.
π‘ Usage Examples
Capture Chart with Custom Indicators
Claude, capture a screenshot of my XAUUSD M15 chartβ Returns actual MT5 chart with all your custom indicators!
Get Multiple Charts
Show me charts for EURUSD H1, GBPUSD H4, and XAUUSD M15Check Current Prices
What are the current prices for EURUSD, GBPUSD, and USDJPY?Explore Symbols
List all available Gold symbolsπ§ͺ Testing
Run the test suite:
# Test EA connection
python test_ea_connection.py
# Test chart capture
python take_screenshot.py
# Test specific symbol
python capture_xauusd.pyπ Configuration (Optional)
Create a .env file for custom settings:
# Custom MT5 installation path
MT5_PATH=C:\Program Files\MetaTrader 5
# Custom output directory for screenshots
OUTPUT_DIR=./chartsπ€ Contributing
Contributions are welcome! Feel free to:
Report bugs
Suggest features
Submit pull requests
Improve documentation
π License
MIT License - see LICENSE file for details
π Acknowledgments
MetaTrader 5 Python API - For market data access
MCP SDK - Model Context Protocol implementation
MQL5 Community - For Expert Advisor development resources
π Support
Having issues? Here's how to get help:
Run diagnostics:
python test_ea_connection.pyCheck MT5 Experts log: Look for error messages in MT5
Verify setup: EA attached? AutoTrading enabled? π visible?
Open an issue: Include error messages and system info
Made with β€οΈ for traders who want to integrate MT5 with Claude AI
No browser automation. No Selenium. Just pure, lightweight MT5 chart capture!
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect any MCP client to MetaTrader 4/5 to read prices, manage positions, and place trades.
Trade 16 crypto exchanges + MetaTrader 5 from your AI assistant via one MCP connection.
Global stock research, ML forecasts, valuation signals, screeners & portfolio tracking in Claude
GA4, Google Ads and Search Console in Claude. Read-only OAuth, multi-account for agencies.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceExposes TradingView technical indicators and OHLCV data through MCP tools for Claude Desktop or any MCP-aware client.23-
- AlicenseNot gradedqualityDmaintenanceEnables interaction with MetaTrader 5 for market data, technical analysis, Fibonacci calculations, and trading via MCP clients such as Claude.MIT
- FlicenseAqualityDmaintenanceEnables Claude AI to perform forex trading operations and market data analysis through MetaTrader 5, including order placement, position management, and multi-timeframe candle data retrieval.16-
- AlicenseAqualityBmaintenanceConnects Claude to a MetaTrader 5 terminal for read-only market data, account info, performance analysis, and order planning (no live trading).18MIT