fix(mcp sampling): Disable MCP tool callbacks to prevent cyclic dependencies
- Add note in documentation about preventing cyclic dependencies - Disable mcp tool callback auto-configuration: spring.ai.mcp.client.toolcallback.enabled=false Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
@@ -140,6 +140,8 @@ McpSyncClientCustomizer samplingCustomizer(Map<String, ChatClient> chatClients)
|
||||
}
|
||||
```
|
||||
|
||||
NOTE: To prevent cyclic dependencies you have to disable MCP tool callbacks auto-configuration: `spring.ai.mcp.client.toolcallback.enabled=false`
|
||||
|
||||
## Running the Examples
|
||||
|
||||
### Prerequisites
|
||||
|
||||
@@ -120,8 +120,8 @@ spring.ai.mcp.client.sse.connections.server1.url=http://localhost:8080
|
||||
logging.level.io.modelcontextprotocol.client=WARN
|
||||
logging.level.io.modelcontextprotocol.spec=WARN
|
||||
|
||||
# Uncomment to disable MCP tool callbacks
|
||||
# spring.ai.mcp.client.toolcallback.enabled=false
|
||||
#Disable MCP tool callbacks
|
||||
spring.ai.mcp.client.toolcallback.enabled=false
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
@@ -31,19 +31,18 @@ import org.springframework.ai.openai.OpenAiChatModel;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class McpClientApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(McpClientApplication.class, args);
|
||||
SpringApplication.run(McpClientApplication.class, args).close();;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner predefinedQuestions(OpenAiChatModel openAiChatModel,
|
||||
ConfigurableApplicationContext context, List<McpSyncClient> mcpClients) {
|
||||
List<McpSyncClient> mcpClients) {
|
||||
|
||||
return args -> {
|
||||
|
||||
@@ -59,8 +58,6 @@ public class McpClientApplication {
|
||||
|
||||
System.out.println("> USER: " + userQuestion);
|
||||
System.out.println("> ASSISTANT: " + chatClient.prompt(userQuestion).call().content());
|
||||
|
||||
context.close();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,4 +13,4 @@ logging.level.io.modelcontextprotocol.client=WARN
|
||||
logging.level.io.modelcontextprotocol.spec=WARN
|
||||
|
||||
|
||||
# spring.ai.mcp.client.toolcallback.enabled=false
|
||||
spring.ai.mcp.client.toolcallback.enabled=false
|
||||
Reference in New Issue
Block a user