metatrader
Model Context Protocol (MCP) to enable AI LLMs to trade using MetaTrader platform
claude mcp add --transport stdio ariadng-metatrader-mcp-server python -m metatrader_mcp_server \ --env MT5_LOGIN="Your MT5 login (optional if provided via args/CLI)" \ --env MT5_SERVER="Your MT5 server name (e.g., MetaQuotes-Demo)" \ --env MT5_PASSWORD="Your MT5 password (optional if provided via args/CLI)"
How to use
MetaTrader MCP Server acts as a bridge between AI assistants and the MetaTrader 5 trading platform. It exposes a programmable interface that lets AI chat clients query market data, account information, and place or manage trades via natural language or REST API calls. The server can be used directly as a Python module, or exposed via REST endpoints for chat integrations like Claude Desktop or Open WebUI. Typical workloads include asking for current prices, retrieving account balance and margin details, or issuing trade commands such as buying or selling instruments with stop loss and take profit parameters. With its REST API option, you can integrate trading capabilities into your chat flows without embedding MT5 SDKs in your frontend.
Usage scenarios include querying real-time quotes, requesting historical candles, creating market or limit orders, and managing open positions. The server supports interfacing through multiple clients and can be run locally or exposed on a network for remote AI services. By keeping credentials on your machine and offering flexible deployment (CLI, REST, or library pattern), it balances accessibility with security for AI-assisted trading workflows.
How to install
Prerequisites
- Python 3.10 or higher
- pip (comes with Python)
- MetaTrader 5 terminal installed and configured
Installation steps
- Create and activate a Python virtual environment (optional but recommended)
python3 -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
- Install the MCP server package
pip install metatrader-mcp-server
- Run the MCP server
# Basic run (module entrypoint)
python -m metatrader_mcp_server
- If you prefer to pass credentials via environment variables, export them before running:
export MT5_LOGIN=your_mt5_login
export MT5_PASSWORD=your_mt5_password
export MT5_SERVER=MetaQuotes-Demo
Then run the server as above. You can also bind to specific host/port or provide additional flags as supported by the package (consult docs for CLI options).
Additional notes
Tips and tips:
- If using Claude Desktop or Open WebUI, you can configure the MCP server through a config snippet that points to the Python module (see mcp_config example).
- Keep MT5 credentials secure; prefer providing them via environment variables or secure vaults rather than embedding in code or logs.
- The server can expose REST endpoints for market data, account info, and order management. Use the /api/v1 paths described in the docs for integration.
- If you encounter connection issues to MT5, verify MT5 terminal is running, the login server and path are correct, and that port/firewall settings allow the local host to be reached by your AI client.
- For advanced setups, you can run behind a reverse proxy or containerize the server for consistent environments.
- Check the project’s docs for any MT5 path overrides to handle non-standard MT5 installations.
Related MCP Servers
valuecell
ValueCell is a community-driven, multi-agent platform for financial applications.
prism-insight
AI-based stock analysis and trading system
mcp-aktools
📈 提供股票、加密货币的数据查询和分析功能MCP服务器
edumcp
EDUMCP is a protocol that integrates the Model Context Protocol (MCP) with applications in the education field, dedicated to achieving seamless interconnection and interoperability among different AI models, educational applications, smart hardware, and teaching AGENTs.
TradingAgents mode
TradingAgents-MCPmode 是一个创新的多智能体交易分析系统,集成了 Model Context Protocol (MCP) 工具,实现了智能化的股票分析和交易决策流程。系统通过多个专业化智能体的协作,提供全面的市场分析、投资建议和风险管理。
lihil
2X faster ASGI web framework for python, offering high-level development, low-level performance.