Interface McpEndpointMixin
- All Known Subinterfaces:
McpEndpoint,McpEndpoint
- All Known Implementing Classes:
SpringExampleMcpServer,SpringMcpRestServlet,SpringMcpRestServlet
POST /mcp on any Juneau REST resource.
Implementing classes supply their McpServerConfig via getMcpConfig() and their
protocol revision via revision(). In practice a consumer implements a revision-specific
sub-interface (for example org.apache.juneau.rest.server.mcp.v20250618.McpEndpoint), which supplies revision() for them.
Example:
@Rest(path="/api")
public class MyResource extends BasicRestServlet implements org.apache.juneau.rest.server.mcp.v20250618.McpEndpoint {
@Override
public McpServerConfig getMcpConfig() {
return new McpServerConfig().addTool(new MyEchoTool());
}
}
Named *Mixin (not Abstract*) because this is an interface, not an abstract class -
Abstract* is this repo's naming convention for abstract classes only. McpRevision, the
other core type dated subclasses de-versioning-shadow, deliberately keeps its plain name: end-users
never implement it directly (only a bound revision's own subclass does), so it never faces the
same-simple-name collision this mixin interface was renamed to avoid.
-
Method Summary
Modifier and TypeMethodDescriptionReturns theMcpServerConfigbacking this endpoint.default ObjecthandleMcpRequest(JsonRpcRequest req, RestRequest restReq) Default MCP JSON-RPC endpoint handler.revision()The MCP protocol revision this endpoint speaks.default McpSubscriptionBrokerOptional subscription broker backing this endpoint'ssubscriptions/listensupport.
-
Method Details
-
getMcpConfig
Returns theMcpServerConfigbacking this endpoint.- Returns:
- The config. Never
null.
-
revision
The MCP protocol revision this endpoint speaks.- Returns:
- The bound revision. Never
null.
-
subscriptionBroker
Optional subscription broker backing this endpoint'ssubscriptions/listensupport.Returning
null (the default) means this endpoint does not support subscriptions: noMcpSubscriptionBrokerorMcpSubscriptionsbean is added to the request-scopedBeanStorethathandleMcpRequest(org.apache.juneau.bean.jsonrpc.JsonRpcRequest, org.apache.juneau.rest.server.RestRequest)builds.A revision binding that implements
subscriptions/listen(for exampleorg.apache.juneau.rest.server.mcp.v20260728.McpEndpoint) overrides this to return a binding-owned broker instance (its own per-binding vs. shared-instance semantics are that revision's own choice — see its Javadoc).- Returns:
- The subscription broker, or
null if this endpoint does not support subscriptions.
-
handleMcpRequest
Default MCP JSON-RPC endpoint handler.Implementations may override this method to customize routing (path / annotations) but must still dispatch through
revision().Applies the same serializer policy as
AbstractMcpRestServlet(addBeanTypesanduriResolution="NONE"), so the two neutral HTTP entrypoints stay at parity.- Parameters:
req- JSON-RPC request envelope.restReq- The current REST request.- Returns:
- The response, or
nullfor notifications.
-