feat(mcp): support caller-owned dynamic HTTP authentication - #1330
Merged
Merged
Conversation
Yuang-Deng
had a problem deploying
to
protected
September 18, 2026 09:19 — with
GitHub Actions
Error
Yuang-Deng
requested a deployment
to
protected
September 20, 2026 11:57 — with
GitHub Actions
Waiting
This branch is waiting to be deployed
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.
Problem and change
Remote MCP servers using expiring OAuth credentials cannot use static headers for long-running tools. Add optional asynchronous header and recovery callbacks to MCPClient for Streamable HTTP, so the caller retains ownership of credentials and refresh policy.
A new connection obtains current headers. An explicit HTTP 401 can trigger one recovery and retry; tool failures/timeouts and failures during cleanup after a successful call do not replay the operation. Redirects with dynamic authentication callbacks are rejected before the SDK can follow them; static headers retain SDK redirect behavior. Existing static authentication transports remain unchanged.
Validation
The branch now includes main. The dependent LazyMind PR has also synchronized main and adopted the host-file API changes; it remains draft until this dependency is merged.
Python 3.10 validation: the previously failing lint now passes using the existing AnyIO exceptiongroup backport, and all 9 MCP auth tests pass with MCP SDK 1.30.0. No new production dependency was added. SDK 2.2.0 was also probed: it converts the real HTTP 401 into MCPError, so the current explicit HTTP-status recovery does not recover that case. LazyMind constrains MCP to <2; SDK 2 recovery is outside this change.