Skip to content

Let the host adjust the headers an MCP connection is opened with - #1413

Merged
yileicn merged 1 commit into
SciSharp:masterfrom
yuyixg:feature/mcp-client-header-provider
Aug 27, 2026
Merged

Let the host adjust the headers an MCP connection is opened with#1413
yileicn merged 1 commit into
SciSharp:masterfrom
yuyixg:feature/mcp-client-header-provider

Conversation

@yuyixg

@yuyixg yuyixg commented Aug 27, 2026

Copy link
Copy Markdown

The headers came straight from MCP:McpServerConfigs, so every call to a server went out as whatever fixed credential was configured for it. A host that wants to call a server as the user driving the conversation had no way in: GetMcpClientAsync is not virtual, and the transport is built inline.

IMcpClientHeaderProvider is an optional hook, resolved with GetService and asked about every server. Nothing registers it by default, and an implementation is free to answer with what it was given, so a host without one -- or with one that does not recognise a server -- gets the configured headers back untouched.

The headers passed to the provider belong to the McpSettings instance captured for the lifetime of the process, which is why the contract asks implementations to copy rather than write in place.

The headers came straight from MCP:McpServerConfigs, so every call to a server
went out as whatever fixed credential was configured for it. A host that wants
to call a server as the user driving the conversation had no way in:
GetMcpClientAsync is not virtual, and the transport is built inline.

IMcpClientHeaderProvider is an optional hook, resolved with GetService and asked
about every server. Nothing registers it by default, and an implementation is
free to answer with what it was given, so a host without one -- or with one that
does not recognise a server -- gets the configured headers back untouched.

The headers passed to the provider belong to the McpSettings instance captured
for the lifetime of the process, which is why the contract asks implementations
to copy rather than write in place.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@yileicn

yileicn commented Aug 27, 2026

Copy link
Copy Markdown
Member

reviewed

@yileicn
yileicn merged commit 669d22f into SciSharp:master Aug 27, 2026
4 checks passed
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.

3 participants