Class SpringMcpRestServlet

java.lang.Object
jakarta.servlet.GenericServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable, BasicUniversalConfig, DefaultConfig, DefaultHtmlConfig, McpEndpointMixin, McpEndpoint
Direct Known Subclasses:
SpringExampleMcpServer

public abstract class SpringMcpRestServlet extends BasicSpringRestServlet implements McpEndpoint
Convenience base class exposing a 2026-07-28 MCP endpoint on a Spring Boot resource with full Spring dependency-injection support.

Combines BasicSpringRestServlet (Spring Boot bean-store integration via SpringBeanStore) with the McpEndpoint mixin (the 2026-07-28 MCP handler). This is the recommended way to expose MCP from a Spring Boot resource: subclassing McpRestServlet instead does not work, since McpRestServlet and BasicSpringRestServlet are sibling RestServlet subclasses and a class cannot extend both — and even if it could, only the mixin path preserves the Spring BeanStore bridge that MCP tool/prompt/resource handlers rely on to resolve Spring-managed beans (for example via BeanStore.getBean(MyService.class)).

Subclasses supply their McpServerConfig by implementing McpEndpointMixin.getMcpConfig(), and may optionally override McpEndpoint.getMcpOptions() to customize capabilities/instructions/cache/mrtr/subscriptions/broker behavior.

Example: