MTContext Docs

How It Works

The path a request takes from your AI client to your MetaTrader terminal.

Four pieces sit between your AI client and your broker:

AI Client (Claude Desktop, Cursor, ...)
        │  MCP over HTTPS or stdio

Cloud Platform — API Gateway + Auth · MCP Server · License Service
        │  MT5: WebSocket   ·   MT4: HTTP long-poll

Your Terminal — MT4/MT5 + the MTContext Expert Advisor
        │  native MT4/MT5 protocol

Your Broker

Your AI client speaks MCP — the same protocol regardless of which client you use. It calls tools like get_tick or place_order; it never talks to your terminal directly.

The cloud platform authenticates the request, checks it against your subscription tier, and routes it to the session for your specific terminal. This is also where equity guards and alerts run continuously, independent of whether an AI client happens to be connected at that moment.

The Expert Advisor is a thin bridge with no trading logic of its own. It maintains an outbound connection to the cloud (WebSocket for MT5, HTTP long-polling for MT4, since MT4 has no native WebSocket support), executes the commands it's sent, and returns the result. If it loses its connection to the cloud, it does not execute anything buffered — connection loss means a safe, idle state, not a queue of pending trades firing later.

Your broker is wherever your terminal is already connected — MTContext works with any MT4/MT5-compatible broker, since the EA talks to the terminal, not the broker directly.

Why outbound-only

The EA always initiates the connection outward to the cloud; nothing connects inbound to your terminal. That's what makes the single-file install possible — no port forwarding, no local server, no firewall configuration on your end.

One terminal, one active session

Each terminal key is bound to exactly one MT4/MT5 terminal, and that terminal holds exactly one active session at a time. If the same terminal connects twice, the newer connection takes over and the older one is dropped — so a stale connection never silently continues to receive commands.

The REST API's place in this picture

The REST API is a second front door into the same cloud platform, sitting alongside the MCP server rather than replacing it. It authenticates callers with a license-scoped API key instead of a terminal-scoped session, exchanges that key for the same kind of JWT the MCP path uses, and dispatches to your terminal through the same gateway — so the capability tiers, dry_run safety default, and equity guards all behave identically regardless of which door a request came through.

On this page