Home Connecting Your AI Client

Connecting Your AI Client

By Thanh
6 articles

Connecting Claude Desktop

Connect Claude Desktop to your MetaTrader terminal and you can ask it, in plain English, for live prices, your account state, indicators, and — when you choose — trades. There's no Python and no local server to run: MTContext's cloud does the bridging, and Claude Desktop just needs one config block. This takes about five minutes and assumes you've already subscribed, installed the Expert Advisor on your terminal, and have your terminal connected. If you haven't installed the EA yet, read the Installing the EA on MT5 article first. What you need - Claude Desktop installed on your computer - An active MTContext account and license key (from your dashboard) - Your MetaTrader terminal running with the MTContext EA attached and showing connected Step 1 — Copy your config snippet from the dashboard In your MTContext dashboard, open the terminal you want to connect and copy the ready-made MCP config snippet. It looks like this, already filled in with your endpoint and key: { "mcpServers": { "mtcontext": { "type": "http", "url": "https://mcp.mtcontext.com/mcp/v1", "headers": { "Authorization": "Bearer YOUR_LICENSE_KEY" } } } } Always use the snippet from your dashboard rather than copying this one — yours has your real key already inserted. Step 2 — Open Claude Desktop's config file In Claude Desktop, go to Settings → Developer → Edit Config. That opens claude_desktop_config.json. You can also open it directly: - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json - Windows: %APPDATA%\Claude\claude_desktop_config.json Step 3 — Paste in the MTContext block Paste the mtcontext entry inside mcpServers. If you already have other MCP servers configured, add mtcontext alongside them rather than replacing the file. Save the file. Step 4 — Restart Claude Desktop Fully quit and reopen Claude Desktop so it reloads the config. When it restarts you should see MTContext listed among the available tools (look for the tools/plug icon in the message box). Step 5 — Confirm it works Ask Claude something read-only, for example: "Using MTContext, what's the current EURUSD bid and ask?" If Claude returns a live quote, you're connected. Read-only requests like this are completely safe — nothing touches your account. Troubleshooting - MTContext doesn't appear after restart — check the JSON is valid (a missing comma or brace is the usual cause) and that the block is inside mcpServers. - "No terminal connected" — your terminal isn't online. Confirm MetaTrader is running with the EA attached and showing connected; see the EA won't connect / shows "disconnected" article. - Auth error — the license key in the config doesn't match your account. Re-copy the snippet from the dashboard. Next steps Once you're getting live prices, see Checking prices, bars, and account state to learn what else you can ask, and Placing trades safely with dry_run before you let Claude touch an order. Ready to try it? Start free at mtcontext.com — the free tier includes read-only market data with no card required. Full setup reference lives in the documentation.

Last updated on Jul 25, 2026

Connecting Claude Code

