MetaTrader 5 MCP Server & Distrobox Automation
A MCP-Server to control Metatrader5 for EA optimization
chymian
README
MetaTrader 5 MCP Server & Distrobox Automation
This project provides a fully automated workflow for running, optimizing, and documenting MetaTrader 5 (MT5) Expert Advisors (EAs) using a Distrobox container, a Flask REST API, and an MCP server.
Features
- MetaTrader 5 in Wine/Distrobox: Automated setup and launch.
- Flask REST API: Programmatic optimization of EAs, with endpoints for running, monitoring, and saving results.
- MCP Server: Unified interface for trading, optimization, and result retrieval.
- Automated Documentation: Optimization results are saved as clear HTML and Markdown reports for each EA.
- Git Version Control: All code and configuration are versioned from the start.
Quickstart
1. Distrobox Container Setup
To assemble and enter the Distrobox container, run the following commands from the project root:
distrobox-assemble create --file src/mt5.ini -R
distrobox-enter mt5
- See
src/mt5.ini
for a complete, automated Distrobox config. - On container creation, the following are installed and configured:
- Wine, MT5, Python3, pip, Flask, MetaTrader5, pandas, jinja2, git, and all required tools.
- The Flask API is started automatically.
- A git repository is initialized and all files are committed.
2. Flask REST API
- Located at
src/mt5_flask_api.py
. - The API is accessible from the host at http://localhost:5000 (port 5000 is published by default; see
src/mt5.ini
). - Example: test the API from your host system with:
curl http://localhost:5000/optimization_status/some-id
- Endpoints:
POST /optimize
: Start an optimization run.GET /optimization_status/<id>
: Check optimization status.GET /optimization_results/<id>
: Get results.POST /save_results
: Save results as HTML/Markdown/CSV/JSON.
- Results are saved to
~/mt5-dev/result/manual/tuning/<EA_NAME>_tuning.html
and.md
.
3. MCP Server
- See
src/mt5-server.ts
for the MCP server implementation. - Tools include:
- Trading operations (get_account_info, create_order, etc.)
- Optimization operations (run_optimization, get_optimization_status, get_optimization_results, save_optimization_results)
4. Usage Example
- Start the container (Distrobox will run all setup and start the Flask API).
- Use the MCP server to trigger optimizations and generate reports.
- Open the HTML/Markdown reports in
~/mt5-dev/result/manual/tuning/
for a clear overview.
Working Directory & Configuration
By default, all logs, data, results, and outputs are stored in ~/mt5-dev
for portability and consistency.
To override any configuration value for your local development, copy src/mt5.ini
to src/mt5-dev.ini
and customize as needed.
The src/mt5-dev.ini
file is ignored by git and will not be tracked or pushed.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor

Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.