Metatrader 5 Mcp Server — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Metatrader 5 Mcp Server (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
MetaTrader 5 integration for Model Context Protocol (MCP). Provides read-only access to MT5 market data through Python commands.
mt5_query, mt5_analyze, and execute_mt5 now enforce payload size limits, reject dangerous operations, validate MT5 connectivity up front, and catch-all exceptions without crashing the server.# Default behavior (stdio only, backward compatible)
python -m mt5_mcp
# or simply:
mt5-mcp
# Streamable HTTP with rate limiting and a custom port
python -m mt5_mcp --transport http --host 0.0.0.0 --port 7860 --rate-limit 30
# or:
mt5-mcp --transport http --host 0.0.0.0 --port 7860 --rate-limit 30
# Dual mode (stdio + HTTP)
python -m mt5_mcp --transport both
# or:
mt5-mcp --transport both📖 Documentation:
history_deals_get, history_orders_get, and positions_get.execute_mt5), submit structured MT5 queries (mt5_query), or run full analyses with indicators, charts, and forecasts (mt5_analyze).ta, numpy, and matplotlib ship in the namespace for RSI, MACD, Bollinger Bands, multi-panel charts, and more.px, go) for creating interactive HTML charts from market data and trading history.execute_mt5Free-form Python execution inside a curated namespace. Ideal for quick calculations, prototyping, and bespoke formatting.
rates = mt5.copy_rates_from_pos('BTCUSD', mt5.TIMEFRAME_H1, 0, 100)
df = pd.DataFrame(rates)
df['RSI'] = ta.momentum.rsi(df['close'], window=14)
result = df[['time', 'close', 'RSI']].tail(10)mt5_queryStructured JSON interface that maps directly to MT5 read-only operations with automatic validation, timeframe conversion, and friendly error messages.
{
"operation": "copy_rates_from_pos",
"symbol": "BTCUSD",
"parameters": {"timeframe": "H1", "count": 100}
}mt5_analyzePipeline tool that chains a query → optional indicators → charts and/or Prophet forecasts (with optional ML signals) in one request.
{
"query": {
"operation": "copy_rates_from_pos",
"symbol": "BTCUSD",
"parameters": {"timeframe": "D1", "count": 180}
},
"indicators": [
{"function": "ta.trend.sma_indicator", "params": {"window": 50}},
{"function": "ta.momentum.rsi", "params": {"window": 14}}
],
"forecast": {"periods": 30, "plot": true, "enable_ml_prediction": true}
}git clone <repository-url>
cd MT5-MCPpip install -e .Optional features (HTTP transport and interactive charting):
# Install with HTTP/Gradio support
pip install -e .[ui]
# Install with Plotly for interactive charts
pip install -e .[charting]
# Install everything
pip install -e .[all]
# From PyPI:
pip install "mt5-mcp[all]"Package naming: The package is named mt5-mcp (with hyphen) on PyPI, but the Python module uses mt5_mcp (with underscore). This is standard Python convention.
This will install all required dependencies:
mcp - Model Context Protocol SDKMetaTrader5 - Official MT5 Python librarypandas - Data manipulation and formattingprophet - Time series forecastingxgboost - Machine learning for trading signals (NEW!)scikit-learn - ML utilities and preprocessing (NEW!)ta - Technical analysis indicatorsAdd to your Claude Desktop configuration file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mt5": {
"command": "python",
"args": ["-m", "mt5_mcp"]
}
}
}Alternatively, if the mt5-mcp CLI script is in your PATH:
{
"mcpServers": {
"mt5": {
"command": "mt5-mcp",
"args": []
}
}
}{
"mcpServers": {
"mt5": {
"command": "python",
"args": ["-m", "mt5_mcp", "--log-file", "C:\\path\\to\\mt5_mcp.log"]
}
}
}Choose how the server exposes MCP transports directly from the command line:
# Default behavior (run only stdio like previous version)
python -m mt5_mcp
# or:
mt5-mcp
# Run both transports
python -m mt5_mcp --transport both
# or:
mt5-mcp --transport both
# Run only streamable HTTP
python -m mt5_mcp --transport http --host 0.0.0.0 --port 7860
# or:
mt5-mcp --transport http --host 0.0.0.0 --port 7860Additional flags:
--rate-limit <value> – Requests per IP each minute (set to 0 to disable; keep enabled for public servers).--log-level / --log-file – Tailored diagnostics across transports.pip install "mt5-mcp[ui]" (or pip install -e .[ui] while developing).python -m mt5_mcp --transport http --host 0.0.0.0 --port 7860 (or mt5-mcp --transport http).{
"mcpServers": {
"mt5-http": {
"url": "http://localhost:7860/gradio_api/mcp/"
}
}
}Note: Use python -m mt5_mcp (module name with underscore) or the mt5-mcp CLI command (package name with hyphen) interchangeably.
This endpoint works with MCP Inspector, Claude Desktop (when configured for HTTP), VS Code extensions, or remote deployments (Hugging Face Spaces, Windows VPS, etc.).
Refer to [USAGE.md](USAGE.md) for a complete walkthrough that covers prerequisites, configuration screens, troubleshooting tips, and in-depth per-tool examples. Below is a quick multi-line example using execute_mt5:
from datetime import datetime, timedelta
end_date = datetime.now()
start_date = end_date - timedelta(days=30)
rates = mt5.copy_rates_range('EURUSD', mt5.TIMEFRAME_D1, start_date, end_date)
df = pd.DataFrame(rates)
df['time'] = pd.to_datetime(df['time'], unit='s')
df['return'] = df['close'].pct_change()
result = df[['time', 'close', 'return']].tail(10)Note: Always assign the final output to result (or another variable noted in USAGE.md) so the MCP response can be formatted correctly.
mcp.server.lowlevel.Server for stdio clients and Gradio v6 for streamable HTTP/SSE, both sharing the same MT5-safe namespace.mt5, datetime, pd, ta, numpy, matplotlib) while blocking trading calls and disallowed modules.mt5.initialize() / mt5.shutdown() attempts, highlights the correct workflow, and enforces result assignment.Run the server with logging enabled:
python -m mt5_mcp --log-file mt5_debug.log
# or:
mt5-mcp --log-file mt5_debug.logOr configure it in Claude Desktop config (see Configuration section above).
"MT5 connection error: initialize() failed"
"Symbol not found"
mt5.symbols_get() to see available symbols"No data returned"
This server provides read-only access to MT5 data. Trading functions are explicitly excluded from the safe namespace:
order_send() - Place ordersorder_check() - Check orderpositions_get() - Get positions (read-only but blocked to prevent confusion)positions_total() - Position countOnly market data and information retrieval functions are available.
MIT License
Contributions are welcome! Please ensure:
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.