Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import io.modelcontextprotocol.spec.McpStreamableServerTransportProvider;
import reactor.core.publisher.Mono;

import org.springframework.ai.mcp.server.common.autoconfigure.properties.McpServerChangeNotificationProperties;
import org.springframework.ai.mcp.server.common.autoconfigure.properties.McpServerProperties;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
Expand Down Expand Up @@ -78,7 +77,7 @@
"org.springframework.ai.mcp.server.autoconfigure.McpServerStreamableHttpWebMvcAutoConfiguration",
"org.springframework.ai.mcp.server.autoconfigure.McpServerStreamableHttpWebFluxAutoConfiguration" })
@ConditionalOnClass({ McpSchema.class })
@EnableConfigurationProperties({ McpServerProperties.class, McpServerChangeNotificationProperties.class })
@EnableConfigurationProperties({ McpServerProperties.class })
@ConditionalOnProperty(prefix = McpServerProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
matchIfMissing = true)
@Conditional(McpServerAutoConfiguration.NonStatlessServerCondition.class)
Expand All @@ -103,7 +102,6 @@ public McpSchema.ServerCapabilities.Builder capabilitiesBuilder() {
matchIfMissing = true)
public McpSyncServer mcpSyncServer(McpServerTransportProviderBase transportProvider,
McpSchema.ServerCapabilities.Builder capabilitiesBuilder, McpServerProperties serverProperties,
McpServerChangeNotificationProperties changeNotificationProperties,
ObjectProvider<List<SyncToolSpecification>> tools,
ObjectProvider<List<SyncResourceSpecification>> resources,
ObjectProvider<List<SyncPromptSpecification>> prompts,
Expand All @@ -127,8 +125,8 @@ public McpSyncServer mcpSyncServer(McpServerTransportProviderBase transportProvi
// Tools
if (serverProperties.getCapabilities().isTool()) {
logger.info("Enable tools capabilities, notification: "
+ changeNotificationProperties.isToolChangeNotification());
capabilitiesBuilder.tools(changeNotificationProperties.isToolChangeNotification());
+ serverProperties.getToolChangeNotification().isToolChangeNotification());
capabilitiesBuilder.tools(serverProperties.getToolChangeNotification().isToolChangeNotification());

List<SyncToolSpecification> toolSpecifications = new ArrayList<>(
tools.stream().flatMap(List::stream).toList());
Expand All @@ -142,8 +140,9 @@ public McpSyncServer mcpSyncServer(McpServerTransportProviderBase transportProvi
// Resources
if (serverProperties.getCapabilities().isResource()) {
logger.info("Enable resources capabilities, notification: "
+ changeNotificationProperties.isResourceChangeNotification());
capabilitiesBuilder.resources(false, changeNotificationProperties.isResourceChangeNotification());
+ serverProperties.getToolChangeNotification().isResourceChangeNotification());
capabilitiesBuilder.resources(false,
serverProperties.getToolChangeNotification().isResourceChangeNotification());

List<SyncResourceSpecification> resourceSpecifications = resources.stream().flatMap(List::stream).toList();
if (!CollectionUtils.isEmpty(resourceSpecifications)) {
Expand All @@ -155,8 +154,8 @@ public McpSyncServer mcpSyncServer(McpServerTransportProviderBase transportProvi
// Prompts
if (serverProperties.getCapabilities().isPrompt()) {
logger.info("Enable prompts capabilities, notification: "
+ changeNotificationProperties.isPromptChangeNotification());
capabilitiesBuilder.prompts(changeNotificationProperties.isPromptChangeNotification());
+ serverProperties.getToolChangeNotification().isPromptChangeNotification());
capabilitiesBuilder.prompts(serverProperties.getToolChangeNotification().isPromptChangeNotification());

List<SyncPromptSpecification> promptSpecifications = prompts.stream().flatMap(List::stream).toList();
if (!CollectionUtils.isEmpty(promptSpecifications)) {
Expand Down Expand Up @@ -202,7 +201,6 @@ public McpSyncServer mcpSyncServer(McpServerTransportProviderBase transportProvi
@ConditionalOnProperty(prefix = McpServerProperties.CONFIG_PREFIX, name = "type", havingValue = "ASYNC")
public McpAsyncServer mcpAsyncServer(McpServerTransportProviderBase transportProvider,
McpSchema.ServerCapabilities.Builder capabilitiesBuilder, McpServerProperties serverProperties,
McpServerChangeNotificationProperties changeNotificationProperties,
ObjectProvider<List<AsyncToolSpecification>> tools,
ObjectProvider<List<AsyncResourceSpecification>> resources,
ObjectProvider<List<AsyncPromptSpecification>> prompts,
Expand All @@ -228,8 +226,8 @@ public McpAsyncServer mcpAsyncServer(McpServerTransportProviderBase transportPro
tools.stream().flatMap(List::stream).toList());

logger.info("Enable tools capabilities, notification: "
+ changeNotificationProperties.isToolChangeNotification());
capabilitiesBuilder.tools(changeNotificationProperties.isToolChangeNotification());
+ serverProperties.getToolChangeNotification().isToolChangeNotification());
capabilitiesBuilder.tools(serverProperties.getToolChangeNotification().isToolChangeNotification());

if (!CollectionUtils.isEmpty(toolSpecifications)) {
serverBuilder.tools(toolSpecifications);
Expand All @@ -240,8 +238,9 @@ public McpAsyncServer mcpAsyncServer(McpServerTransportProviderBase transportPro
// Resources
if (serverProperties.getCapabilities().isResource()) {
logger.info("Enable resources capabilities, notification: "
+ changeNotificationProperties.isResourceChangeNotification());
capabilitiesBuilder.resources(false, changeNotificationProperties.isResourceChangeNotification());
+ serverProperties.getToolChangeNotification().isResourceChangeNotification());
capabilitiesBuilder.resources(false,
serverProperties.getToolChangeNotification().isResourceChangeNotification());

List<AsyncResourceSpecification> resourceSpecifications = resources.stream().flatMap(List::stream).toList();
if (!CollectionUtils.isEmpty(resourceSpecifications)) {
Expand All @@ -253,8 +252,8 @@ public McpAsyncServer mcpAsyncServer(McpServerTransportProviderBase transportPro
// Prompts
if (serverProperties.getCapabilities().isPrompt()) {
logger.info("Enable prompts capabilities, notification: "
+ changeNotificationProperties.isPromptChangeNotification());
capabilitiesBuilder.prompts(changeNotificationProperties.isPromptChangeNotification());
+ serverProperties.getToolChangeNotification().isPromptChangeNotification());
capabilitiesBuilder.prompts(serverProperties.getToolChangeNotification().isPromptChangeNotification());
List<AsyncPromptSpecification> promptSpecifications = prompts.stream().flatMap(List::stream).toList();

if (!CollectionUtils.isEmpty(promptSpecifications)) {
Expand Down

This file was deleted.

Loading