Skip to main content
Glama
ptacr

mcp-mt5

by ptacr

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
MT5_DATANoPath to terminal data folder (auto-detected if not set)
MT5_EDITIONNoEdition: 'mt5' or 'mt4'mt5
MT5_INSTALLNoInstall dir containing terminal64.exeC:\Program Files\MetaTrader 5
MCP_MT5_PORTNoPort for HTTP transport8931
MCP_MT5_TOKENNoBearer token for HTTP transport authentication
MCP_MT5_TRANSPORTNoTransport mode (e.g., 'http' for remote access)
MT5_TERMINAL_HASHNo32-character terminal hash (auto-detected if not set)

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_infoB

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 a .mq4/.mq5/.mqh source via MetaEditor CLI.

Args: source: Absolute path to the source file. include: Optional MQL root override (parent of Include/). Defaults to terminal MQL root. log_file: Optional explicit log path. Defaults to .log. timeout_sec: Subprocess timeout.

Returns: returncode, structured errors/warnings lists, result_errors/result_warnings, log_path, log_excerpt (last 80 lines), cmd.

run_backtestB

Launch terminal with /config:<tester.ini>.

Args: config: Absolute path to tester.ini. wait: Block until terminal exits (requires ShutdownTerminal=1 in ini). timeout_sec: Wait timeout. portable: Pass /portable flag.

Returns: returncode, elapsed_sec, latest_tester_log path.

kill_terminalA

Force-kill all running terminal processes for the configured edition.

tail_logA

Read last N lines from terminal logs.

Args: mode: "live" (Files/LiveLog.txt), "journal" (Logs/YYYYMMDD.log), "tester" (latest tester log). lines: Tail line count. date: Override YYYYMMDD for journal mode. structured: Parse journal lines into ts/source/message records.

deploy_eaA

Copy compiled .ex4/.ex5 binary into Experts/.

Args: source_ex: Path to compiled .ex4/.ex5. name: Optional rename target.

install_includeB

Copy a .mqh into the terminal Include folder (e.g. for LiveLog.mqh).

Args: source: Absolute path to source .mqh. target_name: Optional rename.

list_expertsC

List compiled EAs in Experts/.

read_tester_reportB

Locate and parse latest MT5 tester HTML report.

Args: path: Explicit report path. If omitted, find latest *.htm under Tester/. raw_truncate: Max chars of raw HTML returned.

patch_tester_iniA

Update fields in a tester.ini file in-place.

Args: config: Path to tester.ini. updates: Mapping of Section.Key → value (e.g. {"Tester.Symbol": "EURUSD", "Tester.FromDate": "2025.01.01"}).

Returns dict listing applied + skipped keys.

compile_and_deployC

Compile then deploy resulting .ex5/.ex4 to Experts/ in one shot.

extract_inputsC

Parse input <type> <name> = <default>; declarations from a source file.

gen_tester_inputsC

Generate a [TesterInputs] block from EA inputs.

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

resolve_includesB

Recursively resolve #include directives. Reports unresolved files.

find_symbolB

Grep a symbol across MQL files, skipping comments and string literals.

code_metricsA

Compute LOC/function/nesting metrics for a file or every MQL file under a root.

extract_docB

Extract MetaEditor //+--+ //| ... +--+ doc blocks from a source file.

find_magic_collisionC

Find duplicate magic-number assignments across the project.

syntax_checkA

Compile a source via MetaEditor's syntax-only mode (/s) and return diagnostics.

lint_basicC

Run structural lint rules (missing handlers, unused inputs, hardcoded magic/symbol).

check_deprecatedC

Flag MT4-style deprecated API calls in MT5 source.

validate_tester_iniB

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

format_mqlB

Format an MQL file via clang-format (treats source as C++).

format_checkB

Report whether a file needs formatting without writing it.

rename_symbolB

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

parse_optimizationA

[LEGACY] Best-effort binary .opt parser — unreliable, prefer read_optimization_csv with OptExport.mqh instrumented EA.

Parse the latest .opt file in the Tester folder, or one given by path.

top_passesA

[LEGACY] Best-effort binary .opt parser — unreliable, prefer read_optimization_csv with OptExport.mqh instrumented EA.

Sort optimization passes by criterion and return the top N.

read_optimization_csvA

Read optimization results from the CSV file generated by OptExport.mqh in Common Files folder.

Args: run_id: The run ID specified during optimization run. top_n: Number of top passes to return. criterion: The column name to sort by (e.g. 'profit', 'sharpe_ratio', 'custom_metric'). descending: Set to True to sort from highest to lowest.

compare_reportsB

Diff two MT5 tester HTML reports key-by-key with absolute and percent deltas.

regression_checkC

Verify candidate report stays within guard thresholds vs baseline.

snapshot_sourcesC

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

list_snapshotsB

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_testB

Compile, deploy, run a 1-day headless backtest, and scan the journal for runtime errors.

Returns ok: true only if compilation, deployment, run, and the journal scan all pass.

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.

start_jobA

Start a non-blocking backtest or optimization Strategy Tester run.

Args: config: Absolute path to the tester .ini configuration file. kind: Execution type, either "backtest" or "optimize".

check_job_statusA

Check the status and elapsed duration of a background execution job.

Args: job_id: The job ID returned by start_job.

get_job_resultB

Retrieve full structured results of a completed background job.

Args: job_id: The job ID returned by start_job.

list_jobsA

List recent Strategy Tester execution jobs tracked in the database.

Args: limit: Maximum number of jobs to return (default 20). status: Optional filter by job status (e.g. 'running', 'done', 'failed').

instrument_ea_for_optB

Automatically instrument an MQL5 Expert Advisor (.mq5) file with OptExport.mqh logging.

Args: ea_path: Absolute path to the .mq5 file.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription
livelog_resourceLatest contents of MQL5/Files/LiveLog.txt — clients can re-read for polling updates.
journal_resourceLatest daily MT5 journal log.
tester_log_resourceLatest Strategy Tester journal log.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ptacr/mcp-mt5'

If you have feedback or need assistance with the MCP directory API, please join our Discord server