MetaTrader MCP Server
An MCP server for MetaTrader 5: the agent reads the account and quotes, opens, changes and closes trades; a skill, REST and quote stream included
- 843 ★ on the repository
- Last commit
- MIT
Broad access
Why this level
- The agent opens, changes and closes trades on a live account, so it handles the user's money
- The account password sits in a configuration or an .env file, and the network mode checks no access and listens on all interfaces
Install
- Works in
Manual install
pip install metatrader-mcp-serverRequires Python 3.10 or newer and an installed MetaTrader 5 terminal with algorithmic trading enabled in the Expert Advisors section of the options.
Access and checks
How we reviewBroad accessThe tool can change data, run commands or handle secrets.
- The agent opens, changes and closes trades on a live account, so it handles the user's money
- The account password sits in a configuration or an .env file, and the network mode checks no access and listens on all interfaces
This is third-party code. Review the repository files before installing.
What it does
MetaTrader MCP Server is a Python MCP server for MetaTrader 5. It connects to a running MT5 terminal through the MetaTrader5 package using the account number, password and broker server name, and gives the agent 32 tools. It works with a demo and a live account. The tools cover four areas. Account: balance, equity, margin, leverage. Market: bid and ask prices, candles for recent periods and for a date range, symbol details. Trades: market and pending orders, changing stop loss and take profit, closing one position, all of them, by symbol, only profitable or only losing ones, cancelling pending orders. History: completed deals and orders. Besides MCP over stdio or SSE, the package offers three more interfaces: the `metatrader-http-server` HTTP server with docs at `/docs` for Open WebUI, the `metatrader-quote-server` quote stream over WebSocket on port 8765 and a Python client library. The claude-skill folder holds a trading skill for Claude Code and Claude Desktop: it describes every tool, order types and timeframes and formats answers as tables.
Who it is for. For MetaTrader 5 traders and trading bot developers who want to manage an account and trades in plain words in Claude Desktop, Claude Code or Open WebUI, starting with a demo account.
Good fit when
- You need a quick account summary: balance, equity, margin and open positions in one table
- Close all losing positions or all positions of one symbol without clicking through the terminal
- Place a market or pending order with stop loss and take profit from a plain description
- Export candles for a symbol and timeframe over a date range for analysis in another tool
- Feed terminal quotes to your own dashboard or bot over WebSocket without writing MT5 code
Not a fit when
- MetaTrader 5 is not installed or your broker offers a different platform: the server controls MT5 only
- You trade on a Russian exchange through T-Investments: Tinkoff Trader MCP covers that and has trading off by default
- You need an MCP server for the Finam exchange: FINAM Trade API MCP Server exists for it
- You trade on the OKX crypto exchange: OKX Agent Trade Kit fits
- You need support or guarantees on trade quality: the project is in beta and its authors accept no liability for losses
Example request
Show the balance and open positions on the account, then close all losing EURUSD tradesMCP
- Transport
- stdio, sse
- Authentication
- not required
Environment variables
LOGINrequired- MT5 trading account number
PASSWORDrequired, secret- MT5 trading account password
SERVERrequired- Broker server name, for example MetaQuotes-Demo
MT5_PATH- Path to terminal64.exe if the terminal sits in a non-standard folder
Limitations
- The server controls only an MT5 terminal with algorithmic trading enabled (Tools, Options, Expert Advisors); the terminal must be running.
- Python 3.10 or newer and account details are required: number, password and broker server. They are passed as command-line flags, in the agent configuration block or through an `.env` file.
- For remote mode the author suggests running the server on a Windows machine with MT5 installed. The default address is 0.0.0.0:8080, and the MCP protocol has no built-in access check: the author recommends a firewall, a reverse proxy with authentication or an SSH tunnel.
- The package classifiers say Beta, version 0.5.1. The author states there is no liability for losses and notes this is not financial advice.
- The trading skill executes trade requests immediately, without extra confirmation.
- MIT license. Documentation and the skill are in English.
How to disable. Remove the metatrader entry from your agent's MCP settings and stop the server process. The package is removed with `pip uninstall metatrader-mcp-server`. The skill goes away with the trading folder in the Claude skills directory. To be safe, change the account password at your broker if it was stored in a configuration or an `.env` file.
FAQ
How do I connect MetaTrader 5 to Claude Desktop through MCP?
Install the package with pip install metatrader-mcp-server, enable algorithmic trading in the MT5 terminal and add the metatrader server to claude_desktop_config.json. In args set the --login, --password, --server and --transport stdio flags, then restart Claude Desktop. If the terminal sits in a non-standard folder, add the --path flag with the path to terminal64.exe.
What does MetaTrader MCP Server offer besides MCP?
Three separate commands: metatrader-http-server brings up a REST API with docs on the /docs page, used with Open WebUI; metatrader-quote-server serves quotes over WebSocket on port 8765, by default for six symbols including XAUUSD and EURUSD, polling every 100 ms; the MT5Client library is for Python scripts.
How do I close all losing positions in MT5 with AI?
The server has the close_all_losing_positions and close_all_profitable_positions tools, plus close_all_positions and close_all_positions_by_symbol. A request such as close all losing positions calls the first one. The trading skill executes such requests without asking for confirmation, so word them carefully.
How do I install the trading skill for Claude Code?
The skill lives in the claude-skill/trading folder of the repository. Copy it to .claude/skills/trading in your project or symlink .claude/skills to claude-skill. The skill is invoked with /trading or triggers on questions about trades, orders and balance.
Can I connect to MetaTrader MCP Server from another computer?
Yes. Run metatrader-mcp-server with the account details on the machine with MT5; by default it listens on 0.0.0.0:8080 and the --host and --port flags change that. In the client set a url like http://address:8080/sse. The MCP protocol does not check access, so restrict the port with a firewall or forward it through an SSH tunnel.
Discussion
No questions or reviews yet.
Related
MCP serversAn MCP server for market data and technical analysis: quotes, indicators, screeners and backtesting for stocks, crypto, forex and futures
The official CCXT MCP server and skills: market data, balances and opt-in trading across crypto exchanges and prediction markets
MCP server for backtesting trading strategies: the agent fetches quotes, runs a test from YAML and reads the metrics on the Backtrader engine
FINAM Trade API MCP server
FINAM Trade API MCP Server
An MCP server for FINAM brokerage trading: quotes, order book, placing and cancelling orders, accounts and trade history
MCP server that links an agent to a running TradingView Desktop for chart analysis, Pine Script work and alerts
An MCP server for personal stock analysis: market data, technical indicators, screening and portfolio tracking, no keys for the core
Comparison with similar tools
Entries that share the main search query, and how they differ.
| Entry | Official | Authentication | Repository stars | Main difference |
|---|---|---|---|---|
| MetaTrader MCP Server (this entry) | no | not required | 843 | |
| Autonomous trading MCP for T-Bank Invest | no | API key | 0 | trading in T-Investments on a Russian exchange, trading is off by default |
| FINAM Trade API MCP server | no | API key | 0 | exchange trading through the Finam API: quotes, order book and orders |
| OKX Agent Trade Kit | yes | API key | 492 | the official OKX crypto exchange kit with 167 tools, MCP, CLI and skills |
README in short
The repository holds the source of four modules: the MT5 client, the MCP server, the REST server and the quote stream, a test suite, detailed documentation with an API description and examples, the trading skill and built distributions. The main file walks step by step from installing the package and setting up the terminal to three ways of connecting, lists every operation, describes the quote stream message format and carries a warning about possible trading losses.