Class McpServerModernAutoConfiguration

java.lang.Object
org.springframework.ai.mcp.server.common.autoconfigure.McpServerModernAutoConfiguration

@AutoConfiguration(after=McpServerJsonMapperAutoConfiguration.class) @ConditionalOnClass(io.modelcontextprotocol.modern.server.McpServer.class) @EnableConfigurationProperties({McpServerProperties.class,McpServerModernProperties.class}) @Conditional(EnabledModernServerCondition.class) public class McpServerModernAutoConfiguration extends Object
Auto-configuration for a 2026-07-28 ("modern") MCP server, active when spring.ai.mcp.server.protocol=MODERN.

Each primitive is served by a repository bean: McpSyncToolRepository, McpSyncResourceRepository, McpSyncPromptRepository and McpSyncCompletionRepository. A user-defined repository bean of that type takes precedence; otherwise an in-memory repository is created and fed by every List<McpSyncTool>, List<SyncResourceRegistration>, List<SyncResourceTemplateRegistration>, List<McpSyncPrompt> and List<SyncCompletionRegistration> bean, which is how annotated beans and ToolCallbacks reach the server. The in-memory repositories are beans themselves, so tools can be added or removed at runtime; changes are broadcast to subscriptions/listen clients through the McpChangeFeed bean. An application that wants to filter or decorate a repository per request defines its own repository bean, typically one that builds the in-memory repository from the same list beans and wraps it.

Only the synchronous API type is supported for now; type=ASYNC fails the context at startup.

Since:
2.1.0
Author:
Christian Tzolov
  • Method Details

    • mcpChangeFeed

      @Bean @ConditionalOnMissingBean public io.modelcontextprotocol.modern.server.feature.McpChangeFeed mcpChangeFeed()
    • mcpModernToolRepository

      @Bean @ConditionalOnMissingBean(io.modelcontextprotocol.modern.server.feature.McpSyncToolRepository.class) @ConditionalOnProperty(prefix="spring.ai.mcp.server", name="capabilities.tool", havingValue="true", matchIfMissing=true) public InMemorySyncToolRepository mcpModernToolRepository(org.springframework.beans.factory.ObjectProvider<List<io.modelcontextprotocol.modern.server.feature.McpSyncTool>> tools, io.modelcontextprotocol.modern.server.feature.McpChangeFeed changeFeed, McpServerModernProperties modernProperties)
    • mcpModernResourceRepository

      @Bean @ConditionalOnMissingBean(io.modelcontextprotocol.modern.server.feature.McpSyncResourceRepository.class) @ConditionalOnProperty(prefix="spring.ai.mcp.server", name="capabilities.resource", havingValue="true", matchIfMissing=true) public InMemorySyncResourceRepository mcpModernResourceRepository(org.springframework.beans.factory.ObjectProvider<List<SyncResourceRegistration>> resources, org.springframework.beans.factory.ObjectProvider<List<SyncResourceTemplateRegistration>> resourceTemplates, io.modelcontextprotocol.modern.server.feature.McpChangeFeed changeFeed, McpServerModernProperties modernProperties)
    • mcpModernPromptRepository

      @Bean @ConditionalOnMissingBean(io.modelcontextprotocol.modern.server.feature.McpSyncPromptRepository.class) @ConditionalOnProperty(prefix="spring.ai.mcp.server", name="capabilities.prompt", havingValue="true", matchIfMissing=true) public InMemorySyncPromptRepository mcpModernPromptRepository(org.springframework.beans.factory.ObjectProvider<List<io.modelcontextprotocol.modern.server.feature.McpSyncPrompt>> prompts, io.modelcontextprotocol.modern.server.feature.McpChangeFeed changeFeed, McpServerModernProperties modernProperties)
    • mcpModernCompletionRepository

      @Bean @ConditionalOnMissingBean(io.modelcontextprotocol.modern.server.feature.McpSyncCompletionRepository.class) @ConditionalOnProperty(prefix="spring.ai.mcp.server", name="capabilities.completion", havingValue="true", matchIfMissing=true) public InMemorySyncCompletionRepository mcpModernCompletionRepository(org.springframework.beans.factory.ObjectProvider<List<SyncCompletionRegistration>> completions)
    • mcpModernServer

      @Bean @ConditionalOnMissingBean public io.modelcontextprotocol.modern.server.McpServer mcpModernServer(@Qualifier("mcpServerJsonMapper") tools.jackson.databind.json.JsonMapper jsonMapper, McpServerProperties serverProperties, McpServerModernProperties modernProperties, org.springframework.beans.factory.ObjectProvider<io.modelcontextprotocol.modern.server.feature.McpSyncToolRepository> toolRepository, org.springframework.beans.factory.ObjectProvider<io.modelcontextprotocol.modern.server.feature.McpSyncResourceRepository> resourceRepository, org.springframework.beans.factory.ObjectProvider<io.modelcontextprotocol.modern.server.feature.McpSyncPromptRepository> promptRepository, org.springframework.beans.factory.ObjectProvider<io.modelcontextprotocol.modern.server.feature.McpSyncCompletionRepository> completionRepository, io.modelcontextprotocol.modern.server.feature.McpChangeFeed changeFeed, org.springframework.beans.factory.ObjectProvider<io.modelcontextprotocol.modern.server.RequestStateCodec> requestStateCodec, org.springframework.beans.factory.ObjectProvider<McpModernServerCustomizer> customizers)
    • mcpModernStdioTransport

      @Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix="spring.ai.mcp.server", name="stdio", havingValue="true") public io.modelcontextprotocol.modern.server.transport.StdioMcpTransport mcpModernStdioTransport(io.modelcontextprotocol.modern.server.McpServer mcpServer, @Qualifier("mcpServerJsonMapper") tools.jackson.databind.json.JsonMapper jsonMapper)
    • mcpModernStdioTransportLifecycle

      @Bean @ConditionalOnProperty(prefix="spring.ai.mcp.server", name="stdio", havingValue="true") public McpServerModernAutoConfiguration.StdioMcpTransportLifecycle mcpModernStdioTransportLifecycle(io.modelcontextprotocol.modern.server.transport.StdioMcpTransport stdioTransport)