Interface McpEndpoint
- All Superinterfaces:
McpEndpointMixin
- All Known Implementing Classes:
SpringExampleMcpServer,SpringMcpRestServlet
2026-07-28 MCP endpoint at POST /mcp on any Juneau REST
resource.
The mixin path and the servlet-subclass path (McpRestServlet) are at parity: both bind the revision
at compile time and both read the same McpOptions shape for behavior configuration
(capabilities/instructions/cache/mrtr/subscriptions/broker) via a single override.
Example:
-
Method Summary
Modifier and TypeMethodDescriptiondefault McpOptionsThis endpoint's behavior configuration — capabilities, instructions, cache hints, MRTR, subscriptions, and the subscription broker, all in one place.default McpOptionsPublishes this endpoint's memoizedMcpOptionsinto this resource'sRestContextbean store, the same@Bean-method mechanism already used bymcpTraceContextExtractor().default McpProtectedResourceMetadataServes the RFC 9728 Protected Resource Metadata document at the path-inserted well-known location (SEP-2351), but only when the requested suffix matches this resource's expected well-known path; otherwise404.default McpProtectedResourceMetadataServes the RFC 9728 Protected Resource Metadata document at the root well-known location (SEP-2351 fallback).default voidmcpResourceServerAuth(RestContext ctx, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) OAuth 2.1 resource-server bearer gate for the mixin's MCPPOST /mcpendpoint.default TraceContextExtractorPublishes this revision's stableTraceContextExtractorso an activeTracerHook(viaRestOpInvoker) recognizes this endpoint's resolvedJsonRpcRequestargument and itsparams._metacarrier before span creation.default McpRevisionrevision()The MCP protocol revision this endpoint speaks.default McpSubscriptionBrokerSubscription broker for this endpoint's bound revision.Methods inherited from interface org.apache.juneau.rest.server.mcp.McpEndpointMixin
getMcpConfig, handleMcpRequest
-
Method Details
-
revision
Description copied from interface:McpEndpointMixinThe MCP protocol revision this endpoint speaks.- Specified by:
revisionin interfaceMcpEndpointMixin- Returns:
- The bound revision. Never
null.
-
mcpTraceContextExtractor
Publishes this revision's stableTraceContextExtractorso an activeTracerHook(viaRestOpInvoker) recognizes this endpoint's resolvedJsonRpcRequestargument and itsparams._metacarrier before span creation.A no-op when no
TracerHookbean is registered — see the no-tracer fast-path contract documented onTracerHook.- Returns:
- This revision's shared
TraceContextExtractor. Nevernull .
-
getMcpOptions
This endpoint's behavior configuration — capabilities, instructions, cache hints, MRTR, subscriptions, and the subscription broker, all in one place.The default returns a per-binding-fresh
McpOptions(all defaults; no live-state sharing across endpoint instances). Override to customize any of the six concepts.This method is invoked exactly once per endpoint instance and the result is memoized for that instance's lifetime by the framework internals that read it (
revision(),subscriptionBroker(), the@Bean-published accessor) — so an override may freely construct and configure a fresh instance on every call, exactly as shown above; it never needs to cache the result itself, and returning a fresh instance per call cannot reintroduce the "must return a stable instance" footgun the pre-consolidation per-concept hooks warned about.- Returns:
- This endpoint's options. Must not be
null .
-
mcpOptionsBean
Publishes this endpoint's memoizedMcpOptionsinto this resource'sRestContextbean store, the same@Bean-method mechanism already used bymcpTraceContextExtractor().This is what lets
McpRevision.dispatch(...)'ssubscriptions/listenbranch resolve the real, possibly-overridden subscriptions configuration viactx.getBean(McpOptions.class)instead of always falling through to that call's defensivenew McpSubscriptionsConfig()default — the neutral core cannot add this bean itself (McpOptionsis a v2 type, and the neutral module must not import it), so this v2-side@Beanmethod is the wiring's only seam.- Returns:
- This endpoint's memoized options. Never
null .
-
subscriptionBroker
Subscription broker for this endpoint's bound revision.Reads
getMcpOptions()'s memoizedMcpOptions.getSubscriptionBroker(): an explicitly configured broker is returned as-is; otherwise one is derived and memoized per-binding, sized fromMcpOptions.getSubscriptions()'s queue bound (seeMcpOptions.resolveSubscriptionBroker()). BecauseMcpOptionsitself is memoized once per endpoint instance (McpEndpointOptionsCache), two distinct endpoint instances resolve to two distinct broker registries by default — there is no accidental JVM-wide sharing the way the pre-consolidation mixin default had.- Specified by:
subscriptionBrokerin interfaceMcpEndpointMixin- Returns:
- The subscription broker. Never
null .
-
mcpResourceServerAuth
default void mcpResourceServerAuth(RestContext ctx, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) OAuth 2.1 resource-server bearer gate for the mixin's MCPPOST /mcpendpoint.A no-op unless
RS auth is enabled; when enabled, a request that the router resolves to the MCPPOST /mcpdispatch operation must present a valid bearer token or it is rejected with401/403and aWWW-Authenticate: Bearer ...challenge. The gate is scoped to the MCP dispatch operation (identified by resolved-operation identity, or by that operation's own router matchers — seeMcpResourceServerSupport.resolvesToMcpDispatch(org.apache.juneau.rest.server.RestContext, jakarta.servlet.http.HttpServletRequest)) so otherPOSToperations on the host resource are unaffected, and it cannot drift from the router: a trailing slash, percent-encoding, aPOSTclaim on any override channel (?method=or an override header), or a host-chosen@Mixin(path/paths)re-mount cannot slip past it . The well-knownGETroutes are left unauthenticated for PRM discovery.- Parameters:
ctx- The hostRestContexthandling this request.req- The raw HTTP request.res- The raw HTTP response (used to emit the challenge header on rejection).
-
mcpProtectedResourceMetadataRoot
Serves the RFC 9728 Protected Resource Metadata document at the root well-known location (SEP-2351 fallback).This route (and its path-inserted sibling) is registered unconditionally, but returns
404whenever RS auth isdisabled— so a non-opted-in endpoint claims the well-known namespace but exposes no observable metadata.- Parameters:
req- The REST request.- Returns:
- The PRM document.
-
mcpProtectedResourceMetadataPathInserted
Serves the RFC 9728 Protected Resource Metadata document at the path-inserted well-known location (SEP-2351), but only when the requested suffix matches this resource's expected well-known path; otherwise404.- Parameters:
req- The REST request.- Returns:
- The PRM document.
-