MCP Apps CSP: connectDomains with ws:// / http:// scheme is forcefully rewritten to https://, blocking local WebSocket connections

Open 💬 0 comments Opened Jun 29, 2026 by hzy

What version of the Codex App are you using (From “About Codex” dialog)?

26.623.61825 (Build 4548)

What subscription do you have?

Pro

What platform is your computer?

Darwin 25.3.0 arm64 arm

What issue are you seeing?

MCP Apps declared connectDomains in _meta.ui.csp are forcefully rewritten to https:// scheme regardless of the original scheme provided by the MCP server. This breaks WebSocket connections to local services.

My MCP server declares:

_meta: {
  ui: {
    csp: {
      connectDomains: [ws://127.0.0.1:21783, ws://localhost:21783]
    }
  }
}

The actual CSP applied to the sandboxed iframe shows:
connect-src 'self' ... https://127.0.0.1:21783 https://localhost:21783 ...

The scheme has been rewritten from ws:// to https://. Per CSP spec, https:// only permits wss:// WebSocket connections, so ws://localhost:21783 is blocked:

Connecting to 'ws://localhost:21783/devtool/connector' violates the following
Content Security Policy directive: "connect-src 'self' ... https://localhost:21783 ..."

I also tried http:// scheme — same result, it gets rewritten to https://.

What steps can reproduce the bug?

  1. Create an MCP server that registers a UI resource (text/html;profile=mcp-app) with _meta.ui.csp.connectDomains containing a ws://localhost:<port> or http://localhost:<port> origin
  2. In the MCP App HTML, attempt to open a WebSocket to ws://localhost:<port>
  3. Observe the CSP violation error — the host rewrites the declared scheme to https://

Feedback ID: 019f12a3-aa47-77f3-871f-db1993b98547

What is the expected behavior?

The host should preserve the scheme declared in connectDomains when constructing the CSP connect-src directive. At minimum, ws:// and http:// should be allowed for localhost/127.0.0.1 origins, as local dev tooling (debuggers, language servers, dev servers) commonly uses plain WebSocket without TLS.

The @modelcontextprotocol/ext-apps type definition (McpUiResourceCsp.connectDomains) explicitly documents WebSocket support with examples like "wss://realtime.service.com", implying scheme should be respected.

Additional information

_No response_

View original on GitHub ↗