pub struct ClientMetadata { /* private fields */ }Expand description
The metadata a client presents to register.
This is RFC 7591 §2’s client metadata document, and MCP adds one requirement
on top: 2026-07-28 §8 (SEP-837) makes application_type a MUST for
dynamic registration “to avoid OpenID Connect redirect URI conflicts”.
§Unknown fields
extra holds anything not named here and is merged into the
serialized document. The named fields are the ones this crate has to read or
gate on; a client that publishes client_uri, icon_uri or title —
all of which the newer revisions name — sets them through
with_field rather than losing them at a struct
boundary. Preserving them matters for the same reason it matters on the IR:
the authorization server sees the document this client published, and
silently dropping a field turns a working registration into a failing one.
Implementations§
Source§impl ClientMetadata
impl ClientMetadata
Sourcepub fn new(redirect_uris: Vec<String>) -> Result<Self, ClientIdError>
pub fn new(redirect_uris: Vec<String>) -> Result<Self, ClientIdError>
Metadata with the redirect URIs it will be authorized to use.
RFC 7591 §2 makes redirect_uris the one required member of a client
metadata document, so this constructor refuses an empty list rather than
letting a server reject it.
§Errors
ClientIdError::NotHttps if a redirect URI is not an absolute https
URL, or ClientIdError::DocumentRegistration if the list is empty.
Sourcepub fn redirect_uris(&self) -> &[String]
pub fn redirect_uris(&self) -> &[String]
The redirect URIs, in the order they were given.
Sourcepub fn client_name(&self) -> Option<&str>
pub fn client_name(&self) -> Option<&str>
The name this client presents at a consent screen.
Sourcepub fn with_client_name(self, name: impl Into<String>) -> Self
pub fn with_client_name(self, name: impl Into<String>) -> Self
Set the consent-screen name.
Sourcepub fn token_endpoint_auth_method(&self) -> Option<&str>
pub fn token_endpoint_auth_method(&self) -> Option<&str>
How this client authenticates at the token endpoint.
"none" declares a public client, which is what a Client ID Metadata
Document client is: the draft is explicit that no shared secret can be
established for that form.
Sourcepub fn with_token_endpoint_auth_method(self, method: impl Into<String>) -> Self
pub fn with_token_endpoint_auth_method(self, method: impl Into<String>) -> Self
Set the token endpoint authentication method.
Sourcepub fn application_type(&self) -> Option<&str>
pub fn application_type(&self) -> Option<&str>
The OIDC application_type this client is.
Sourcepub fn with_application_type(self, application_type: impl Into<String>) -> Self
pub fn with_application_type(self, application_type: impl Into<String>) -> Self
Set the OIDC application_type.
Sourcepub fn with_field(
self,
name: impl Into<String>,
value: impl Into<Value>,
) -> Result<Self, ClientMetadataError>
pub fn with_field( self, name: impl Into<String>, value: impl Into<Value>, ) -> Result<Self, ClientMetadataError>
Set one field this crate does not name, preserving it on the wire.
Takes precedence over a named field of the same name, so a caller cannot
set redirect_uris through here and have it win over the typed value —
that would let a document claim redirects the client never checked.
ClientMetadataError::ReservedField names the fields that are typed.