Package com.tnsai.mcp.auth
Class McpOAuthDiscovery
java.lang.Object
com.tnsai.mcp.auth.McpOAuthDiscovery
RFC 8414 OAuth Authorization Server Metadata discovery.
Discovers OAuth metadata from a server URL by checking the well-known OAuth authorization server metadata endpoint. This enables MCP clients to automatically configure OAuth authentication without manual endpoint setup.
Usage:
OAuthMetadata metadata = McpOAuthDiscovery.discover("https://mcp.example.com");
String authEndpoint = metadata.authorizationEndpoint();
String tokenEndpoint = metadata.tokenEndpoint();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOAuth authorization server metadata as defined by RFC 8414. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDiscovers OAuth metadata from a server URL.
-
Constructor Details
-
McpOAuthDiscovery
public McpOAuthDiscovery()
-
-
Method Details
-
discover
Discovers OAuth metadata from a server URL.Checks
.well-known/oauth-authorization-serveron the given server URL and parses the returned JSON metadata document.- Parameters:
serverUrl- the base URL of the MCP server- Returns:
- the discovered OAuth metadata
- Throws:
IOException- if the discovery request fails or the response is invalid
-