# MCP for AI agents

The site runs a Model Context Protocol server (Streamable HTTP, stateless, JSON responses; protocol versions 2025-03-26 to 2025-06-18) at:

    https://mmlprostudio.com/functions/mcp

**Authentication.** The site owner gets the link, with its key, on the AI Connect page (https://mmlprostudio.com/ai). Pass the key as `?key=…` in the URL or as `Authorization: Bearer …`. Without the right key the endpoint answers 404 (the key is the only credential, so keep it out of logs). The owner can rotate it or switch the connection off at any time. There is no OAuth; agents that need a per-user connection use a member's key when that ships (see roadmap).

**Discovery.** `GET https://mmlprostudio.com/functions/mcp?card=1` returns the public server card (no key needed); `https://mmlprostudio.com/.well-known/ai-catalog.json` and `https://mmlprostudio.com/.well-known/mcp/server-card.json` carry the same.

**How to work.** Call `start_here` first in every chat. Read before you write (`get_scene` before `update_scene`), check before you save (`check_mml`), prefer small edits, and save a handoff note with `save_project` before you stop. Every save keeps a version; `restore_version` undoes. Errors come back as tool results with `isError: true` and a message that says what to fix. Results are JSON; big texts are paged (`offset`, `max_chars`).

## Tools (34)

| Tool | Writes | What it does |
|---|---|---|
| `start_here` | no | Call this first in every new chat. Returns the projects (with their latest handoff note), recent scenes, the live server status, and how to continue. No input needed. |
| `mml_guide` | no | Reference for writing MML that works in Otherside's Swamp and Nexus. Topics: overview, elements (every tag and attribute), cavekit (server runtime: smooth motion, timers, players, saved state), targets (which tags each Otherside target supports: documented vs observed in tests, and m-interaction vs ODK priority), otherside (platform rules), avatars (characters, sockets, specs), building (dungeons, doors, triggers, patterns), performance, live (watch-and-guide builds with live_preview and build_step), export (optimizing models for fast loading and low graphics settings), workflow. |
| `list_scenes` | no | List the user's scenes (slug, name, live, size, players online, links). Optional search text matches name, slug and description. |
| `get_scene` | no | Read a scene's MML source by slug, with its links and a check summary. Long sources come in pages: pass offset (character index) to read the next page. |
| `check_mml` | no | Check MML for problems in Otherside (unclosed tags, see-through labels, http or .gltf assets, stutter-causing scripts, wrong clock). Pass source, or a slug to check a saved scene. |
| `live_status` | no | What's happening on the live server: which scenes run, players online, and for one scene (slug) its connections, recent events and script logs (CaveKit.log and console output). Use it to debug. |
| `optimization_report` | no | How export-ready a scene's models are: size, triangles, whether each uses an optimized copy, and which formats the optimizer will use (chosen from the knowledge bank: Draco + JPEG/PNG + power-of-two textures ≤2048 for Otherside by default). The site's Export tab does the optimizing (it runs in the browser); apply_optimized_assets swaps in copies that already exist. |
| `apply_optimized_assets` | yes | Swap every model in a scene for its optimized copy when one already exists (made in the Export tab or for another scene with the same recipe). Keeps the old source as a version, saves, and updates the live scene. |
| `scene_insights` | no | What real players do, from the Cave server's telemetry (last 7 days): visits, unique/returning players, median stay, how visits end (dropped = crash/freeze/disconnect), latency, interactions, update traffic per player, script errors. With a slug: that scene's health score (0-100) and the fixes that would help most. Without: the overview, every active scene's score, and the automatic settings the site chose (export profile). Check this before optimizing or redesigning a scene. |
| `test_suite` | no | The site's Otherside test suite (one live scene per file format, compression, interaction, movement, sync, lighting and stress case). Returns every module with its wss:// link, what to check, and results so far: saved verdicts per world (Swamp/Nexus), plus live in-world data (visits, load time from the blue button, button verdicts, quick disconnects that may be crashes, script errors). Use it to see what's proven and what still needs testing. |
| `record_test_result` | yes | Save a result the user reports for a test-suite module (e.g. 'T04 is white in the Swamp on Low'). Saving a result never changes the knowledge bank or export switches: knowledge changes need a review first (update_knowledge is accepted but ignored). |
| `list_versions` | no | Saved versions of a scene, newest first (id, note, size, date). Use with get_version or restore_version. |
| `get_version` | no | Read the source of one saved version (from list_versions). |
| `list_assets` | no | Files the user uploaded (GLB models, images, audio, video) with their public https URLs, for use in src attributes. |
| `list_prefabs` | no | The user's saved reusable MML pieces (characters, props, rooms, effects) with their markup, ready to paste into a scene. |
| `generate` | no | Generate ready-to-use MML (does not save). kinds: ${Object.entries(GENERATORS).map(([k, g]: [string, any]) => |
| `list_projects` | no | All projects with their scenes and when they were last worked on. |
| `open_project` | no | Resume a project: returns its goal, full notes (including handoff notes from earlier chats), its scenes with links and check summaries, and recent AI activity. Pass the project id or name. |
| `knowledge` | no | What has been tested to work, break or partly work in the Swamp, the Nexus and ODK worlds, plus limits and best practices (status: works, broken, partial, untested, rule). Follow this over general MML knowledge. Filter by search text, tag (e.g. m-audio), status or world. |
| `list_free_assets` | no | Free models, images and sounds anyone can use (https, cross-origin friendly), with triangle counts, size in metres and a ready MML tag for each. |
| `get_guidance` | no | Read what the user said while watching the live build (messages, objects they pointed at) and whether they paused you. Call between build steps; build_step and update_scene also include it. |
| `build_step` | yes | Add or change ONE piece of a scene while the user watches (e.g. 'floor and walls', then 'torches', then 'treasure room'). Use append for new MML or edits for exact find/replace. Saves a version first (so the user can undo the step), updates the live preview, and returns the triangle count and any guidance the user sent. If the user paused you, it refuses: wait for them. |
| `record_finding` | yes | Paused: knowledge-bank changes now need a review, so this saves nothing and changes nothing. To keep what the user found, save it as a test result with record_test_result (module, world, verdict, notes) and tell the user the knowledge bank changes only after a review. |
| `create_scene` | yes | Create a new scene from MML and (by default) start it on the live server. Returns the wss:// link for the Swamp or Nexus. Optionally adds it to a project. |
| `update_scene` | yes | Change a saved scene. Use ONE of: edits (list of exact find/replace pairs, preferred for small changes), append (MML added at the end, e.g. from generate), or source (replace everything). The previous source is kept as a version first. Returns the check summary. |
| `restore_version` | yes | Put a saved version back as the scene's current source (the current source is kept as a version first, so this can be undone too). |
| `set_scene_live` | yes | Start (live: true) or stop (live: false) a scene on the live server. Stopping disconnects players from it; the scene stays saved. |
| `set_scenes_live` | yes | Start, stop or restart many scenes in one call (the Scenes page's Stop all / Restart all). action: start \| stop \| restart. slugs: the scenes; or all: true for every one of the user's scenes. Restart = stop, wait until the server has dropped them (up to 45 s), start again: everyone in them is disconnected for a few seconds and the scenes load fresh from their files (saved state stays). |
| `restart_scene` | yes | Restart one scene from its starting position: stop it, wait until the live server has dropped it (up to 45 s), start it again. Everyone in it is disconnected for a few seconds; saved state (scores, verdicts) stays. For a changed scene this is not needed: saving hot-reloads it with players connected. |
| `delete_scene` | yes | Delete a scene for good: it is stopped first (players disconnected, the link stops answering), then the record is removed. Its saved versions are kept. Ask the user before calling this; pass confirm_slug equal to the slug to show you did. |
| `search_docs` | no | Search the site's documentation for agents (MML reference, CaveKit, Otherside rules, limits, export, workflow, the MCP tools, FAQ) and the knowledge bank. Returns the matching passages with their doc URLs. Use it when you are unsure how something works here. |
| `preview_mml` | yes | Run MML as a temporary scene on the live server without saving it (expires after 15 idle minutes). Returns a browser preview link and a temporary wss:// link. |
| `save_project` | yes | Create or update a project. Use append_note for a dated handoff note (what changed, decisions, next steps) so a new chat can continue; notes replaces all notes. add_scenes/remove_scenes manage which scenes belong to it. Omit project to create a new one (name required). |
| `save_prefab` | yes | Save a reusable MML piece (character, prop, room, effect) to the user's prefab library, so it can be placed again from the site's editor or by any AI chat. Saving with an existing name updates it. |

Guide topics for `mml_guide`: overview, elements, cavekit, targets, otherside, avatars, building, performance, live, export, workflow.

## Server instructions (sent on initialize)

You are connected to MML ProStudio (www.mmlprostudio.com), CaveMan's studio for building live MML (Metaverse Markup Language) scenes that run in Otherside's Swamp and Nexus.

How to work:
1. In every new chat, call start_here first. It lists the projects, recent scenes and the live server, and tells you how to pick up where the last chat stopped.
2. Working on a project? Call open_project to read its notes and scenes. Before you stop, or when the user changes direction, call save_project with a short handoff note (what changed, what's next), so the next chat can continue.
3. Read before you write. Use get_scene before update_scene. Prefer small edits (update_scene with edits) over resending a whole scene. Every save keeps a version, so restore_version can undo.
4. Check before saving: run check_mml on new or changed MML and fix errors first.
5. Use generate for dungeons, mazes, rooms, stairs, arrays, characters and signs instead of writing hundreds of cubes by hand. Use list_prefabs, list_assets and list_free_assets for ready-made parts and models.
8. LIVE BUILDS: when the user wants to watch or guide a build (or any build bigger than a few objects), call live_preview first (it shows a live 3D view in the chat and gives page_url, a full-page live view for a side browser). Then build piece by piece with build_step: one meaningful piece per call (floor, walls, lighting, props, scripts), each with a short title. Every result includes user_guidance (what the user said or pointed at) and paused; follow the guidance before the next step, and if paused, stop and wait. Keep an eye on the triangle count in each result.
9. The knowledge tool holds what has been tested to work (or break) in the Swamp/Nexus. Follow it over general MML knowledge. When the user reports a test result from Otherside, save it with record_test_result; the knowledge bank changes only after a review.
11. PLAYER DATA: scene_insights shows what real players do (visits, drops/crashes, stay time, latency, interactions, update traffic) and each scene's health score with fixes. Use it before optimizing or redesigning, and after changes to see if they helped. The site also picks the default export profile from this data automatically, plus per-scene budgets (Otherside profile: textures up to 2048 px, up to 8 lights, up to 3000 elements; Low-end profile: 1024 px, 4 lights, 1500 elements). Build new scenes within the current budget. Players' graphics settings (Low/Medium/High/Epic) come from the report buttons in test scenes.
10. EXPORTS: before sharing a finished scene's wss:// link, call optimization_report. Models should use optimized copies (Draco geometry, power-of-two textures ≤2048, JPEG colour/PNG normal maps) so they load fast and still appear on the lowest graphics settings. Use apply_optimized_assets when copies exist; otherwise tell the user to click 'Optimize all models' in the editor's Export tab. Only formats marked works in the knowledge bank are used for Otherside.
6. Use preview_mml to try something without saving. It returns a browser link and a temporary wss:// link.
7. Give the user the wss:// link after creating a scene. That link is what they paste into the Swamp or Nexus.

Rules for MML in the Swamp and Nexus (tag support is narrower than the MML spec and differs by target: read mml_guide targets before using m-interaction, m-prompt, m-audio, m-link, the probes or m-attr-lerp, and say what is documented vs observed):
- Scripts run on the server. Use the shared document clock (document.timeline.currentTime or CaveKit.now()), never Date.now(), for anything players see.
- Move things with m-attr-anim or CaveKit.moveTo/spin, not setInterval loops under 200 ms (they stutter).
- m-attr-anim loops forever unless loop="false".
- Label backgrounds must be solid colours (see-through label backgrounds render invisible).
- Models must be https .glb files with textures packed inside (.gltf shows white).
- Keep scenes lean: merge walls into long cubes, reuse models, keep total elements in the low thousands.
- Keep a whole project under 1,000,000 triangles (all models, avatars and shapes combined). Tool results report the scene's triangle count; single assets should stay under 150,000.
Call mml_guide for the full element reference, CaveKit, avatars, building patterns and performance.

## Connecting

- **Claude (claude.ai, desktop, Code):** add a custom connector / MCP server with the URL from AI Connect (the key is in the URL).
- **ChatGPT:** developer mode → add the MCP server URL; approve writes when asked.
- **Cursor, Windsurf, Gemini CLI and others:** `{"mcpServers": {"mml-prostudio": {"url": "https://mmlprostudio.com/functions/mcp?key=…"}}}`.
- **Plain HTTP:** POST JSON-RPC 2.0 (`initialize`, `tools/list`, `tools/call`) with `Content-Type: application/json`; batches of up to 20.
