Class MpcWebMvcServerAutoConfiguration

java.lang.Object
org.springframework.ai.autoconfigure.mcp.server.MpcWebMvcServerAutoConfiguration

@AutoConfiguration @ConditionalOnClass(io.modelcontextprotocol.server.transport.WebMvcSseServerTransport.class) @ConditionalOnMissingBean(io.modelcontextprotocol.spec.ServerMcpTransport.class) @ConditionalOnProperty(prefix="spring.ai.mcp.server", name="stdio", havingValue="false", matchIfMissing=true) public class MpcWebMvcServerAutoConfiguration extends Object
Auto-configuration for MCP WebMvc Server Transport.

This configuration class sets up the WebMvc-specific transport components for the MCP server, providing Server-Sent Events (SSE) communication through Spring MVC. It is activated when:

  • The WebMvcSseServerTransport class is on the classpath (from mcp-spring-webmvc dependency)
  • Spring MVC's RouterFunction class is available (from spring-boot-starter-web)
  • The spring.ai.mcp.server.transport property is set to WEBMVC

The configuration provides:

  • A WebMvcSseServerTransport bean for handling SSE communication
  • A RouterFunction bean that sets up the SSE endpoint

Required dependencies:


 <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>
 </dependency>
 
Since:
1.0.0
Author:
Christian Tzolov
See Also:
  • Constructor Details

    • MpcWebMvcServerAutoConfiguration

      public MpcWebMvcServerAutoConfiguration()
  • Method Details

    • webMvcSseServerTransport

      @Bean @ConditionalOnMissingBean public io.modelcontextprotocol.server.transport.WebMvcSseServerTransport webMvcSseServerTransport(com.fasterxml.jackson.databind.ObjectMapper objectMapper, McpServerProperties serverProperties)
    • mvcMcpRouterFunction

      @Bean public org.springframework.web.servlet.function.RouterFunction<org.springframework.web.servlet.function.ServerResponse> mvcMcpRouterFunction(io.modelcontextprotocol.server.transport.WebMvcSseServerTransport transport)