Claude Code — Anthropic's command-line coding agent — is an MCP client, so it can connect to your MetaTrader terminal through MTContext and pull live prices, account state, and (when you choose) place trades, right from your terminal or IDE. Setup is a single command. This assumes you've subscribed, installed the EA, and your terminal shows connected. If not, start with Installing the EA on MT5. Get your endpoint and key From your MTContext dashboard, copy your MCP endpoint URL (https://mcp.mtcontext.com/mcp/v1) and your license key. You'll pass both to Claude Code. Add MTContext with one command MTContext is an HTTP MCP server, so add it with the HTTP transport and an Authorization header: claude mcp add --transport http mtcontext https://mcp.mtcontext.com/mcp/v1 \ --header "Authorization: Bearer YOUR_LICENSE_KEY" Replace YOUR_LICENSE_KEY with your real key. Add --scope user if you want MTContext available across all your projects rather than just the current one. Verify it's registered List your MCP servers and confirm MTContext connected: claude mcp list You should see mtcontext with a connected status. Inside a Claude Code session, you can also run /mcp to see it and its tools. Confirm it works In a Claude Code session, ask a read-only question: "Using MTContext, what's my current account balance and open positions?" A live answer means you're connected — and read-only requests never touch your account. Troubleshooting - Not connected in claude mcp list — re-check the URL and that the Authorization header includes Bearer before the key. - "No terminal connected" — the terminal is offline; confirm the EA is attached and connected. - Auth error — the key is wrong or expired; re-copy it from the dashboard. Next steps See Checking prices, bars, and account state for what to ask, and Placing trades safely with dry_run before enabling trades. Start free at mtcontext.com · full reference in the documentation.

Last updated on Jul 25, 2026

Connecting Cursor

Cursor speaks the Model Context Protocol, so you can connect it to your MetaTrader terminal through MTContext and ask its AI for live prices, account state, and trades — right from your editor. Setup is the same idea as any MCP client: add one config block with your MTContext endpoint and key. This assumes you've subscribed, installed the EA, and your terminal shows connected. If not, start with Installing the EA on MT5. Get your config snippet In your MTContext dashboard, copy the MCP config snippet for the terminal you want to connect. It contains your endpoint and license key already filled in: { "mcpServers": { "mtcontext": { "type": "http", "url": "https://mcp.mtcontext.com/mcp/v1", "headers": { "Authorization": "Bearer YOUR_LICENSE_KEY" } } } } Use your dashboard's snippet — it always the latest snippet, you still have to replace the placeholder with your real key. Cursor 1. Open Settings → MCP (or Cursor Settings → Tools & Integrations → MCP), and choose Add new MCP server — or edit ~/.cursor/mcp.json directly. For a single project, use .cursor/mcp.json in the project root instead. 2. Add the mtcontext entry inside mcpServers, alongside any existing servers. 3. Save. Cursor picks up the change; if it doesn't, toggle the server off and on in the MCP settings, or restart Cursor. 4. In the MCP settings you should see mtcontext with a green/active status and its tools listed. Confirm it works In the editor's AI chat, ask a read-only question: "Using MTContext, what's the current XAUUSD spread?" A live answer means you're connected. Read-only calls never touch your account. Troubleshooting - Server shows red / not connecting — check the JSON is valid and the block sits inside mcpServers. - "No terminal connected" — your terminal is offline; confirm the EA is attached and connected. - Auth error — re-copy the snippet from the dashboard so the key matches. Next steps See Checking prices, bars, and account state for what to ask next, and Placing trades safely with dry_run before enabling trades. Start free at mtcontext.com · full guide in the documentation.

Last updated on Jul 26, 2026

Connecting other MCP clients

MTContext isn't tied to one AI app. It's a standard Model Context Protocol (MCP) server, so any compliant client can connect with two pieces of information. If your client isn't one of the ones with a dedicated guide, this article is for you. The hosted endpoint MTContext's hosted server is a standard Streamable HTTP MCP server: https://mcp.mtcontext.com/mcp/v1 Authenticated with a single header: Authorization: Bearer MTMCP-YOUR-TERMINAL-KEY Any MCP client that supports Streamable HTTP transport with custom headers can connect using just that URL and header — check your client's docs for where it wants each. After connecting, the client calls tools/list and shows the tools your subscription tier includes. There's no MTContext-specific plugin to install; it's plain MCP throughout. If your client only speaks stdio Many MCP clients only know how to launch a local process over stdio, not connect to a remote HTTPS endpoint. For those, use mcp-remote, a small local bridge: npm install -g mcp-remote Then point your client at: mcp-remote https://mcp.mtcontext.com/mcp/v1 with the Authorization: Bearer MTMCP-YOUR-TERMINAL-KEY header attached. The Connecting Claude Desktop, Connecting Claude Code, and Connecting Cursor articles are all concrete examples of this same pattern. Do you need a terminal key? For the hosted endpoint, yes — a terminal key already bound to a terminal is the only credential. See the Activating your license key article for how to generate and bind one. Troubleshooting - Server unreachable — verify HTTPS egress and any proxy/TLS interception rules on your network. - tools/list empty or partial — check your subscription tier and account context; tools appear based on capability. - Auth failures — confirm the Bearer format and that the key is valid and bound. Next steps New to the key concept? Read Activating your license key. Want the overview of every client option? See Connect any AI client to MetaTrader. Get your key at mtcontext.com or browse the full setup documentation.

Last updated on Jul 26, 2026

Connect any AI client to MetaTrader

MTContext connects your MetaTrader terminal to the AI client you already use — there's no single "MTContext app" you have to adopt. Whatever supports the Model Context Protocol (MCP) can talk to your MetaTrader 5 terminal through one hosted endpoint (MetaTrader 4 support is coming soon). This page is the map to every connection guide. The pattern is the same everywhere No matter which client you use, the shape of the setup is identical: 1. Generate a terminal key in your dashboard and bind it to your terminal (see Activating your license key). 2. Point your client at the hosted MCP endpoint, https://mcp.mtcontext.com/mcp/v1. 3. Authenticate with one header: Authorization: Bearer MTMCP-YOUR-TERMINAL-KEY. Once connected, your client lists the tools your subscription tier includes and you can start asking for prices, indicators, and (on paid tiers) trades. Every client guide below is a concrete version of these three steps. Pick your client - Claude Desktop — the most common starting point. See Connecting Claude Desktop. - Claude Code — for a terminal-based, developer workflow. See Connecting Claude Code. - Cursor — an AI code editor. See Connecting Cursor. - Any other MCP client — the standard Streamable HTTP endpoint, plus mcp-remote for stdio-only clients. See Connect any MCP client to MetaTrader. No Python, one file on the terminal side Whichever client you choose, the MetaTrader side is the same one-file Expert Advisor and no Python — see Do I need Python to use AI with MetaTrader? if that's a concern. The client is just how you talk to it. Not sure which to use? If you're new, start with Claude Desktop — it's the smoothest first setup and everything you learn there transfers directly to the other clients, because it's the same terminal key and the same endpoint underneath. Next steps Once your client is connected, see Checking prices, bars, and account state for your first read-only prompts. Start free at mtcontext.com — one key works across every client.

Last updated on Jul 26, 2026

Session tokens: getting and rotating your JWT

Most people never touch a session token — the hosted server handles it invisibly. But if you're building custom tooling or debugging an auth issue, it helps to know what's happening under the hood. This article explains the two-credential model. Two credentials, two lifetimes MTContext uses two things: - Your terminal key (MTMCP-…) — a durable credential that doesn't expire on its own; it only stops working when you revoke or rotate it. - A session token (a JWT) — short-lived, and what actually authorizes each request to the trading gateway. Your client never sends the terminal key to the gateway directly for every call. Instead, the key is exchanged for a session token, and that token is what's used until it expires and a fresh one is fetched. The automatic path (what you normally use) When you connect through a standard MCP client — Claude Desktop, Cursor, or the hosted endpoint via mcp-remote — the hosted server performs the exchange and refreshes the session token transparently on your behalf, before it expires (by default within an hour). You set your terminal key once in the client config and never manage a token again unless the key itself is rotated or revoked. The manual path (CI/CD and custom tooling) If you're scripting against the gateway directly and mcp-remote doesn't fit, you can exchange the terminal key for a token yourself: JWT=$(curl -s -X POST https://gateway.mtcontext.com/api/token \ -H "Authorization: Bearer MTMCP-YOUR-TERMINAL-KEY" | jq -r .token) In this mode you are responsible for refreshing the token before it expires (default 24h in the direct-exchange flow). That's exactly the bookkeeping the mcp-remote/hosted path does for you, which is why it's the recommended default for everything except automation. Rotating You don't rotate a session token directly — you let it expire and a new one is issued. What you rotate is the terminal key it's minted from; see Rotating or revoking a terminal key. After a key is revoked, any session token already issued from it keeps working only until it expires and then fails to refresh. Next steps If a client is failing to authenticate, see Auth errors and expired tokens. For the security angle on both credentials, see Keeping your terminal key and JWT safe. Get your terminal key at mtcontext.com/dashboard.

Last updated on Jul 22, 2026