Skip to content

fix(auth): accept empty optional OAuth client metadata URLs#2076

Open
mrutunjay-kinagi wants to merge 2 commits intomodelcontextprotocol:mainfrom
mrutunjay-kinagi:fix-1665-empty-uri-metadata
Open

fix(auth): accept empty optional OAuth client metadata URLs#2076
mrutunjay-kinagi wants to merge 2 commits intomodelcontextprotocol:mainfrom
mrutunjay-kinagi:fix-1665-empty-uri-metadata

Conversation

@mrutunjay-kinagi
Copy link

@mrutunjay-kinagi mrutunjay-kinagi commented Feb 17, 2026

Summary

  • normalize empty-string optional URL fields in OAuthClientMetadata to None before URL validation
  • keep existing URL validation rules for non-empty values
  • add a regression test for empty client_uri/logo_uri/tos_uri/policy_uri/jwks_uri inputs

Why

Fixes validation failures when auth servers emit empty strings for optional client metadata URL fields.

Closes #1665

Validation

  • pytest -q tests/client/test_auth.py -k "empty_optional_uris"
  • ruff check src/mcp/shared/auth.py tests/client/test_auth.py
  • ruff format --check src/mcp/shared/auth.py tests/client/test_auth.py

@mrutunjay-kinagi
Copy link
Author

Follow-up pushed in e9a78ec to fix the pre-commit failure by validating the empty-URI fixture via (runtime path) instead of passing empty strings directly to typed constructor params.

@mrutunjay-kinagi
Copy link
Author

Follow-up pushed in e9a78ec to fix the pre-commit pyright failure.

Change made:

  • Updated the empty-URI regression test to use OAuthClientMetadata.model_validate({...}) so empty strings are exercised through runtime validation without violating static constructor type checks.

@mrutunjay-kinagi
Copy link
Author

All checks are now passing on the latest commit (e9a78ec).

Ready for maintainer review when you have bandwidth. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URL Validation on Client Metadata is too strict

1 participant