Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
MT5_DATANoAuto-detected AppData terminal folder (%APPDATA%\MetaQuotes\Terminal\<hash>)
MT5_EDITIONNoSet to 'mt4' for MetaTrader 4mt5
MT5_INSTALLNoInstall dir containing terminal64.exeC:\Program Files\MetaTrader 5
MT5_TERMINAL_HASHNo32-char folder name for terminal data

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

This server publishes no instructions, or was last inspected before Glama recorded them.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": false
}
prompts
{
  "listChanged": false
}
resources
{
  "subscribe": false,
  "listChanged": false
}
experimental
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
env_infoA

Resolve and report MT4/5 paths, terminal hash, and missing-component issues.

list_terminalsA

Enumerate all MetaTrader terminal data folders under %APPDATA%\MetaQuotes\Terminal.

compileA

Compile one MQL source with MetaEditor and return structured diagnostics.

ok is true only when the log has a Result: line with 0 errors AND (unless syntax_only) a fresh .ex5/.ex4 was produced (binary_fresh). Fix every entry in errors (file, line, col, code, message) and call again; warnings do not block deployment. Takes 1-30 s. To also copy the binary into Experts/ use compile_and_deploy.

run_backtestA

Run a Strategy Tester backtest headlessly from a tester.ini and wait for it to finish.

Requires the EA to be deployed first (compile_and_deploy / deploy_ea) and ShutdownTerminal=1 in the ini, otherwise the call runs until timeout_sec. Typically 1-30 minutes; progress notifications are sent every few seconds while waiting. If the tester reports "cannot synchronize history" (first headless start after login), the run is retried once automatically. For long runs prefer start_backtest + get_backtest. Returns run_id, report_path (resolved from Report= in the ini), latest_tester_log and journal_notes/warnings; if warnings mentions start_time_changed the tester moved FromDate because history was missing, so the report is not comparable with other runs.

start_backtestA

Launch a backtest in the background and return immediately with a run_id.

Poll get_backtest(run_id) until status is no longer "running"; the final record carries report_path and journal_notes. Runs are also written to .mt5tmp/runs/<run_id>.json next to the ini. Only one terminal per install can test at a time.

get_backtestA

Status of a background backtest (running / completed / timeout / cancelled) with report path and journal notes when done; without run_id, lists all runs newest first.

cancel_backtestA

Kill the terminal of a running background backtest. No report is produced for a cancelled run.

kill_terminalA

Force-kill terminal processes launched by this server (run_backtest / smoke_test).

By default only PIDs this server started are killed, so a live-trading terminal on the same machine is never touched. Pass all_instances=True to taskkill every terminal64.exe/terminal.exe of the configured edition (destructive).

tail_logA

Tail a MetaTrader log: the EA's LiveLog.txt, the daily Experts journal, or the latest tester journal.

Use mode="tester" right after a backtest to see runtime errors and the effective test period.

list_expertsA

List compiled EAs in Experts/ (defaults to *.ex5 for MT5, *.ex4 for MT4).

read_tester_reportA

Parse a Strategy Tester HTML report (MT5 or MT4) into summary metrics; the full HTML stays behind report_uri.

Prefer passing the report_path returned by run_backtest/get_backtest; without path the newest report on disk is used, which may belong to an older run. summary values are the strings printed in the report ("10 000.00", "359.61 (3.34%)"); use compare_reports / regression_check for numeric comparison. Read the mt5://report/{id} resource only when you need the original HTML.

patch_tester_iniA

Set keys in a tester.ini in place, keeping the file's encoding and other lines.

updates maps "Section.Key" to a value, e.g. {"Tester.Symbol": "EURUSD", "Tester.FromDate": "2025.01.01", "TesterInputs.RiskPct": "1.5"}. Missing sections/keys are added. Run validate_tester_ini afterwards; always set Deposit, Currency, Leverage, Model, Optimization, Visual, UseLocal/UseRemote/UseCloud and Report explicitly so a run does not inherit the machine's last UI state.

compile_and_deployA

Compile a source and, if it succeeds, copy the fresh binary into the terminal's Experts/ folder.

Use this before run_backtest or smoke_test. Returns the compile result plus deploy; ok is false if either stage failed (compile errors are in compile.errors).

deployA

Copy a compiled EA into the terminal's Experts/ folder or a .mqh header into Include/, chosen by extension.

Overwrites an existing file of the same name. Use compile_and_deploy to build and copy in one step.

inspect_sourceA

Read-only facts about MQL source: input declarations, #include tree (with missing files), MetaEditor doc blocks, symbol usages, duplicate magic numbers.

Replaces extract_inputs / resolve_includes / extract_doc / find_symbol / find_magic_collision.

analyze_mqlA

Static checks on MQL source without compiling: structural lint (missing OnInit/OnTick, unused inputs, hardcoded magic/symbol), MT4-style deprecated API calls with MT5 replacements, and size/nesting metrics.

Replaces lint_basic / check_deprecated / code_metrics. Use compile(syntax_only=true) for real compiler diagnostics.

read_optimizationA

