feat: relay MCP runtime calls through the editor - #2217
Open
kpal81xd wants to merge 3 commits into
Open
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 overpostMessage.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— nomcp_portwhen 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.use_local_frontend/use_local_engineoverrides, 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
mcp_port; both return, logs including warnings from before the bridge attached.Checks