Skip to content

Forward MCP streamable HTTP headers#299

Open
jstar0 wants to merge 1 commit into
microsoft:mainfrom
jstar0:fix/mcp-streamable-http-headers
Open

Forward MCP streamable HTTP headers#299
jstar0 wants to merge 1 commit into
microsoft:mainfrom
jstar0:fix/mcp-streamable-http-headers

Conversation

@jstar0

@jstar0 jstar0 commented Jun 21, 2026

Copy link
Copy Markdown

Fixes #295

Summary

Forwards custom MCP server HTTP headers from the top-level headers field into requestInit.headers.

Changes

This PR:

  • copies each MCP server's top-level headers into requestInit.headers
  • keeps the original top-level headers field intact
  • preserves any existing requestInit.headers value when the same header is already set there
  • supports both VS Code-style { "servers": ... } config and direct server-map config
  • skips malformed non-object requestInit or requestInit.headers shapes instead of replacing user-provided values
  • adds regression coverage for the wrapped config, direct config, and duplicate-header precedence cases

Why

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 headers were not represented in requestInit.headers, so those headers were not available to the Streamable HTTP request path.

Verification

./mvnw -pl com.microsoft.copilot.eclipse.core,com.microsoft.copilot.eclipse.core.test -am -Dtest=CopilotLanguageServerSettingsTests verify

Copilot AI review requested due to automatic review settings June 21, 2026 17:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.headers into server.requestInit.headers when not already present there (preserving requestInit.headers precedence).
  • 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.

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.

[Bug] Custom HTTP headers from MCP config are not sent on Streamable HTTP requests

2 participants