OAuth Client ID Metadata Document support for MCP authorization.
Implements the OAuth Client ID Metadata Document mechanism where the
client's client_id is a URL that resolves to a JSON document
containing the client's OAuth metadata.
This enables dynamic client registration-like behavior without requiring a registration endpoint.
Client IDs are exact HTTPS URLs with a non-root path. The document at that
URL must repeat the exact client ID and provide client_name and
redirect_uris. Authorization servers advertise support with
client_id_metadata_document_supported: true.
Summary
Functions
Builds a client metadata document for this application.
Fetches and parses client metadata from a client_id URL.
Returns whether authorization-server metadata advertises CIMD support.
Validates client metadata structure.
Validates the URL form required for a CIMD client identifier.
Types
Functions
@spec build_metadata(keyword()) :: client_metadata()
Builds a client metadata document for this application.
Useful for MCP clients that want to publish their own metadata.
@spec fetch( String.t(), keyword() ) :: {:ok, client_metadata()} | {:error, term()}
Fetches and parses client metadata from a client_id URL.
Parameters
client_id_url- The client_id URL to fetch metadata fromopts- Hardened metadata-fetch options. A custom:http_clientmust implementget(uri, approved_address, opts)and connect to the supplied address while preservinguri.hostfor TLS and HTTP host validation.
Returns
{:ok, metadata}- Successfully fetched client metadata{:error, reason}- Failed to fetch or parse metadata
The default client permits only HTTPS public addresses, revalidates and pins every redirect hop, bounds time and response bytes, and sends no credentials.
Returns whether authorization-server metadata advertises CIMD support.
@spec validate(client_metadata(), String.t()) :: :ok | {:error, term()}
Validates client metadata structure.
Required Fields
client_id- Must match the URL it was fetched fromclient_name- Human-readable name for the clientredirect_uris- List of allowed redirect URIs
Optional Fields
client_uri- URL of the client's home pagelogo_uri- URL of the client's logoscope- Space-separated list of requested scopescontacts- List of contact emailstos_uri- Terms of service URLpolicy_uri- Privacy policy URL
Validates the URL form required for a CIMD client identifier.