Skip to content

feat: relay MCP runtime calls through the editor - #2217

Open
kpal81xd wants to merge 3 commits into
mainfrom
feat/mcp-runtime-relay
Open

feat: relay MCP runtime calls through the editor#2217
kpal81xd wants to merge 3 commits into
mainfrom
feat/mcp-runtime-relay

Conversation

@kpal81xd

@kpal81xd kpal81xd commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What's Changed

Chromium gates public→loopback behind a per-origin permission (Chrome 142+, websockets from 147). The launch page is a different origin, so runtime tools needed a second grant — requested silently while a popup loaded. The Editor now holds the only socket and relays runtime:* to the launch window over postMessage.

  • mcp/relay.ts (new) — offers a channel to a launch window and tells the server what it can reach. The Editor makes first contact (the window's opener is severed); the page then keeps announcing itself, so a reloaded Editor re-adopts a still-running app.
  • mcp/launch.ts — no mcp_port when relaying; adopts a running app when no options are requested; one verified close path for relaunch and stop, since a window whose opener we severed cannot be closed from the Editor.
  • launch/mcp/runtime.ts — answers relayed calls, closes on request, buffers console output from the first frame. Still dials the server directly when handed a port.
  • mcp/connection.ts, mcp/toolbar.ts — read the server's greeting; report when the browser is blocking the connection instead of sitting on Connecting.
  • viewport-launch.ts — the Launch button hands its window to the relay.
  • MCP launches carry the use_local_frontend / use_local_engine overrides, so a local build launches the local launch page.

Needs playcanvas/editor-mcp-server#102 for relay mode; both sides fall back to the old path.

Smoke test

  1. Open a project, select MCP, connect. Expected: Connected, or a popover hint to allow Apps on device if the browser blocks it.
  2. Ask an assistant to start a Launch instance, screenshot it and read its logs. Expected: URL has no mcp_port; both return, logs including warnings from before the bridge attached.
  3. Ask again while that app runs. Expected: it attaches, no second window.
  4. Ask with mini stats enabled. Expected: the old window closes, the new one shows the overlay.
  5. Reload the Editor tab, reconnect, ask for a screenshot. Expected: the running app answers, no relaunch.
  6. Press the Editor's Launch button while connected, ask for a screenshot, then stop the instance. Expected: screenshot works; the window closes.
  7. Check the launch origin in Chrome site settings. Expected: no local access grant, yet all of the above worked.

Checks

The launch page is a different origin to the editor, so reaching the MCP server
itself needed its own local network access grant (Chrome 142+, websockets from
147) — requested silently while a popup loaded, and a no-op when refused. The
editor now holds the only socket and forwards `runtime:*` calls to the launch
window over postMessage, so one grant covers everything.

First contact comes from the editor, since the launch window's opener is severed.
After that the launch page keeps announcing itself, which lets a reloaded editor
re-adopt a still-running app instead of losing the runtime peer. Console output
is captured from the first frame so an adopted window has complete logs.

launch:start with no options adopts a running app rather than restarting it; any
option forces a fresh launch. Both relaunch and launch:stop now close the current
window through one path that asks the page to close itself and confirms it went —
a window whose opener we severed cannot be closed from the editor, which is also
why the opener is only severed when relaying.

The MCP popover reports when the browser is blocking the connection, and MCP
launches now carry the use_local_frontend/use_local_engine overrides the editor
was loaded with.
@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
editor Ready Ready Preview Aug 24, 2026 3:28pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant