Class McpProtectedResourceMetadataServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.xebialabs.xlrelease.mcp.oauth.McpProtectedResourceMetadataServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
public class McpProtectedResourceMetadataServlet
extends jakarta.servlet.http.HttpServlet
Serves the OAuth 2.0 Protected Resource Metadata (RFC 9728) for the MCP endpoint, so MCP clients
(Claude, etc.) can discover the OIDC authorization server protecting
/s/mcp and run the
OAuth 2.1 + PKCE flow on their own. Mounted at /.well-known/oauth-protected-resource and
/.well-known/oauth-protected-resource/*; only the bare path and the MCP resource path
suffix (e.g. /s/mcp) are answered, anything else is 404.
Answers 404 while the MCP server feature is disabled (mirroring
McpServerEnabledFilter) or when no OIDC issuer is
configured. Purely additive: it never affects which credentials the MCP endpoint accepts.
- See Also:
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
ConstructorsConstructorDescriptionMcpProtectedResourceMetadataServlet(Supplier<String> serverUrl, String mcpResourcePath, Supplier<String> issuer, BooleanSupplier mcpServerEnabled, List<String> scopesSupported) -
Method Summary
Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, init, isSensitiveHeader, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
McpProtectedResourceMetadataServlet
public McpProtectedResourceMetadataServlet(Supplier<String> serverUrl, String mcpResourcePath, Supplier<String> issuer, BooleanSupplier mcpServerEnabled, List<String> scopesSupported) - Parameters:
serverUrl- supplier of the public server base URL (read per request so runtime changes to the configured server URL are reflected immediately)mcpResourcePath- the MCP endpoint path relative to the server root, e.g./s/mcpissuer- supplier of the configured OIDC issuer URL (may return null/blank)mcpServerEnabled- runtime MCP server feature togglescopesSupported- scopes to advertise asscopes_supported(xl.features.mcp.server.oauth.scopes-supported); MCP clients request exactly these when registering with the OIDC provider instead of guessing from the provider's full scope list. Empty list omits the field.
-
-
Method Details
-
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) - Overrides:
doGetin classjakarta.servlet.http.HttpServlet
-
baseUrl
Server base URL without a trailing slash, tolerating the onegetServerUrl()carries.
-