fix(client): forward User-Agent through OAuth auth flow - #2526
Conversation
|
Pushed a follow-up for the coverage blocker. The full-flow exception path is now covered directly, so the auth flow still logs Validation:
|
|
Follow-up pushed for the pre-commit/pyright failure: the new Validated locally after the update:
One local note: |
3d641bf to
78eafac
Compare
|
Closing as a duplicate of #2077, which was opened first with the same fix at the same call sites. Thanks for the contribution. |
What
User-Agentheader onto OAuth-generated discovery, registration, refresh, and token requests.User-Agentis preserved.Why
Streamable HTTP callers can configure a custom
User-Agenton their HTTP client, but OAuth requests are created inside the auth provider as freshhttpx.Requestinstances. Those generated requests dropped the caller's user agent, which breaks deployments behind WAF rules that require it.Fixes #1664
Tests
uv run pytest tests/client/test_auth.py -k user_agent -quv run pytest tests/client/test_auth.py -quv run ruff check src/mcp/client/auth/oauth2.py tests/client/test_auth.pyuv run ruff format --check src/mcp/client/auth/oauth2.py tests/client/test_auth.pygit diff --check