Home Security & Best Practices

Security & Best Practices

By Thanh
3 articles

Keeping your terminal key and JWT safe

Your terminal key is the one credential that lets a client act on your MetaTrader terminal — within your subscription's capabilities — for as long as it's valid. Treating it with the same care as a password (or an API key) keeps your account yours. Here's how. Understand what each credential can do - Terminal key (MTMCP-…) — durable. It doesn't expire on its own; anyone holding it can act on the bound terminal until you revoke it. This is the one to protect. - Session token (JWT) — short-lived and auto-refreshed. It's minted from the terminal key, so it's not a separate thing to guard so much as a reason the key matters: whoever has the key can mint tokens. See Session tokens: getting and rotating your JWT. Note that a session token doesn't limit the blast radius of a leaked key — if the key is exposed, revoke the key. Store it well - Keep it in your client's config or a secrets manager — not in a chat message, a screenshot, a shared doc, or a public repo. - Remember the plaintext is shown once at creation. Save it somewhere durable immediately; if you lose it, you generate a new one rather than recovering the old. - Don't commit config files containing the key to version control. If you must, use environment variables or a secrets store and keep them out of the repo. Keep it out of the wrong places - Scrub keys from logs and error reports before sharing them for support. - Be cautious pasting client configs into forums or issues — redact the MTMCP-… value. - On a shared machine, don't leave the key in a world-readable file. The capability floor already limits damage Even a leaked key can only do what your tier allows on the bound terminal — a free-tier key is read-only, and no key can override your broker's rules or bypass the dry_run and equity-guard protections. That's a floor, not a substitute for keeping the key private. If a key leaks — act in this order 1. Revoke the exposed key from Dashboard → Terminal Keys immediately. New sessions stop within seconds. 2. Generate a replacement and deploy it. 3. Remember a session already running may keep working until its cached token expires (within about an hour), then fails to refresh. Full procedure in Rotating or revoking a terminal key. Next steps Round out the security picture with Understanding the dry_run safety model and What MTContext can and can't do. Manage your keys at mtcontext.com/dashboard.

Last updated on Jul 22, 2026

Understanding the dry_run safety model

If you're going to let an AI touch a trading account, you should understand exactly what stops it from doing something you didn't intend. MTContext's answer is the dry_run model, and it's worth understanding in detail. This article goes a level deeper than Placing trades safely with dry_run. Every trade-affecting tool defaults to a dry run It isn't just the "place order" tool. Every tool that can change your account — place_order, close_position, modify_position, modify_order, cancel_order, and partial_close — defaults to dry_run: true. A dry run validates the request and reports exactly what would happen, but sends nothing to your broker. Real execution only occurs when a request explicitly carries dry_run: false. There is no "default to live" anywhere in the system. Two independent gates, not one For a live order to actually reach your broker, two separate conditions both have to be true: 1. The request must explicitly set dry_run: false, and 2. The Expert Advisor on your terminal must have trading enabled (inp_AllowTrading = true). These are independent on purpose. Even if a request were made with dry_run: false, an EA that isn't set to allow trading won't execute it. You can run the EA in a read-and-validate-only mode and know that nothing can trade, regardless of what any client asks. There's also a capability gate above both: trading tools require the trade capability (Pro tier and up). On the free tier the trade tools aren't available at all. What a dry run validates before you ever go live When you do confirm a real trade, it's still checked first and fails safe if anything is off: - Lot size against your broker's minimum, maximum, and step. - Margin against what's actually available in your account. - Broker rules — symbol availability, trading hours, restrictions — which MTContext can validate against but never override. If a check fails, the order is rejected rather than sent. Commands can't fire twice Each command carries a unique identifier and is de-duplicated. If a request is retried — a flaky connection, an over-eager client — the same order won't accidentally execute twice. The account-level backstop Individual trades are one layer; your whole account is another. The server-side equity guard can close positions or block new trades if your equity falls past a limit you set, and it runs independently of whether your AI client is connected. See Setting up equity protection guardrails. The bottom line Nothing trades unless you explicitly pass dry_run: false, the EA is set to allow trading, and your broker accepts the order. Three things have to line up, and each one is under your control or your broker's. Next steps See Placing trades safely with dry_run for the everyday version, and What MTContext can and can't do for the full capability boundary. Explore it free at mtcontext.com — the free tier is read-only, so trading tools are off entirely.

Last updated on Jul 22, 2026

What MTContext can and can't do

Before trusting any tool with a trading account, it's worth knowing exactly where its powers start and stop. This article draws that line for MTContext — what it can do, what it deliberately won't, and what stays entirely in your and your broker's control. What MTContext can do - Read your terminal's state — live prices, spreads, historical bars, account balance and equity, open positions, and order history. - Run analysis — technical indicators (RSI, MACD, ATR, and more), risk-based position sizing, correlation checks, and macro/sentiment context, all surfaced as tools your AI client can call. - Act on your terminal when you ask — place, modify, and close orders, and set guardrails like equity protection — through your AI client, with your confirmation. - Connect your MetaTrader 5 terminal — MT5 is supported today, with MetaTrader 4 support coming soon; one account can connect multiple terminals (within your plan's terminal seats). What MTContext can't (and won't) do - It doesn't decide trades for you. MTContext is the bridge; the AI client does the reasoning and you approve the actions. It doesn't run a strategy on its own in the background. - It doesn't execute trades without confirmation. Trade requests default to a dry run and only execute when you explicitly confirm — see Placing trades safely with dry_run. - It can't override your broker. Lot-size limits, margin requirements, trading hours, and symbol restrictions are enforced by your broker; MTContext validates against them and fails safe, but can't bypass them. - It doesn't touch anything beyond your terminal. It reads and acts on the MetaTrader terminal you've connected — nothing else on your computer. - It won't act while your terminal is offline. If the EA loses its connection, it holds in a safe state rather than firing buffered commands. Who's in control of what Think of it as three layers, each with a clear job. You decide what to ask and confirm any real trade. Your AI client interprets your request and proposes actions. MTContext carries the request to your terminal and validates it. And underneath all of it, your broker has the final say on whether an order is allowed. The honest bottom line Can AI place trades on your MetaTrader account through MTContext? Yes — but only the ones you confirm, only within your broker's rules, and only while your terminal is online. It's a capable assistant with a hard safety floor, not an autonomous bot. Next steps See Understanding the dry_run safety model and Keeping your terminal key and JWT safe to round out the security picture. Explore it free at mtcontext.com — the free tier is read-only.

Last updated on Jul 22, 2026