loading…
Search for a command to run...
loading…
Enables comprehensive access to the MetaTrader 5 trading platform for retrieving market data, managing accounts, and executing trading operations. It provides 3
Enables comprehensive access to the MetaTrader 5 trading platform for retrieving market data, managing accounts, and executing trading operations. It provides 32 specialized tools for interacting with MT5 functionalities, including historical OHLCV data access, real-time position monitoring, and automated order management.
A Model Context Protocol (MCP) server that provides comprehensive access to MetaTrader 5 trading platform functionality through Python.
📖 New to this project? Check out the Quick Start Guide for a condensed reference!
Windows:
# Clone the repository
git clone https://github.com/amirkhonov/metatrader5-mcp.git
cd metatrader5-mcp
# Run installation script
install.bat
Linux/Mac:
# Clone the repository
git clone https://github.com/amirkhonov/metatrader5-mcp.git
cd metatrader5-mcp
# Run installation script
chmod +x install.sh
./install.sh
# Install from source
git clone https://github.com/amirkhonov/metatrader5-mcp.git
cd metatrader5-mcp
pip install -r requirements.txt
pip install -e .
git clone https://github.com/amirkhonov/metatrader5-mcp.git
cd metatrader5-mcp
poetry install
Copy the environment template:
cp .env.example .env
Edit .env with your MT5 credentials:
MT5_LOGIN=12345678
MT5_PASSWORD=your_password
MT5_SERVER=MetaQuotes-Demo
MT5_PATH=C:\Program Files\MetaTrader 5\terminal64.exe
Run the server:
# Using environment variables from .env
metatrader5-mcp
# Or with command line arguments
metatrader5-mcp --login 12345 --password secret --server MetaQuotes-Demo
# Check if the server starts correctly
metatrader5-mcp --help
This MCP server exposes 32 tools for interacting with MT5, organized into the following categories:
Choose the method that works best for you:
Windows:
install.bat
Linux/Mac:
./install.sh
The script will:
.env configuration file# Install dependencies
pip install -r requirements.txt
# Install the package
pip install -e .
# Copy environment template
cp .env.example .env
# Edit .env with your credentials
poetry install
cp .env.example .env
# Edit .env with your credentials
pipx install .
# Build and run
docker-compose up -d
# View logs
docker-compose logs -f
Note: Docker support is experimental as MT5 requires Windows. Best for development/testing.
Add this configuration to your Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"metatrader": {
"command": "metatrader5-mcp",
"args": [
"--login", "YOUR_MT5_LOGIN",
"--password", "YOUR_MT5_PASSWORD",
"--server", "YOUR_MT5_SERVER",
"--path", "C:\\Program Files\\MetaTrader 5\\terminal64.exe"
]
}
}
}
The server supports the following optional arguments:
--login LOGIN - Trading account number--password PASSWORD - Trading account password--server SERVER - Trading server name (e.g., "MetaQuotes-Demo")--path PATH - Path to MT5 terminal executable# With auto-initialization
metatrader5-mcp --login 12345 --password secret --server MetaQuotes-Demo
# Without initialization (manual connection via tools)
metatrader5-mcp
Having issues? Check our comprehensive Troubleshooting Guide for:
Or run the validation script:
python validate.py
⚠️ Important Security Notes:
📖 For comprehensive security guidance, see SECURITY.md
mt5_symbol_select to add symbolspython -m metatrader5_mcp
The server uses stdio transport and communicates via JSON-RPC over stdin/stdout.
You can test individual MT5 functions in Python:
import MetaTrader5 as mt5
# Initialize
if not mt5.initialize():
print("Failed:", mt5.last_error())
quit()
# Get account info
account = mt5.account_info()
print(account._asdict())
# Cleanup
mt5.shutdown()
MIT License - feel free to use and modify as needed. See LICENSE for details.
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
See CHANGELOG.md for version history and updates.
⚠️ Disclaimer:
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"metatrader-5-mcp-server": {
"command": "npx",
"args": []
}
}
}