Repository navigation
auth: drop the query from the 2025-03-26 fallback authorization base URL - #1348
Open
akshita317 wants to merge 1 commit into
Open
akshita317 wants to merge 1 commit into
akshita317 wants to merge 1 commit into
Conversation
When an MCP server publishes no protected resource metadata, the authorization code handler falls back to the 2025-03-26 rule: the authorization base URL is the MCP server URL with its path discarded. getProtectedResourceMetadata cleared only the path, so a query or fragment on the server URL stayed in the base URL. For a server at https://api.example.com/mcp?tenant=acme the issuer became https://api.example.com?tenant=acme. Metadata served at the root names the issuer https://api.example.com, so GetAuthServerMeta rejected it with "metadata issuer ... does not match issuer URL" and Authorize failed. Without metadata, the default endpoints were built by string concatenation into https://api.example.com?tenant=acme/authorize. Build the base URL from the scheme and authority only. Fixes modelcontextprotocol#1347 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Akshita kumari <110122283+akshita317@users.noreply.github.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When an MCP server publishes no protected resource metadata,
AuthorizationCodeHandlerfalls back to the 2025-03-26 rule: the authorization base URL is the MCP server URL with its path discarded.getProtectedResourceMetadatacleared only the path, so a query or fragment on the server URL stayed in the base URL.For a server at
https://api.example.com/mcp?tenant=acme, the issuer becamehttps://api.example.com?tenant=acme. Metadata served at the root names the issuerhttps://api.example.com, soGetAuthServerMetarejected it ("metadata issuer … does not match issuer URL") andAuthorizefailed. Without metadata, the default endpoints were built by concatenation intohttps://api.example.com?tenant=acme/authorize.This builds the base URL from the scheme and authority only. Protected resource metadata discovery is unchanged: RFC 9728 §3.1 keeps the query when inserting the well-known suffix.
Tests (both fail without the change):
TestGetProtectedResourceMetadata_BackcompatDropsQuery: a query, a fragment, an empty?, and a query with no path all givehttp://localhost:1234.TestAuthorize_BackcompatServerURLWithQuery: the full flow against the fake authorization server, reached at/mcp?tenant=acme, now gets a token.Fixes #1347
AI assistance: prepared with Claude Code.
🤖 Generated with Claude Code