Skip to content

feat(auth): specify OIDC application_type during dynamic client registration (SEP-837)#2784

Open
stefanoamorelli wants to merge 1 commit into
modelcontextprotocol:mainfrom
stefanoamorelli:sep-837-oidc-dcr-application-type
Open

feat(auth): specify OIDC application_type during dynamic client registration (SEP-837)#2784
stefanoamorelli wants to merge 1 commit into
modelcontextprotocol:mainfrom
stefanoamorelli:sep-837-oidc-dcr-application-type

Conversation

@stefanoamorelli
Copy link
Copy Markdown

@stefanoamorelli stefanoamorelli commented Jun 5, 2026

Adds an application_type field to OAuthClientMetadata and sends it during OAuth Dynamic Client Registration, inferring the value from the client's redirect URIs when the caller does not set one.

Closes #2783.

Motivation and Context

SEP-837 requires MCP clients to send an application_type during OIDC Dynamic Client Registration. Omitting it defaults the client to "web", which conflicts with the loopback redirect URIs (localhost, 127.0.0.1, ::1) that native clients (CLI and desktop apps) use, so the server can reject the registration.

Currently OAuthClientMetadata has no such field and create_client_registration_request never sends one, so the client hits that default. This PR adds the field and infers a value from the redirect URIs at registration time: loopback and private-use schemes register as "native", a remote https host as "web", and a mix is left unset for the authorization server to decide. An explicit value is always sent as-is, and non-OIDC servers ignore the parameter. This follows the spec's guidance 1 and mirrors the approach already merged in the Go SDK (modelcontextprotocol/go-sdk#904) and Rust SDK (modelcontextprotocol/rust-sdk#883).

How Has This Been Tested?

The full suite passes locally with 100% coverage (./scripts/test); ruff, ruff format, and pyright are clean.

New unit tests cover the application_type model field, the redirect-URI inference (loopback, IPv4/IPv6 loopback, private-use scheme, remote host, and ambiguous mixes), and that create_client_registration_request sends the inferred type, preserves an explicit one, and omits an ambiguous one. The auth interaction suite's registration snapshot was updated to include application_type: "native" for its loopback redirect. The conformance suite already covers SEP-837 (src/seps/sep-837.yaml), so conformance.yml exercises this against the SDK.

Breaking Changes

None. application_type is optional and defaults to None; existing callers are unaffected, and registration requests only gain a parameter that OIDC servers expect and non-OIDC servers ignore.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

The registration failure SEP-837 describes is already surfaced by handle_registration_response as an OAuthRegistrationError, so no new error handling was needed; this PR only ensures the client declares the correct type up front.

SEP-837 requires an MCP client to specify an application_type during
OIDC Dynamic Client Registration [1]. When it is omitted, OIDC servers
default the client to "web", which conflicts with the loopback redirect
URIs that CLI and desktop clients use, so the registration can be
rejected. OAuthClientMetadata had no such field and the registration
request never sent one, so the SDK hit exactly that default.

I add an optional application_type to OAuthClientMetadata and infer it
from the redirect URIs when the caller does not set one: loopback and
private-use scheme URIs register as "native", a remote https host as
"web", and a mix is left unset for the server to decide. An explicit
value is always sent as-is. Non-OIDC servers ignore the parameter.

Implements [2].

[1]: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/7df71535a0c9b2057d73966bb6b123e684a940cd/docs/specification/draft/basic/authorization/client-registration.mdx#L152-L179
[2]: modelcontextprotocol#2783

Signed-off-by: Stefano Amorelli <stefano@amorelli.tech>
@stefanoamorelli
Copy link
Copy Markdown
Author

stefanoamorelli commented Jun 5, 2026

The one red check is an unrelated, pre-existing stdio flake (test_tool_call_and_notification_round_trip_over_a_stdio_subprocess) that this PR does not touch; it should be fixed by #2773.

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.

Implement SEP-837: Specify OIDC application_type during Dynamic Client Registration

1 participant