fix(http): allow projected MCP headers in preflights - #3167
Open
SamMorrowDrums wants to merge 2 commits into
Open
fix(http): allow projected MCP headers in preflights#3167SamMorrowDrums wants to merge 2 commits into
SamMorrowDrums wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Auto-generated by license-check workflow
Contributor
There was a problem hiding this comment.
Pull request overview
Extends browser CORS preflight support for MCP routing and projected parameter headers.
Changes:
- Adds fixed MCP method, name, owner, and repo headers.
- Validates, deduplicates, sorts, and reflects future
Mcp-Param-*headers. - Expands middleware and router-level CORS tests.
Show a summary per file
| File | Description |
|---|---|
pkg/http/server_test.go |
Tests projected headers through the full router. |
pkg/http/middleware/cors.go |
Implements projected-header preflight handling. |
pkg/http/middleware/cors_test.go |
Covers validation, ordering, deduplication, and preserved behavior. |
pkg/http/headers/headers.go |
Defines MCP projection header constants. |
go.mod |
Promotes x/net to a direct dependency. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 8/9 changed files
- Comments generated: 0
- Review effort level: Balanced
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
Mcp-MethodandMcp-Namerequest headers plus the currentMcp-Param-ownerandMcp-Param-repoprojectionsAccess-Control-Request-Headersvalue onOPTIONSand reflect only valid, non-emptyMcp-Param-*field namesOPTIONSbehaviorExact projected-header contract
CORS has no prefix wildcard, so preflights validate each requested name with
httpguts.ValidHeaderFieldName. Matching is case-insensitive against the exactMcp-Param-prefix and requires a non-empty suffix. Fixed owner/repo entries remain first; future names are case-insensitively deduplicated, sorted, and emitted withhttp.CanonicalHeaderKey. Arbitrary headers, bareMcp-Param-, malformed/control-character names, and lookalike prefixes are omitted.Mcp-Param-*headers are request-only and are not added toAccess-Control-Expose-Headers;Mcp-Session-IdandWWW-Authenticateremain exposed.Cross-repository dependencies
github/github-mcp-server-remote#955must consume this commit or a release containing it for direct remote traffic; its stable dependency blocker remains until this change is merged and released.github/copilot-api#37229separately owns matching hosted-edge preflight behavior.Validation
script/lintscript/test