Repository navigation
fix(mcp-apps): authorize wss:// for app connect domains - #7765
Merged
Merged
Conversation
An MCP app that declares an https connect domain (resource `_meta.ui.csp. connectDomains`) still can't open a WebSocket to it: the injected `connect-src https://host` does NOT authorize `wss://host` — CSP does not derive the WebSocket scheme from an https: source (verified in Chrome: the socket is blocked inside the sandboxed iframe, while identical from the top document it connects). Apps can't work around it — validateDomains only accepts http(s). The injector now adds each connect domain's WebSocket-scheme equivalent (https→wss, http→ws), originals first so fetch/XHR matching and existing output are unchanged. This unblocks realtime (Yjs) co-editing in MCP apps. Co-Authored-By: Claude Opus 4.8 <[email protected]>
decocms Bot
pushed a commit
that referenced
this pull request
Oct 7, 2026
PR: #7765 fix(mcp-apps): authorize wss:// for app connect domains Bump type: patch - @decocms/shared (packages/shared/package.json): 0.136.0 -> 0.136.1 Deploy-Scope: both
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
MCP apps declare allowed connect origins via the UI resource's
_meta.ui.csp.connectDomains, which the CSP injector emits asconnect-src.But an app that lists
https://hoststill can't open a WebSocket to it:connect-src https://hostdoes not authorizewss://host— CSP does notderive the WebSocket scheme from an
https:source. Apps can't work around it(
validateDomainsonly acceptshttp(s)://).This injector now also emits each connect domain's WebSocket-scheme equivalent
(
https://host→wss://host,http://host→ws://host), originals first soplain fetch/XHR matching and the existing output prefix are unchanged.
Why
Unblocks realtime (Yjs/WebSocket) co-editing in MCP apps. Concretely: the
ritualsapp (weekstarts/weekends) ships live co-editing via a CloudflareDurable Object relay; its iframe currently gets
connect-src https://rituals.deco-cx.workers.devand the WebSocket is silently blocked, so itfalls back to non-live saves.
Evidence
Reproduced in the deployed Studio iframe condition (sandboxed iframe + injected
CSP), hitting the real relay:
connect-srchttps://rituals.deco-cx.workers.devwss://rituals.deco-cx.workers.devhttps://… wss://…(this fix)The same socket connects fine from the top document, confirming it's the
iframe's
connect-srcscheme, not the relay.Scope / risk
Additive and backward-compatible: it only widens
connect-srcto theWebSocket scheme of domains an app already declared. Existing
csp-injectortests pass; added one asserting the
wss/wsentries.🤖 Generated with Claude Code
Summary by cubic
MCP apps that declare
https://connect domains could not open WebSockets to those hosts, because CSP does not derivewss:from anhttps:source. The injector now also emits each connect domain's WebSocket-scheme equivalent (https://host→wss://host,http://host→ws://host), originals first. This unblocks realtime co-editing in MCP apps while leaving existingconnect-srcoutput unchanged for fetch/XHR.Written for commit 3405a15. Summary will update on new commits.