From 8c338ed88afcbc08b5752f4eb1089fa973e4db51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=9A=E6=B1=A0/Ivan?= Date: Fri, 18 Apr 2025 17:46:46 +0800 Subject: [PATCH] feat(mcp): Add tool callback configuration to MCP client properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iefc9de0425ad0654175172b7f0bc220e74e3227b Signed-off-by: 砚池/Ivan --- .../properties/McpClientCommonProperties.java | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpClientCommonProperties.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpClientCommonProperties.java index d63f1924165..709ab5cef3c 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpClientCommonProperties.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpClientCommonProperties.java @@ -16,10 +16,12 @@ package org.springframework.ai.mcp.client.autoconfigure.properties; -import java.time.Duration; - +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.boot.context.properties.ConfigurationProperties; +import java.time.Duration; + /** * Common Configuration properties for the Model Context Protocol (MCP) clients shared for * all transport types. @@ -101,6 +103,32 @@ public enum ClientType { */ private boolean rootChangeNotification = true; + /** + * Tool callback configuration. + *

+ * This configuration is used to enable or disable tool callbacks in the MCP client. + */ + private Toolcallback toolcallback = new Toolcallback(false); + + /** + * Represents a callback configuration for tools. + *

+ * This record is used to encapsulate the configuration for enabling or disabling tool + * callbacks in the MCP client. + * + * @param enabled A boolean flag indicating whether the tool callback is enabled. If + * true, the tool callback is active; otherwise, it is disabled. + */ + @JsonInclude(JsonInclude.Include.NON_ABSENT) + public record Toolcallback( + + /** + * A boolean flag indicating whether the tool callback is enabled. If true, + * the tool callback is active; otherwise, it is disabled. + */ + @JsonProperty("enabled") boolean enabled) { + } + public boolean isEnabled() { return this.enabled; } @@ -157,4 +185,12 @@ public void setRootChangeNotification(boolean rootChangeNotification) { this.rootChangeNotification = rootChangeNotification; } + public Toolcallback getToolcallback() { + return toolcallback; + } + + public void setToolcallback(Toolcallback toolcallback) { + this.toolcallback = toolcallback; + } + }