Merge pull request #408 from koic/dcr_application_type
Set OIDC `application_type` on Dynamic Client Registration per SEP-837
This commit is contained in:
commit
aac41cdff8
1 changed files with 140 additions and 1 deletions
|
|
@ -440,7 +440,7 @@ module MCP
|
|||
end
|
||||
|
||||
response = begin
|
||||
http_post_json(registration_endpoint, @provider.client_metadata)
|
||||
http_post_json(registration_endpoint, registration_client_metadata)
|
||||
rescue Faraday::Error => e
|
||||
raise AuthorizationError,
|
||||
"Dynamic client registration failed: #{e.class}: #{e.message}."
|
||||
|
|
@ -466,6 +466,20 @@ module MCP
|
|||
info
|
||||
end
|
||||
|
||||
# Returns the client metadata to submit on Dynamic Client Registration.
|
||||
# Per SEP-837, MCP clients MUST specify an appropriate OIDC `application_type`
|
||||
# so the authorization server can apply the matching redirect URI policy.
|
||||
# When the user did not set one explicitly, infer `"native"` vs `"web"` from
|
||||
# the registered `redirect_uris`; an explicit value always wins.
|
||||
# https://github.com/modelcontextprotocol/modelcontextprotocol/pull/837
|
||||
def registration_client_metadata
|
||||
metadata = @provider.client_metadata
|
||||
return metadata if metadata[:application_type] || metadata["application_type"]
|
||||
|
||||
redirect_uris = metadata[:redirect_uris] || metadata["redirect_uris"]
|
||||
metadata.merge("application_type" => Discovery.infer_application_type(redirect_uris))
|
||||
end
|
||||
|
||||
# Reads `key` from a `client_information` hash that may use either string or
|
||||
# symbol keys, so users can persist the result of `JSON.parse` *or* a hand-built
|
||||
# `{ client_id:, client_secret: }` and have both work.
|
||||
|
|
|
|||
Loading…
Reference in a new issue