Skip to content

fix: allow mcp-protocol-version request header in CORS preflight - #137

Open
shoemoney wants to merge 1 commit into
perplexityai:mainfrom
shoemoney:fix/cors-allow-protocol-version-header
Open

fix: allow mcp-protocol-version request header in CORS preflight#137
shoemoney wants to merge 1 commit into
perplexityai:mainfrom
shoemoney:fix/cors-allow-protocol-version-header

Conversation

@shoemoney

Copy link
Copy Markdown

The cors() options in src/http.ts list mcp-protocol-version in exposedHeaders but omit it from allowedHeaders, which only permits Content-Type and mcp-session-id. The official @modelcontextprotocol/sdk StreamableHTTPClientTransport sends the mcp-protocol-version header on every request after initialization, so a browser-based client permitted via ALLOWED_ORIGINS (per SECURITY.md) completes initialize and then fails every subsequent request at the CORS preflight.

Since exposedHeaders already lists the header, the intent to support it is clear. This adds it to allowedHeaders in the server and in the mirrored fixture in src/transport.test.ts, plus a preflight regression test in src/http.config.test.ts asserting Access-Control-Allow-Headers includes mcp-protocol-version.

Full suite passes (90 tests) and tsc builds clean.

The cors() options already expose mcp-protocol-version via exposedHeaders,
but allowedHeaders omitted it. The official StreamableHTTPClientTransport
sends mcp-protocol-version on every request after initialize, so any
browser-based client permitted via ALLOWED_ORIGINS failed the CORS
preflight once initialization completed. Add the header to allowedHeaders
in the server and in the mirrored transport test fixture, and add a
preflight regression test.
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