You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forward the original transport User-Agent header onto OAuth-generated discovery, registration, refresh, and token requests.
Add a regression that walks the auth generator through PRM discovery, OASM discovery, dynamic client registration, and token exchange while asserting the custom User-Agent is preserved.
Why
Streamable HTTP callers can configure a custom User-Agent on their HTTP client, but OAuth requests are created inside the auth provider as fresh httpx.Request instances. Those generated requests dropped the caller's user agent, which breaks deployments behind WAF rules that require it.
Pushed a follow-up for the coverage blocker. The full-flow exception path is now covered directly, so the auth flow still logs OAuth flow error and re-raises while keeping the repo-wide coverage gate strict.
Validation:
uv run pytest tests/client/test_auth.py -q -> 98 passed, 1 xfailed
uv run ruff check src/mcp/client/auth/oauth2.py tests/client/test_auth.py -> passed
uv run ruff format --check src/mcp/client/auth/oauth2.py tests/client/test_auth.py -> passed
uv run coverage run -m pytest -n auto -> 1174 passed, 98 skipped, 1 xfailed
Follow-up pushed for the pre-commit/pyright failure: the new caplog fixture is now typed as pytest.LogCaptureFixture.
Validated locally after the update:
uv run pyright tests/client/test_auth.py
uv run pytest tests/client/test_auth.py::TestAuthFlow::test_auth_flow_logs_and_reraises_oauth_errors -q
uv run pytest tests/client/test_auth.py -q
uv run ruff check src/mcp/client/auth/oauth2.py tests/client/test_auth.py
uv run ruff format --check src/mcp/client/auth/oauth2.py tests/client/test_auth.py
git diff --check
One local note: uv run pre-commit run pyright --files tests/client/test_auth.py currently exits before running pyright because the cached pre-commit-hooks manifest has an unsupported stages: [pre-commit] entry for this local pre-commit version. Direct pyright is clean and matches the CI error this commit addresses.
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
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.
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