mt5-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| MT5_MCP_HOME | No | Overrides the default home directory %USERPROFILE%\.mt5-mcp where terminals.toml, secrets.env, profiles, and data are stored. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Research and backtesting only. This server cannot place, modify, or close live orders. list_terminals returns the registry. Pass include_discovered=true to see every install. add_terminal and remove_terminal change the registry only, not the files on disk. launch_terminal starts any install, registered or not, and skips one that is already running. Call use_terminal before market data, account_health, or a backtest. account_health, positions, and orders are read-only. capture_profile writes every symbol on the broker to a JSON file. copy_rates and copy_ticks write history to files and return a short preview. history_coverage reads the earliest M1 bar already on disk and does not download. extend_history with kind=m1 downloads older M1 one UTC month at a time until a month has no bars. The server never logs in. Log in from the terminal window. An existing Expert Advisor is compiled and tested as-is. compare_profiles diffs saved broker profiles. smoke_test compiles an EA and runs one day, then scans the journal. run_backtest stores a snapshot of the sources, the ini, and the report path. read_report returns every closed trade. Read the mt5:// resources before a new kind of task.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| list_terminalsA | List terminals in the registry. Pass include_discovered=true to also list installs found under %APPDATA%\MetaQuotes\Terminal that are not in the registry yet. Password values are not included. |
| add_terminalA | Add a discovered terminal, or a path, to the registry. This writes terminals.toml. It does not copy or create an install. name becomes the registry id when it is set. A junction to an install is refused. Register the real directory. |
| remove_terminalB | Remove a terminal from the registry. The install and data folder stay on disk. |
| launch_terminalA | Start a MetaTrader terminal. Pass a registry id, a discovered id, or any terminal path. If that terminal64.exe is already running, this leaves it alone. A junction is refused, because MetaTrader would open a second data folder. |
| use_terminalA | Attach the API to a terminal that is already logged in. This never sends a login or password. If the open account is not the one named in the registry, log in from the terminal window. |
| terminal_statusA | Report the active terminal: build, company, server clock, timezone offset, login, and demo or real. |
| disconnectA | Drop the Python API connection. The terminal window stays open. |
| account_healthA | Read account health for the active terminal. Returns balance, equity, margin, free margin, margin level, floating profit, whether trading is allowed, open positions, and pending orders. This does not place, modify, or close anything. |
| positionsA | List open positions on the active account. Read-only. |
| ordersB | List pending orders on the active account. Read-only. |
| capture_profileA | Write a JSON profile of the active broker: clock, account mode, and every symbol. Each symbol stores the full symbol_info record plus weekday sessions. The tool result is a summary and a file path, not the whole symbol list. |
| read_profileB | Read a saved broker profile. Without symbol, return the summary. With symbol, return that instrument. |
| list_profilesA | List saved broker profiles and how many symbols each one contains. |
| compare_profilesA | Diff saved broker profiles on the fields that decide whether a backtest can transfer. Pass at least two ids from list_profiles. Symbol names must match exactly. Compared fields are spread, the floating-spread flag, swap, swap mode, stops level, contract size, filling mode, and session hours. Unchanged symbols are counted and omitted. |
| list_symbolsB | List symbol names on the active terminal. limit=0 returns every name. |
| symbol_infoB | Return the full symbol_info record, the latest tick, and weekday sessions. |
| symbol_tickB | Return the latest bid, ask, last, and time for one symbol. |
| select_symbolC | Add or remove a symbol in Market Watch so history can download. |
| copy_ratesA | Download bars, paging until the terminal runs out, and write CSV or Parquet. Omit both dates to request every bar the terminal still serves. Pass both dates for one window. Bars outside that window are dropped, including the older bar the terminal returns when the window is before cached history. This is not how far back M1 goes. Use history_coverage for bars already on disk and extend_history with kind=m1 to download older months. The result is a file path, a count, a time range, and a short preview. |
| probe_historyA | Probe how far back daily, weekly, or monthly bars already go, and save that series by default. Omit symbol to survey every symbol, or pass a group mask. Daily bars are stored as data//rates/D1/.csv with a survey.json index. The tool result is the summary, not the bars. This does not measure M1. history_coverage reads the earliest M1 bar already on disk. extend_history with kind=m1 downloads older months until one comes back empty. |
| history_coverageA | Report stored bar and tick depth for one symbol without downloading a gap. m1.time_from is the earliest minute bar already in the yearly .hcc files. A missing earlier year has not been fetched. A year file the terminal has open is read back with one request bounded to that year. This call does not request an earlier year. Bar years and tick months come from the same cache. When verify is true, one bounded UTC request is made inside that cache for daily bars and for ticks. |
| extend_historyA | Download older history one chunk at a time and stop at the first empty chunk. kind=d1 walks one UTC year backward from the oldest cached year. kind=m1 walks one UTC month backward from the month before the earliest cached M1 bar. A bar outside that month does not count. The first month with no bars inside it is the broker limit. max_steps is the number of months in one call. Call again when reached_broker_limit is false. kind=ticks walks one UTC month backward from the oldest cached tick month. |
| copy_ticksB | Download ticks to a file. Set all_history=true when dates are omitted. Unbounded tick history is large, so all_history is required for that case. |
| list_expertsA | List .mq5 sources and .ex5 binaries under the active terminal Experts folder. |
| compileC | Compile one .mq5 file with MetaEditor and return structured errors and warnings. |
| smoke_testB | Compile an EA, run that one day, and scan the tester journal. date is both FromDate and ToDate. timeout_sec defaults to 180. Blocking lines are init failures, history not synchronized, tester rejects, and runtime errors. A history-sync miss is retried once. This does not place a live order. |
| read_inputsC | Parse input declarations from an Expert Advisor source file. |
| write_tester_configB | Write a headless tester.ini. ShutdownTerminal is always 1 and Visual is always 0. model is every_tick, ohlc, open_prices, or real_ticks. Pass source to seed TesterInputs from the EA, or pass inputs as a name-to-value map. |
| run_backtestA | Run terminal64.exe /config on a tester ini and wait until it exits. The ini must contain only [Tester] and [TesterInputs], with ShutdownTerminal=1. The launch path is used as written. A junction, an already-open terminal, or the same program running from another path is refused. The report is the file named by Report in the ini. Before the launch, the EA sources and the ini are copied into a snapshot. The manifest is updated with the report path. |
| read_reportA | Parse a tester HTML report into a summary, every closed trade, and a breakdown. Omit path to use the newest report for the active terminal. Each trade has entry and exit time, side, volume, prices, profit, and comment. The breakdown splits long and short expectancy, holding time, and entry hour on the report clock. |
| list_snapshotsB | List source snapshots written by run_backtest, newest first. |
| read_snapshotB | Read one snapshot manifest: EA sources, tester inputs, and the report path. |
| compare_reportsC | Diff two tester reports field by field. |
| tail_logC | Tail the tester journal or the terminal journal. mode is tester or journal. |
| stop_backtestA | Stop a Strategy Tester process this server started. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
| connect_terminal | Attach to a MetaTrader terminal that is already logged in. Do not ask for a password. |
| analyze_market_data | Export bars for one symbol and summarize the file, the range, and the latest tick. |
| review_account | Read balance, margin, open positions, and pending orders. Do not send or change an order. |
| backtest_expert | Compile an existing EA if needed, write a headless tester ini, run it, and read the report. |
| compare_backtests | Diff two tester reports. |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
| getting_started | Basic workflow: find a terminal, attach, then read data or run a backtest. |
| terminals | Registry, launch, and attach. The server never logs in. |
| market_data_guide | Symbols, broker profiles, bar export, history probe, and tick export. |
| account_guide | Read-only account health, open positions, and pending orders. |
| backtest_guide | Compile an existing Expert Advisor and run a headless backtest. |
| timeframes | Bar-size names and the integer codes the terminal stores. |
| tester_models | Tick-model names for write_tester_config. |
TDQS
Scored across 35 tools
Most tools target distinct resources or actions, but the history family (copy_rates, probe_history, history_coverage, extend_history, copy_ticks) overlaps enough that an agent must read descriptions carefully to choose correctly. Other groups, such as terminal launch/use/status and profile capture/read/compare, are more clearly separated.
The set mostly follows a predictable verb_noun pattern, with readable names throughout. A few read-only or status tools use noun-only names such as positions, orders, terminal_status, account_health, symbol_info, and history_coverage, but there is no chaotic style mixing.
With 35 tools, the server is well above the reasonable 3–15 range and past the 25+ threshold for being heavy. The domain is broad, but packaging terminal management, history, symbols, compilation, and backtesting into one server makes the surface large and costly to navigate.
The tool surface covers terminal lifecycle, account inspection, symbols, history, EA compilation, snapshots, and backtesting with few dead ends. Gaps such as no live order placement/modification/close and no explicit report-listing tool appear intentional or minor, and agents can work around them.