| # MetaTrader 5 MCP servers, build 6316: faults in the file tools
|
|
|
| Found on 2026-11-13 while comparing the tools that the two built-in MCP servers have in common.
|
|
|
| ## Environment
|
|
|
| - MetaTrader 5 and MetaEditor, build 6316, 64-bit, running under Wine on Linux.
|
| - Last tried on build 6327: faults 1 to 4 are reproduced as described, and the definitions
|
| that faults 5 and 6 are about are unchanged.
|
| - The servers as they name themselves in the handshake: `MetaTrader 5 MCP 1.0` (terminal) and
|
| `MetaEditor 5 MCP 1.0` (MetaEditor), protocol `2025-06-18`.
|
| - Every call below was sent to both servers with the same arguments (`tools/call` over
|
| Streamable HTTP) and the results were compared.
|
| - The test file is the standard `MQL5\Include\Object.mqh` as installed (33 lines, CRLF line
|
| ends). Its line 8 is `//| Class CObject. |`
|
| and its line 11 is `class CObject`. `<MQL5>` below stands for the absolute path of the
|
| `MQL5` folder, as `get_workspace_info` returns it in `workspace.mql5_folder`.
|
|
|
| ## Summary
|
|
|
| | # | Server | Tool | Fault |
|
| | --- | --- | --- | --- |
|
| | 1 | MetaEditor | `search_regex` | The pattern is lowercased when `case_sensitive` is false, escapes included: `\S` becomes `\s` |
|
| | 2 | both | `search_regex` | `$` does not match at the end of a line in a file with CRLF line ends |
|
| | 3 | MetaEditor | `list_directory`, `read_file_by_lines`, `search_regex` | An empty result where the terminal's server returns an error |
|
| | 4 | MetaEditor | `get_time_information` | The description names two values that the result does not have |
|
| | 5 | MetaEditor | `delete_file` | The description of `path` is the one of a tool that creates a file |
|
| | 6 | MetaEditor | `read_binary_file`, `replace_text_in_file` | Descriptions less exact than the terminal's (not tested) |
|
|
|
| Faults 1 and 2 matter most: the search returns a wrong result with no error.
|
|
|
| ## 1. MetaEditor, `search_regex`: the pattern is lowercased, escapes included
|
|
|
| With `case_sensitive` false, which is the default, MetaEditor's server lowercases the whole
|
| pattern before it is used. That changes the meaning of the escaped classes: `\S` becomes `\s`,
|
| `\W` becomes `\w`, `\D` becomes `\d`, `\B` becomes `\b`.
|
|
|
| To reproduce, call `search_regex` on MetaEditor's server:
|
|
|
| ```json
|
| {
|
| "path": "<MQL5>\\Include",
|
| "pattern": "\\S\\sCObject",
|
| "file_glob": "Object.mqh"
|
| }
|
| ```
|
|
|
| - Expected (and what the terminal's server returns): `total_matches` 3, in lines 8, 11 and 31,
|
| and `pattern` in the result is `\S\sCObject`.
|
| - MetaEditor's server returns: `total_matches` 5, in lines 14, 15, 18, 21 and 23 (none of the
|
| right ones: these are the lines with two white-space characters before `CObject`), and
|
| `pattern` in the result is `\s\scobject`.
|
|
|
| With `"case_sensitive": true` added, both servers return the 3 right matches and the pattern
|
| unchanged.
|
|
|
| The terminal's server does not have this fault: it reports the pattern as it was given and
|
| still matches without regard to case. (`search_text` lowercases its `query` on both servers,
|
| which does no harm there: the text is literal.)
|
|
|
| ## 2. Both servers, `search_regex`: `$` does not match at the end of a line with CRLF
|
|
|
| In a file with CRLF line ends, the end-of-line anchor matches only after the carriage return,
|
| so the line seems to be matched with its `\r` still in it. CRLF is MetaEditor's own format for
|
| source files (`get_workspace_info` returns `"newline": "CRLF"`).
|
|
|
| To reproduce, call `search_regex` on either server with these patterns, each with
|
| `"path": "<MQL5>\\Include"`, `"file_glob": "Object.mqh"` and `"case_sensitive": true`:
|
|
|
| | `pattern` | Expected `total_matches` | Returned |
|
| | --- | --- | --- |
|
| | `CObject$` | 1 (line 11, `class CObject`) | 0 |
|
| | `CObject\r$` | | 1 (line 11) |
|
| | `^$` | 1 (line 16, the file's one empty line) | 0 |
|
| | `^\r$` | | 1 (line 16) |
|
| | `^class CObject` | 1 | 1 (line 11) |
|
|
|
| `^` works as expected; only `$` is affected.
|
|
|
| ## 3. MetaEditor: an empty result where the terminal's server returns an error
|
|
|
| In three cases MetaEditor's server reports success with nothing in it, where the terminal's
|
| server returns `isError: true` and a message. A client cannot tell "nothing there" from "the
|
| request was wrong".
|
|
|
| | Tool | Arguments | MetaEditor | Terminal |
|
| | --- | --- | --- | --- |
|
| | `list_directory` | `"path": "<MQL5>\\nosuchdir"` (a folder that does not exist) | `"ok": true` and an empty `entries` | error: `Tool 'list_directory' specified folder does not exist` |
|
| | `read_file_by_lines` | `"path": "<MQL5>\\Include\\Object.mqh"`, `"start_line": 100000` | an empty text | error: `Tool 'read_file_by_lines' start_line 100000 is out of file, only 33 lines available` |
|
| | `search_regex` | `"path": "<MQL5>\\Include"`, `"pattern": "class ("`, `"file_glob": "*.mqh"` (an invalid pattern) | `"total_matches": 0` and an empty `results` | error: `Tool 'search_regex' search failed: invalid regular expression or search engine error` |
|
|
|
| Expected: MetaEditor's server answers as the terminal's does.
|
|
|
| ## 4. MetaEditor, `get_time_information`: the description names values that are not returned
|
|
|
| MetaEditor's description of the tool:
|
|
|
| > Get current time information from the connected MetaTrader 5 terminal and the local computer.
|
| > Returns UTC/GMT time, local computer time, local time offset from UTC in minutes, daylight
|
| > saving time status, calculated trade server time, and last known server time if available.
|
|
|
| Its result has four fields only, with the terminal running and connected to a trade server:
|
|
|
| ```json
|
| {
|
| "utc_time": "2026-11-13T21:10:49Z",
|
| "local_time": "2026-11-13T13:10:49",
|
| "local_utc_offset_minutes": -480,
|
| "daylight_saving_time": false
|
| }
|
| ```
|
|
|
| There is no calculated trade server time and no last known server time. The terminal's server,
|
| called at the same moment, returned the same four fields and
|
| `"trade_server_last_known_time": "2026-11-13T23:10:48"`, and its description matches its
|
| result (it names the fields and says when the last one is left out).
|
|
|
| Expected: either the two values in MetaEditor's result, or a description that does not name
|
| them.
|
|
|
| ## 5. MetaEditor, `delete_file`: the description of `path` belongs to another tool
|
|
|
| In MetaEditor's `tools/list`, the parameter `path` of `delete_file` is described as:
|
|
|
| > Absolute file path to create. The path must be under an allowed write root returned by
|
| > get_workspace_info. Do not pass relative paths. Parent directories will be created
|
| > automatically.
|
|
|
| The terminal's server describes the same parameter of the same tool as:
|
|
|
| > Absolute file path to delete. The path must be under an allowed write root returned by
|
| > get_workspace_info. Do not pass relative paths.
|
|
|
| To see it: `tools/list` on MetaEditor's server, the tool `delete_file`,
|
| `inputSchema.properties.path.description`. Seen in the definition only: the tool was not
|
| called.
|
|
|
| ## 6. MetaEditor: descriptions less exact than the terminal's (not tested)
|
|
|
| Two more differences between the two servers' definitions of the same tools. Whether
|
| MetaEditor's tools behave as the terminal's descriptions say was tested for the first only.
|
|
|
| - `read_binary_file`, parameter `length`. MetaEditor: "Maximum number of bytes to read." The
|
| terminal adds: "Use 0 to read all remaining bytes from the specified offset to the end of the
|
| file." MetaEditor's server does read to the end with `length` 0, so only its description is
|
| short of that sentence.
|
| - `replace_text_in_file`. MetaEditor: "Replace literal case-sensitive text in a file while
|
| preserving the rest of the file unchanged." The terminal's description adds that the search
|
| is within a single line, that multiline search is not supported and that `search` must not
|
| contain carriage-return or newline characters, and says the same in the descriptions of
|
| `search`, `start_line` and `end_line`. Not called on either server.
|
|
|
| ## For comparison: what else differs between the two servers
|
|
|
| Not faults, but differences a client meets when it uses the same tool on both servers:
|
|
|
| - `list_directory`, `find_files_by_glob` and `find_files_by_name_keyword`: MetaEditor's server
|
| adds `"git_status"` to every file entry (`"not under git control"` in this test); the
|
| terminal's server has no such field.
|
| - `get_workspace_info`: the terminal's result schema has four fields that MetaEditor's has not
|
| (`capabilities.can_run_optimization`, `capabilities.can_read_tester_journal`,
|
| `community.community_balance`, `community.community_currency`); the folders, the read, write
|
| and execute roots, the limits and the editor settings were the same in both results.
|
|
|
| Everything else that was tried gave the same result on both servers: `read_file` (a whole file,
|
| `offset` and `length`, an offset past the end, a file that does not exist, a path outside the
|
| read roots, a path with `..`), `read_file_by_lines` (ranges, `max_lines`, `encoding`),
|
| `read_binary_file`, `search_text`, and the three listing tools but for `git_status`.
|