Repository navigation
Pass httpx auth through ClientSessionGroup HTTP parameters - #3840
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 <265398295+lafalce-assistant@users.noreply.github.com>
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 <265398295+lafalce-assistant@users.noreply.github.com>
|
The two-server test in this PR covers static tokens. An additional integration test against The test uses in-process Streamable HTTP servers and synthetic credentials. On the linked commit, running Codex wrote and ran this additional test. |
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.