mt5-readonly-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mt5-readonly-mcp
A Model Context Protocol (MCP) server that lets an AI assistant such as Claude read a MetaTrader 5 account (positions, pending orders, trade history, prices and symbol specs) and makes it unable to trade.
Giving a language model access to a brokerage account is useful for journaling and analysis, but one misread prompt should never be able to open a position. This server is built so that read-only does not depend on the model behaving: it is enforced in code, checked on every call, and the server refuses to work if the check fails.
How read-only is enforced
Layer | What it does | Code | Test |
1. No trading code path | No tool places, modifies or closes orders. On import, |
| |
2. Fail-closed account check | Before every tool call the logged-in account must report |
| |
3. Dedicated terminal | Connects only to the terminal in |
| |
Confined exports | Export tools write CSV files only inside |
| |
No secrets | The server never receives a password. The dedicated terminal keeps the investor password saved when you logged in by hand. |
Every tool also carries MCP tool annotations (readOnlyHint, destructiveHint), so clients can show which tools only read.
flowchart LR
A[Tool call] --> B{MT5_TERMINAL_PATH set<br/>and file exists?}
B -- no --> X[Refuse]
B -- yes --> C[Connect to the dedicated terminal]
C --> D{account.trade_allowed?}
D -- true --> Y[Disconnect and refuse]
D -- false --> E[Read data] --> F[Compact JSON to the assistant]Related MCP server: mt5-remote-reader-mcp
Tools
Tool | Returns |
| Balance, equity, margin, leverage, account type and the read-only status |
| Open positions, optionally filtered by symbol |
| Active limit, stop and stop-limit orders with expiry |
| Closed trades, one row per position: entry and exit merged, volume-weighted prices, initial SL/TP, exit reason (stop loss, take profit, manual, stop out), commission, swap and net result |
| OHLC candles for any timeframe from M1 to MN1 |
| Contract size, volume limits, tick value, spread and swaps |
| Symbols offered by the broker, filtered by wildcard |
| Bid, ask, spread and daily change for up to 60 symbols in one call |
| Candles for many symbols and timeframes written to CSV |
| Closed-trade history written to CSV |
| Snapshot of account, positions and pending orders written to CSV |
Results are compact JSON (column names once, then rows) to keep the assistant's context small. For large datasets the export tools write files instead, so the assistant can analyse them with code rather than reading thousands of rows. Symbols are resolved for broker suffixes, so XAUUSD finds XAUUSDm. All times are the broker's server time.
Quick start (Windows)
You need Windows, MetaTrader 5, uv and an MCP client such as Claude Desktop.
Install a second MetaTrader 5 terminal into its own folder, for example
C:\MT5-ReadOnly(the installer's Settings button lets you choose the folder). Keep your trading terminal separate.Log that terminal in with the investor (read-only) password and tick Save password. Most brokers provide one when the account is opened; you can also set one in MetaTrader 5 under Tools → Options → Server → Change.
Get the code and run the check:
git clone https://github.com/HermanSetiawan77777/mt5-readonly-mcp.git C:\Tools\mt5-readonly-mcp $env:MT5_TERMINAL_PATH = "C:\MT5-ReadOnly\terminal64.exe" uv --directory C:\Tools\mt5-readonly-mcp run mt5-readonly-mcp --checkA correct setup prints
OK: connected, read-only mode verifiedandtrade_allowed = False (must be False). If the terminal is logged in with the master password, the check fails and tells you why.Add the server to Claude Desktop (Settings → Developer → Edit Config, file
%APPDATA%\Claude\claude_desktop_config.json):{ "mcpServers": { "mt5-readonly": { "command": "uv", "args": ["--directory", "C:\\Tools\\mt5-readonly-mcp", "run", "mt5-readonly-mcp"], "env": { "MT5_TERMINAL_PATH": "C:\\MT5-ReadOnly\\terminal64.exe", "MT5_EXPORT_DIR": "C:\\Users\\you\\mt5-exports" } } } }If Claude Desktop cannot find
uv, use the full path touv.exeascommand.Restart Claude Desktop and ask, for example:
"Show my open positions and pending orders."
"Summarise my closed trades this month by symbol: win rate, average win and loss, net result."
"Export H1 and M15 candles for XAUUSD and BTCUSD for the last 5,000 bars."
Configuration
Variable | Required | Meaning |
| yes | Full path to |
| no | Folder for CSV exports. Default: |
Development
The MetaTrader5 package exists only for Windows, so the tests replace it with an in-memory fake (tests/fake_metatrader5.py) and run on any OS:
uv run pytest
uv run ruff check .CI runs the tests on Linux for Python 3.10, 3.12 and 3.13, plus a Windows job that installs the real MetaTrader5 package, imports the server and confirms that it fails closed without configuration.
src/mt5_readonly_mcp/
guard.py safety layers 1-3
data.py read helpers and the deal-to-trade grouping
export.py CSV writing confined to the export folder
server.py the MCP tools
__main__.py command line: run the server or --checkLimitations
Windows only, because the MetaTrader5 Python package is Windows only.
MetaTrader 5 history does not keep SL/TP changes made after entry, so
deal_historyreports the initial SL/TP.Read-only protects the account, not the data: anything the tools return is sent to the AI client you connect. Use a client whose data policy you accept.
The tests use a fake terminal. Each release is also checked by hand against a live terminal (
--check, then every tool).
Disclaimer
Not affiliated with or endorsed by MetaQuotes Ltd. MetaTrader is a trademark of MetaQuotes Ltd. This software reads data only and gives no financial advice.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Read-only access to your MetaTrader 4 and 5 accounts for AI agents: balances, open positions, trade history with win rate, live quotes, symbol specs and candles. It cannot place, modify or close orders.
Read-only MetaTrader 5 for AI agents: balances, positions, history and prices. Sign in with OAuth.
Read-only market charts, OHLC, backtests and a view of your connected broker accounts
Let AI agents read and trade MetaTrader 5 accounts. Sign in with OAuth; read-only unless you allow.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides read-only access to MetaTrader 5 market data, trading history, and technical analysis through Python execution. Supports querying price data, calculating indicators, creating charts, and generating forecasts with Prophet and ML models.95 PyPI3MIT
- AlicenseAqualityDmaintenanceEnables AI agents to monitor MetaTrader 5 accounts on remote Windows VPS via SSH, providing read-only access to positions, history, and logs without executing trades.16MIT
- AlicenseNot gradedqualityCmaintenanceEnables read and execution access to multiple MetaTrader 5 accounts, allowing an AI assistant to manage positions, P&L, prices, indicators, history, logs, and trades across accounts.1MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to read Midas Atlas portfolio, positions, transaction history, and technical analysis, with order tools disabled by default and every order requiring desktop approval.102MIT