Repository navigation
docs(csp-cors): document CORS headers for the MCP endpoint in browser-based hosts - #801
Open
sja-thedude wants to merge 1 commit into
Open
sja-thedude wants to merge 1 commit into
sja-thedude wants to merge 1 commit into
Conversation
…-based hosts Browser-based hosts (basic-host, web inspectors, web assistants) call the MCP endpoint cross-origin. Servers that hand-roll CORS around createMcpHandler must allow the SEP-2243 headers Mcp-Method and Mcp-Name, or the 2026-07-28 preflight fails and clients fall back to the 2025 handshake.
This branch has not been deployed
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.
Summary
docs/csp-cors.mdcovers CORS for requests an app makes from its iframe, but not the other boundary: a browser-based host (examples/basic-host, web inspectors, web assistants) calling the MCP endpoint cross-origin. This adds a short section for that case.Why
The Express examples use
app.use(cors()), which reflects requested headers, so they work. Servers that hand-roll CORS aroundcreateMcpHandler(Cloudflare Workers, Deno, Bun) usually allow-list headers explicitly. On 2026-07-28 exchanges the TypeScript client also sendsMcp-MethodandMcp-Name(SEP-2243). If those are missing, the preflight fails with "Request header field mcp-method is not allowed by Access-Control-Allow-Headers", and a client usingversionNegotiation: { mode: "auto" }silently falls back to the 2025 handshake or fails to connect. I hit this when a browser-based host connected to a Worker-hosted MCP Apps server.Changes
docs/csp-cors.md: when it applies, a table of the request headers the client sends and when, and a minimalfetch-handler example.Header names were checked against
@modelcontextprotocol/client2.1 (RESERVED_REQUEST_HEADER_NAMESand_applyBodyDerivedHeadersin the Streamable HTTP transport).