Class McpWebMvcServerAutoConfiguration

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

@AutoConfiguration @ConditionalOnClass(io.modelcontextprotocol.server.transport.WebMvcSseServerTransportProvider.class) @ConditionalOnMissingBean(io.modelcontextprotocol.spec.McpServerTransportProvider.class) @Conditional(McpServerStdioDisabledCondition.class) public class McpWebMvcServerAutoConfiguration 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, Yanming Zhou
See Also:
  • Constructor Details

    • McpWebMvcServerAutoConfiguration

      public McpWebMvcServerAutoConfiguration()
  • Method Details

    • webMvcSseServerTransportProvider

      @Bean @ConditionalOnMissingBean public io.modelcontextprotocol.server.transport.WebMvcSseServerTransportProvider webMvcSseServerTransportProvider(org.springframework.beans.factory.ObjectProvider<com.fasterxml.jackson.databind.ObjectMapper> objectMapperProvider, McpServerProperties serverProperties)
    • mvcMcpRouterFunction

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