Skip to content

fix: validate registered redirect uris#2638

Closed
he-yufeng wants to merge 2 commits into
modelcontextprotocol:mainfrom
he-yufeng:fix/validate-dcr-redirect-uris
Closed

fix: validate registered redirect uris#2638
he-yufeng wants to merge 2 commits into
modelcontextprotocol:mainfrom
he-yufeng:fix/validate-dcr-redirect-uris

Conversation

@he-yufeng

Copy link
Copy Markdown

Summary

  • validate DCR redirect_uris before registering the client
  • allow HTTPS redirect URIs and HTTP loopback redirect URIs
  • reject non-loopback HTTP, non-HTTP(S) schemes, and fragments with invalid_redirect_uri

Fixes #2629

To verify

  • .\.venv\Scripts\python.exe -m pytest tests\server\mcpserver\auth\test_auth_integration.py -q -k "client_registration"
  • .\.venv\Scripts\python.exe -m pytest tests\server\mcpserver\auth\test_auth_integration.py -q
  • .\.venv\Scripts\python.exe -m ruff check src\mcp\server\auth\handlers\register.py tests\server\mcpserver\auth\test_auth_integration.py
  • .\.venv\Scripts\python.exe -m ruff format --check src\mcp\server\auth\handlers\register.py tests\server\mcpserver\auth\test_auth_integration.py
  • .\.venv\Scripts\pyright.exe src\mcp\server\auth\handlers\register.py tests\server\mcpserver\auth\test_auth_integration.py
  • git diff --check upstream/main..HEAD

@he-yufeng

Copy link
Copy Markdown
Author

Pushed a small test-only follow-up for the coverage gate: the new redirect URI branch now has an explicit redirect_uris: null registration case.

Verified locally:

  • .\.venv\Scripts\python.exe -m pytest tests\server\mcpserver\auth\test_auth_integration.py -q -k "client_registration"
  • .\.venv\Scripts\python.exe -m ruff check src\mcp\server\auth\handlers\register.py tests\server\mcpserver\auth\test_auth_integration.py
  • .\.venv\Scripts\python.exe -m ruff format --check src\mcp\server\auth\handlers\register.py tests\server\mcpserver\auth\test_auth_integration.py
  • .\.venv\Scripts\pyright.exe src\mcp\server\auth\handlers\register.py tests\server\mcpserver\auth\test_auth_integration.py
  • git diff --check upstream/main..HEAD

@he-yufeng

Copy link
Copy Markdown
Author

Closing this during backlog cleanup. The python-sdk queue has too many open PRs, and this older/no-human-signal item is lower priority than the remaining PRs that have recent validation, review discussion, or clearer current value. I can reopen or refresh it if maintainers want this specific change.

@he-yufeng he-yufeng closed this Jun 10, 2026
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.

DCR registration accepts redirect_uris with non-HTTPS / non-loopback / fragmented schemes

1 participant