Replace authorization request parameters the endpoint URL already carries - #566
Merged
koic merged 1 commit intoSep 22, 2026
Conversation
…ries ## Motivation and Context `Flow#build_authorization_url` appended the flow's parameters after whatever query the authorization server metadata's `authorization_endpoint` already carried. An endpoint URL carrying `client_id`, `redirect_uri`, `state`, `code_challenge`, or `resource` of its own therefore produced a request with each of them twice, the URL's value first. RFC 6749 Section 3.1 forbids sending a parameter more than once, and which value a server honors is its own choice; on the legacy 2025-03-26 path the endpoint URL is served by the MCP server itself, so its query could speak for the client's identity, redirect URI, PKCE challenge, and resource at the authorization server. A parameter the flow sets now replaces one of the same name in the endpoint URL, and the rest of the URL's query is kept, which is what the TypeScript SDK's `searchParams.set` does. `request` and `request_uri` are dropped from the endpoint URL's query as well, although the flow sets neither. RFC 9101 has an authorization server take the whole authorization request from the object they carry, over every parameter in the query, and both are the client's to send, so an endpoint URL holding one of them could speak for the client through that door too. A `scope` in the endpoint URL stays when the flow has none of its own, as it does in the TypeScript SDK: an authorization server may place a default scope on its own endpoint URL. ## How Has This Been Tested? A new test in `test/mcp/client/oauth/flow_test.rb` serves an `authorization_endpoint` whose query carries those parameters and one more, and checks that the authorization URL holds each parameter once with the flow's value while keeping the extra one. It fails against the previous library. Two more tests in the same file check that `request` and `request_uri` in the endpoint URL's query are dropped, and that a `scope` there stays when the flow has none; the first of them fails against the previous library. ## Breaking Changes None.
koic
deleted the
override_query_parameters_of_the_authorization_endpoint
branch
September 22, 2026 05:13
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.
Motivation and Context
Flow#build_authorization_urlappended the flow's parameters after whatever query the authorization server metadata'sauthorization_endpointalready carried. An endpoint URL carryingclient_id,redirect_uri,state,code_challenge, orresourceof its own therefore produced a request with each of them twice, the URL's value first. RFC 6749 Section 3.1 forbids sending a parameter more than once, and which value a server honors is its own choice; on the legacy 2025-03-26 path the endpoint URL is served by the MCP server itself, so its query could speak for the client's identity, redirect URI, PKCE challenge, and resource at the authorization server.A parameter the flow sets now replaces one of the same name in the endpoint URL, and the rest of the URL's query is kept, which is what the TypeScript SDK's
searchParams.setdoes.requestandrequest_uriare dropped from the endpoint URL's query as well, although the flow sets neither. RFC 9101 has an authorization server take the whole authorization request from the object they carry, over every parameter in the query, and both are the client's to send, so an endpoint URL holding one of them could speak for the client through that door too. Ascopein the endpoint URL stays when the flow has none of its own, as it does in the TypeScript SDK: an authorization server may place a default scope on its own endpoint URL.How Has This Been Tested?
A new test in
test/mcp/client/oauth/flow_test.rbserves anauthorization_endpointwhose query carries those parameters and one more, and checks that the authorization URL holds each parameter once with the flow's value while keeping the extra one. It fails against the previous library.Two more tests in the same file check that
requestandrequest_uriin the endpoint URL's query are dropped, and that ascopethere stays when the flow has none; the first of them fails against the previous library.Breaking Changes
None.
Types of changes
Checklist