Repository navigation
Pass httpx auth through ClientSessionGroup HTTP parameters - #3840
Open
mateolafalce wants to merge 2 commits into
Open
mateolafalce wants to merge 2 commits into
mateolafalce wants to merge 2 commits into
Conversation
SseServerParameters and StreamableHttpParameters can carry an httpx2.Auth, and connect_to_server forwards it to the HTTP client. That is what OAuthClientProvider needs. The handler is left out of serialization. Co-authored-by: Michael <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.
Re-trigger cubic
The coverage gate counts tests. The auth handler repr was never called, and the in-process ASGI helpers had branches no HTTP request reaches. Co-authored-by: Michael <[email protected]>
This branch has not been 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.
Fixes #1723
Summary
ClientSessionGroupcould not carry anhttpx2.Auth. Callers had to put a bearer token inheaders, so anOAuthClientProvider(discovery, refresh) could not run from a session group.SseServerParametersandStreamableHttpParametersnow take an optionalauth.connect_to_serverpasses it tosse_clientandcreate_mcp_http_client.authis omitted frommodel_dump(),model_dump_json(), andrepr(): the handler can hold a credential, and it is not JSON.Behavior
authdefaults toNone. Stdio is unchanged.OAuthClientProvidershare its tokens and its refresh cycle.headers=is still sent. A header other thanAuthorizationarrives as set. If the handler setsAuthorization, that value is what the server sees.OAuthClientProvidersets it once it has an access token.OAuthClientProviderdrops into the sameauth=slot. Building one is covered in the OAuth clients page.Tests
In-process streamable HTTP and legacy SSE: the server sees the handler's bearer token. Two servers in one group see two different tokens. A manual
Authorizationheader does not survive a handler that sets its own, andX-Trace-Iddoes. Dumps do not contain the token.Pyright on the touched files reports 0 errors.
Disclosure: an AI assistant drafted this change at my request.
This branch is independent of #2065 and #3516, which are still open. It is based on current
main(somax_sse_event_sizeis unchanged) and covers the open review notes on #3516: the docs example runs, and the test states whichAuthorizationvalue the server sees.