Skip to content
Closed
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 @@ -77,7 +77,7 @@ static class McpAutoConfigEnabled {
}

@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX + ".toolcallback", name = "enabled",
havingValue = "true", matchIfMissing = false)
havingValue = "true", matchIfMissing = true)
static class ToolCallbackProviderEnabled {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

import java.time.Duration;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
Expand Down Expand Up @@ -110,7 +107,7 @@ public enum ClientType {
* <p>
* This configuration is used to enable or disable tool callbacks in the MCP client.
*/
private Toolcallback toolcallback = new Toolcallback(false);
private Toolcallback toolcallback = new Toolcallback();

/**
* Represents a callback configuration for tools.
Expand All @@ -121,14 +118,22 @@ public enum ClientType {
* @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 static class Toolcallback {

/**
* A boolean flag indicating whether the tool callback is enabled. If true, the
* tool callback is active; otherwise, it is disabled.
*/
private boolean enabled = true;

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean isEnabled() {
return this.enabled;
}

}

public boolean isEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,14 @@ void doesNotMatchWhenBothPropertiesAreDisabled() {
}

@Test
void doesNotMatchWhenToolCallbackPropertyIsMissing() {
// McpClientEnabled is true by default if missing, but ToolCallbackEnabled is
// false by default if missing
void doesMatchWhenToolCallbackPropertyIsMissing() {
this.contextRunner.withPropertyValues("spring.ai.mcp.client.enabled=true")
.run(context -> assertThat(context).doesNotHaveBean("testBean"));
.run(context -> assertThat(context).hasBean("testBean"));
}

@Test
void doesNotMatchWhenBothPropertiesAreMissing() {
// McpClientEnabled is true by default if missing, but ToolCallbackEnabled is
// false by default if missing
this.contextRunner.run(context -> assertThat(context).doesNotHaveBean("testBean"));
void doesMatchWhenBothPropertiesAreMissing() {
this.contextRunner.run(context -> assertThat(context).hasBean("testBean"));
}

@Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ public class McpToolCallbackAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(McpToolCallbackAutoConfiguration.class));

@Test
void disabledByDefault() {
void enableddByDefault() {

this.applicationContext.run(context -> {
assertThat(context).doesNotHaveBean("mcpToolCallbacks");
assertThat(context).hasBean("mcpToolCallbacks");
assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks");
});

this.applicationContext
.withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.type=SYNC")
.run(context -> {
assertThat(context).doesNotHaveBean("mcpToolCallbacks");
assertThat(context).hasBean("mcpToolCallbacks");
assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks");
});

this.applicationContext
.withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.type=ASYNC")
.run(context -> {
assertThat(context).doesNotHaveBean("mcpToolCallbacks");
assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks");
assertThat(context).hasBean("mcpAsyncToolCallbacks");
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ The common properties are prefixed with `spring.ai.mcp.client`:

|`toolcallback.enabled`
|Enable/disable the MCP tool callback integration with Spring AI's tool execution framework
|`false`
|`true`
|===

=== Stdio Transport Properties
Expand Down