Forward MCP streamable HTTP headers#299
Open
jstar0 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes MCP Streamable HTTP authentication gaps by ensuring any top-level per-server headers in the MCP JSON config are forwarded into requestInit.headers (without removing the original headers field), so the Streamable HTTP request path can include them.
Changes:
- Normalize MCP server configs by copying
server.headersintoserver.requestInit.headerswhen not already present there (preservingrequestInit.headersprecedence). - Support both VS Code-style wrapped configs (
{ "servers": { ... } }) and direct server-map configs ({ "my-server": { ... } }). - Add regression tests covering wrapped config, direct config, and duplicate-header precedence.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/CopilotLanguageServerSettings.java | Parses MCP server JSON as JsonObject and normalizes headers into requestInit.headers while preserving existing values and skipping malformed shapes. |
| com.microsoft.copilot.eclipse.core.test/src/com/microsoft/copilot/eclipse/core/lsp/protocol/CopilotLanguageServerSettingsTests.java | Adds unit tests verifying header forwarding for wrapped/direct configs and that requestInit.headers takes precedence on duplicates. |
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.
Fixes #295
Summary
Forwards custom MCP server HTTP headers from the top-level
headersfield intorequestInit.headers.Changes
This PR:
headersintorequestInit.headersheadersfield intactrequestInit.headersvalue when the same header is already set there{ "servers": ... }config and direct server-map configrequestInitorrequestInit.headersshapes instead of replacing user-provided valuesWhy
Streamable HTTP MCP servers may require custom HTTP headers for authentication. The settings adapter already forwards MCP server configuration to the language server, but top-level
headerswere not represented inrequestInit.headers, so those headers were not available to the Streamable HTTP request path.Verification