Read an MT5 optimisation cache (.opt): header, optimised inputs, pass count and the top N passes by criterion.

Ranking uses every pass in the cache. The best pass of a genetic run is a biased sample; prefer robust neighbourhoods over the single top row. Replaces parse_optimization / top_passes.

compare_reportsA

Diff two tester reports key by key (absolute and percent deltas), optionally checking guard thresholds.

With guards, a profit-style metric below its threshold or a drawdown/loss metric above it is a violation. Accepting only improvements across many iterations is selection bias; treat guards as a sanity gate, not proof of robustness. Replaces regression_check.

gen_tester_inputsA

Generate a [TesterInputs] block from EA inputs.

If write_to points at a tester.ini, the block is appended/replaced in-place.

validate_tester_iniA

Sanity-check a tester.ini. If source given, cross-check inputs vs EA declarations.

format_mqlA

Format an MQL file with clang-format (MQL literals such as D'…' and input group lines are protected).

Default is a dry run reporting whether the file would change; pass write=true to apply. Replaces format_check.

rename_symbolA

Rename a symbol across MQL files (whole-word match). dry_run=True previews only.

snapshot_sourcesA

Freeze a copy of source files into a timestamped folder under dest.

list_snapshotsA

List all snapshot folders under dest.

select_terminalA

Switch the active terminal data folder for this session.

Provide one of: origin (install path stored in origin.txt), hash (32-char folder name), or install (auto-scan for the matching origin).

Subsequent tool calls will use the new layout until the server restarts.

smoke_testA

One-call health check for an EA: compile, deploy, run a 1-day headless backtest, scan the journal.

Catches problems that compile cleanly but fail at runtime (OnInit errors, array out of range, divide by zero). ok is true only if every stage passes; stage tells where it stopped. Overwrites the EA of the same name in Experts/. Takes 1-10 minutes.

extract_functionA

Extract a contiguous block of lines into a new helper function.

Brace-counting + regex param detection — not a full AST parser. Returns the proposed helper, call site, and parameter list. Set dry_run=False to write.

syntax_checkA

DEPRECATED (removed in 0.6.0): use compile(source, syntax_only=true).

deploy_eaA

DEPRECATED (removed in 0.6.0): use deploy(file, name).

install_includeA

DEPRECATED (removed in 0.6.0): use deploy(file, name) with a .mqh file.

extract_inputsA

DEPRECATED (removed in 0.6.0): use inspect_source(source, aspects=["inputs"]).

resolve_includesC

DEPRECATED (removed in 0.6.0): use inspect_source(source, aspects=["includes"]).

extract_docA

DEPRECATED (removed in 0.6.0): use inspect_source(source, aspects=["docs"]).

find_symbolA

DEPRECATED (removed in 0.6.0): use inspect_source(root=..., symbol=...).

find_magic_collisionA

DEPRECATED (removed in 0.6.0): use inspect_source(root=..., aspects=["magic"]).

lint_basicA

DEPRECATED (removed in 0.6.0): use analyze_mql(source, checks=["lint"]).

check_deprecatedA

DEPRECATED (removed in 0.6.0): use analyze_mql(source, checks=["deprecated"]).

code_metricsA

DEPRECATED (removed in 0.6.0): use analyze_mql(source or root, checks=["metrics"]).

format_checkA

DEPRECATED (removed in 0.6.0): use format_mql(source) (dry run by default).

parse_optimizationD

DEPRECATED (removed in 0.6.0): use read_optimization(...).

top_passesA

DEPRECATED (removed in 0.6.0): use read_optimization(criterion=..., top_n=...).

regression_checkA

DEPRECATED (removed in 0.6.0): use compare_reports(baseline, candidate, guards=...).

list_backtestsA

DEPRECATED (removed in 0.6.0): use get_backtest() without run_id.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

B3.2/5.0

Scored across 43 tools

Disambiguation3/5

The active tools are mostly distinct, but the 16 deprecated aliases duplicate the same operations as active tools (e.g., extract_inputs vs inspect_source, parse_optimization vs read_optimization), creating confusion. Some overlap also exists between compile/compile_and_deploy/deploy and run_backtest/start_backtest/smoke_test, though descriptions help clarify boundaries.

Naming Consistency4/5

Most tool names follow a clear verb_noun pattern (list_snapshots, run_backtest, read_tester_report, validate_tester_ini). Minor deviations like env_info, compile_and_deploy, and smoke_test are understandable exceptions, and deprecated names also generally follow similar conventions.

Tool Count2/5

With 43 tools, the surface is far too large, even though 16 are deprecated. The active count of 27 is still heavy, and several active tools are composites (compile_and_deploy, smoke_test) that could be consolidated without losing capability.

Completeness4/5

The server covers the major MT5 automation lifecycle: terminal selection, compile/deploy, backtest launch and monitoring, report parsing, source inspection, static analysis, formatting, optimization reading, and snapshots. Minor gaps exist (no explicit tester.ini creation tool, no undeploy/removal tool), but workflows do not hit dead ends.

Maintenance

ActivityMaintained
ResponsivenessNo issues