Class McpServerModernWebMvcAutoConfiguration

java.lang.Object
org.springframework.ai.mcp.server.webmvc.autoconfigure.McpServerModernWebMvcAutoConfiguration

@AutoConfiguration(after={McpServerModernAutoConfiguration.class,McpServerJsonMapperAutoConfiguration.class}) @ConditionalOnClass({io.modelcontextprotocol.modern.server.McpServer.class,WebMvcModernServerTransport.class}) @ConditionalOnBean(io.modelcontextprotocol.modern.server.McpServer.class) @EnableConfigurationProperties(McpServerModernProperties.class) @Conditional({McpServerStdioDisabledCondition.class,EnabledModernServerCondition.class}) public class McpServerModernWebMvcAutoConfiguration extends Object
Auto-configuration of the WebMvc transport for the 2026-07-28 ("modern") MCP server. Active when spring.ai.mcp.server.protocol=MODERN and stdio is disabled.

A ServerHttpHeaderValidator bean, when present, validates Origin and Host headers. A McpTransportContextExtractor<ServerRequest> bean, when present, derives the transport context from the request; otherwise the transport context is empty. Every McpServerCustomizer<WebMvcModernServerTransport.Builder> bean is applied, in order, to the transport builder.

Since:
2.1.0
Author:
Christian Tzolov
  • Constructor Details

    • McpServerModernWebMvcAutoConfiguration

      public McpServerModernWebMvcAutoConfiguration()
  • Method Details

    • webMvcModernServerTransport

      @Bean @ConditionalOnMissingBean public WebMvcModernServerTransport webMvcModernServerTransport(io.modelcontextprotocol.modern.server.McpServer mcpServer, @Qualifier("mcpServerJsonMapper") tools.jackson.databind.json.JsonMapper jsonMapper, McpServerModernProperties modernProperties, org.springframework.beans.factory.ObjectProvider<io.modelcontextprotocol.server.transport.ServerHttpHeaderValidator> headerValidator, org.springframework.beans.factory.ObjectProvider<io.modelcontextprotocol.server.McpTransportContextExtractor<org.springframework.web.servlet.function.ServerRequest>> contextExtractor, org.springframework.beans.factory.ObjectProvider<McpServerCustomizer<WebMvcModernServerTransport.Builder>> customizers)
    • webMvcModernServerRouterFunction

      @Bean @ConditionalOnMissingBean(name="webMvcModernServerRouterFunction") public org.springframework.web.servlet.function.RouterFunction<org.springframework.web.servlet.function.ServerResponse> webMvcModernServerRouterFunction(WebMvcModernServerTransport webMvcModernServerTransport)
    • webMvcModernServerTransportLifecycle

      @Bean public org.springframework.context.SmartLifecycle webMvcModernServerTransportLifecycle(WebMvcModernServerTransport webMvcModernServerTransport)