Skip to main content
Glama
ak40u

mt4ctl

by ak40u

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
MT4CTL_CONFIGNoPath to the terminals.yaml configuration file. Defaults to ~/.config/mt4ctl/terminals.yaml or ./terminals.yaml.

Capabilities

Features and capabilities supported by this server

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

Tools

Functions exposed to the LLM to take actions

NameDescription
mt4_listA

List configured terminals with host, account, and environment.

Read-only and offline (no SSH). Use this first to learn which terminal ids exist before calling status/logs/control.

mt4_statusA

Report health of one terminal or all of them.

Queries hosts concurrently and shows, per terminal: systemd service state, broker connection (per-terminal, via socket attribution), and how long since the log was last written. CONN=up plus SERVICE=active means healthy.

Args: terminal: a terminal id, or "all" (default).

mt4_logsA

Return the tail of a terminal's newest log file.

Args: terminal: terminal id. pattern: optional case-insensitive regex to grep (e.g. "login|error"). lines: number of trailing lines to return (1-1000).

mt4_controlA

Start, stop, or restart a terminal's systemd unit.

Mutating a live terminal requires confirm=true.

Args: terminal: terminal id. action: one of "start", "stop", "restart". confirm: must be true to act on a terminal tagged env=live.

mt4_loginA

Perform a one-time headless login so a migrated terminal can auto-reconnect.

Needed when a terminal was copied to a new host: MetaTrader's saved password is machine-bound and must be re-entered once. After this succeeds the unit auto-logins on every restart. Live terminals require confirm=true.

Args: terminal: terminal id. server: broker server name, e.g. "ExampleBroker-Demo". account: login number; defaults to the terminal's configured account. password: explicit password; otherwise resolved from env/secrets file. confirm: must be true to act on a terminal tagged env=live.

mt4_screenshotA

Capture a screenshot of a terminal's window (PNG).

Useful to visually confirm the chart, the AutoTrading state, and the EA smiley. On shared-display hosts the target window is raised first.

Args: terminal: terminal id.

mt4_doctorA

Diagnose the mt4ctl setup without mutating anything.

Checks the registry, the secrets-file permissions, and — per host — SSH reachability, required remote tools, systemd units, and data directories. Run this when a terminal is unexpectedly unknown or mt4_status looks wrong. Read-only and safe.

mt4_ea_listA

List the expert advisors (strategies) attached to terminals.

For a single terminal, lists every attached EA; for "all", shows the count per terminal. Read-only (parses the terminal's chart files).

Args: terminal: a terminal id, or "all" (default).

mt4_autotradingA

Report whether algo-trading is enabled — terminal master switch + per-EA.

Shows the terminal-level AutoTrading button (from terminal.ini) and how many attached experts have live-trading enabled. Flags terminals whose master is off (nothing trades) or whose experts have non-uniform/disabled flags.

Note: the per-EA live-trading flag is a best-effort decode of the MT4 chart-expert bitmask; the terminal master switch is authoritative.

Args: terminal: a terminal id, or "all" (default).

mt4_infoA

Report each terminal's build, broker server, and last broker ping.

Read-only (parsed from the terminal's log). Useful to confirm what build and broker a terminal is on and its connection latency.

Args: terminal: a terminal id, or "all" (default).

mt4_deployA

Deploy a strategy bundle to a terminal — idempotent, managed-subset.

Pushes pre-built charts + experts so the terminal's managed files match the bundle, while leaving foreign files (e.g. a watchdog's chart) untouched. This is apply-only: it does NOT select strategies, set lots/magic, generate charts, or compile — the caller owns the bundle's contents.

bundle is a LOCAL directory on this machine (read here and pushed over SSH — NOT a path on the remote host). It mirrors the MT4 layout:

<bundle>/
  profiles/default/<name>.chr        # ready charts (one expert each)
  MQL4/Experts/<folder>/<ea>.ex4     # the experts those charts reference

Always run with dry_run=true first to preview the add/update/remove/foreign plan. Re-running the same bundle is a no-op (reports "no changes"). A terminal tagged env=live requires confirm=true. There is no rollback command: to recover, re-deploy the previous bundle (a pre-apply backup is also retained and is restored automatically if an apply fails).

reset_market_watch deletes symbols.sel in the stopped window (backed up first) so MT4 rebuilds Market Watch on the deploy's own start — caps unbounded symbol carry-over; it forces a stop/start cycle even with no file changes. After the restart, verify polls up to verify_timeout seconds rather than taking a single snapshot, so normal reconnect timing is not reported as a failed deploy.

Args: terminal: terminal id. bundle: local bundle directory path. dry_run: preview the plan without changing anything (no lock, no upload). confirm: must be true to deploy to a terminal tagged env=live. reset_market_watch: rebuild Market Watch by deleting symbols.sel while stopped. verify_timeout: seconds to poll post-restart health before reporting (default ~120).

mt4_adoptA

Take an already-running terminal under mt4ctl management (first cutover).

On a terminal whose strategies were NOT placed by mt4ctl, the first mt4_deploy refuses (every existing file is an unmanaged-overwrite). Run mt4_adopt once first: it records the bundle's footprint into the manifest at the files' current on-disk hashes, so deploy can reconcile from there.

This is RECORDS-ONLY: it changes NOTHING — no upload, no restart, no preview. It is bundle-scoped (foreign files like a watchdog's chart stay foreign) and requires every bundle file to already be present on the host (the premise is the farm runs this bundle; a missing file is refused). A live terminal needs confirm=true.

bundle is a LOCAL directory (the same layout mt4_deploy takes). After adopt, run mt4_deploy <terminal> <bundle> --dry-run to confirm a clean "no changes".

Args: terminal: terminal id. bundle: local bundle directory path. confirm: must be true to adopt a terminal tagged env=live.

mt4_verifyA

Poll a terminal until it is healthy (service active + broker connected) or times out.

Use after any restart to wait out the broker reconnect instead of guessing: instead of one snapshot it polls and reports the terminal's state at timeout, so a real failure is distinguishable from normal startup timing. Read-only.

Args: terminal: terminal id. timeout: seconds to poll before reporting (default ~120).

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

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/ak40u/mt4ctl'

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