Class McpProtectedResourceMetadataClient

java.lang.Object
org.apache.juneau.rest.client.mcp.auth.McpProtectedResourceMetadataClient

Fetches and parses an RFC 9728 Protected Resource Metadata (PRM) document, and resolves the authorization server a protected MCP resource delegates to.

This is the client half of the OAuth 2.1 baseline PRM discovery required by the MCP 2026-07-28 revision: on a 401 WWW-Authenticate challenge the client recovers the resource_metadata pointer (WwwAuthenticateChallenge.resourceMetadata()), fetches the PRM document here, selects an authorization server (McpProtectedResourceMetadata.firstAuthorizationServer()), and validates that server's issuer identity via OidcDiscoveryClient (RFC 8414 / OIDC Discovery).

When an expected resource identifier is supplied (McpProtectedResourceMetadataClient.Builder.expectedResource(URI) or the expectedResource argument of fetch(URI, URI) / parse(String, URI, URI)), the PRM document's resource field is validated against it per RFC 9728 §3.3 (exact string match, mirroring the issuer-identity posture) and a mismatch is rejected — this defends against a malicious server pointing the client at a PRM document minted for a different resource. An expected resource is required unless McpProtectedResourceMetadataClient.Builder.skipResourceValidation(boolean) is set.

By default the PRM URL and any discovered authorization-server URI must use https and must not point at a loopback, private, link-local or metadata host; McpProtectedResourceMetadataClient.Builder.allowPrivateUrls(boolean) lifts the host restriction (and permits plain http for loopback hosts), and McpProtectedResourceMetadataClient.Builder.allowInsecureHttp(boolean) disables the scheme check.

Since:
10.0.0