# M5 — MCP setup guide for agents You are reading the agent onboarding guide for M5, a professional crypto trading terminal (charts, order flow, custom indicator scripts). M5 exposes an MCP server. Once connected you can: report app/workspace status, control the workspace (layouts, widgets, chart layers, draw tools), and create or edit indicator scripts on the user's account — script saves return live compile diagnostics, and edits appear directly in the user's open script editor. If a user pointed you at this file, walk them through the setup below, then start working. ## 1. Get a token (user action — guide them) Ask the user to open `/settings/mcp` on this host in their browser (sign-in required) and: 1. Name the token (e.g. "Claude Code"). 2. Pick a scope preset: - Full control — workspace, charts, draw tools, script editing (recommended default). - Full control + metadata & archive — additionally allows script metadata updates and archiving. Publishing still requires approved builder status. - Read-only — inspection only. 3. Create it and paste the token (starts with `m5_mcp_`) back to you. It is shown only once. ## 2. Register the MCP server (your action) The MCP URL is `/api/mcp`, plus the scope's query params if not "Full control": - Full control + metadata & archive: `?features=status,workspace,widgets,chart,draw,scripts,alerts,scripts_admin` - Read-only: `?read_only=1` Claude Code: claude mcp add m5 --transport http --header "Authorization: Bearer " Codex: export M5_MCP_TOKEN="" codex mcp add m5 --url "" --bearer-token-env-var M5_MCP_TOKEN Other clients (mcp.json-style config): { "mcpServers": { "m5": { "type": "http", "url": "", "headers": { "Authorization": "Bearer " } } } } Transport is MCP Streamable HTTP (JSON-RPC over POST). A new session may be needed for the client to discover tools. ## 3. Verify Call `m5_get_status`. `connected: true` means the user's browser tab is linked and live features work. If `connected: false`: script create/edit and `script_check` still work headless, but ask the user to open M5 in their browser for live features (script editor, save-time compile diagnostics, workspace control). ## 4. Working with scripts (important) - Call `script_api_reference` BEFORE writing or editing any script code. New scripts are scripting v3 (source begins `script ""`); pass `version: 2` only for legacy `//@version=2` scripts. Check v3 code with `script_check` before saving, and look up symbols or diagnostic codes with `script_reference_lookup`. - Resolve "this script" via `m5_get_status`: `sessions[].scriptEditor` is the script open in the editor; `sessions[].charts[].scriptLayers` are scripts on charts. - After `script_create`/`script_update_code`, read `result.diagnostics`: status `error` means the saved code does not compile — fix and save again. - Use `script_editor_open` to show the user your work in their editor, and `chart_add_script` to put a script on the active chart (add a chart widget first if the workspace is empty). ## 5. Good first suggestions for the user - "What's on my chart right now?" - "Create a script that plots VWAP with deviation bands and open it in my editor." - "Take the indicator on my chart and add an ATR-based stop line." Full scripting language documentation: https://docs.mmt.gg/scripting (LLM index at https://docs.mmt.gg/scripting/llms.txt).