python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

Extract reusable OAuth authorization redirect builder

Open maxpetrusenkoagent opened this issue 5 months ago • 0 comments

Summary

Fixes #1743.

Extracts the reusable OAuth authorization redirect step from OAuthClientProvider into a public helper for proxy/server-side use cases:

  • adds OAuthAuthorizationRedirect, a resumable authorization redirect result containing the authorization URL, OAuth state, and PKCE verifier
  • adds build_authorization_redirect(...) so callers can build and persist the browser redirect step without needing redirect_handler / callback_handler
  • keeps OAuthClientProvider behavior routed through the new helper
  • preserves existing authorization endpoint query parameters and hides the PKCE verifier from repr(...)

Verification

  • uv run --frozen pytest tests/client/test_auth.py tests/interaction/auth/test_flow.py -q
  • uv run --frozen coverage erase && uv run --frozen coverage run -m pytest tests/client/test_auth.py tests/interaction/auth/test_flow.py && uv run --frozen coverage combine && uv run --frozen coverage report --include='src/mcp/client/auth/oauth2.py,src/mcp/client/auth/__init__.py' --fail-under=0 && UV_FROZEN=1 uv run --frozen strict-no-cover
  • uv run --frozen ruff format --check src/mcp/client/auth/oauth2.py src/mcp/client/auth/__init__.py tests/client/test_auth.py
  • uv run --frozen ruff check src/mcp/client/auth/oauth2.py src/mcp/client/auth/__init__.py tests/client/test_auth.py
  • uv run --frozen pyright src/mcp/client/auth/oauth2.py src/mcp/client/auth/__init__.py tests/client/test_auth.py
  • ./scripts/test → 1786 passed, 5 skipped, 1 xfailed, 100.00% coverage, strict-no-cover clean

Review

Local autoreview found no blocking issues. It suggested preserving existing authorization endpoint query parameters and hiding the PKCE verifier in repr; both are included and covered by regression tests.

maxpetrusenkoagent avatar Jun 13 '26 02:06 maxpetrusenkoagent