refactor: update MCP API usage to version 0.8.0
- Remove all book-library MCP examples (servlet, webflux, and webmvc implementations) - Update weather example to use MCP version 0.8.0-SNAPSHOT - Refactor transport handling to use transport providers instead of direct transport objects - Update method calls from toSyncToolRegistration to toSyncToolSpecifications - Add central-portal-snapshots repository to pom.xml for dependency resolution - Align with the new MCP client class names Add MCP Sampling capability with weather example Adds MCP Sampling implementation that demonstrates how to delegate LLM requests to multiple providers. - add a weather server that retrieves data and uses MCP Sampling to generate creative content - add a client that routes requests to different LLM providers (OpenAI and Anthropic) based on model hints - add README documentation explaining the MCP Sampling workflow and implementation details The MCP Sampling capability enables applications to leverage multiple LLM providers within a single workflow, allowing for creative content generation, model comparison, and specialized task delegation. refactor: migrate to spring-ai-mcp-client-spring-boot-starter - Replace spring-ai-mcp dependency with spring-ai-mcp-client-spring-boot-starter - Update import statements from org.springframework.ai.mcp.* to io.modelcontextprotocol.client.* - Replace McpFunctionCallback with SyncMcpToolCallbackProvider - Update Spring AI version from 1.0.0-M5 to 1.0.0-SNAPSHOT in multiple projects - Enable tool callback auto-configuration with spring.ai.mcp.client.toolcallback.enabled refactor: update Spring AI artifact IDs to new naming convention - Update all Spring AI dependencies to use the new naming convention: spring-ai-*-spring-boot-starter → spring-ai-starter-* spring-ai-openai-spring-boot-starter → spring-ai-starter-model-openai spring-ai-mcp-client-spring-boot-starter → spring-ai-starter-mcp-client - And similar patterns for other artifacts - Enable debug mode in brave module's application.properties Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
committed by
Mark Pollack
parent
1ca981eba5
commit
41c921bc33
@@ -4,12 +4,13 @@ import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import io.modelcontextprotocol.client.McpClient;
|
||||
import io.modelcontextprotocol.client.McpSyncClient;
|
||||
import io.modelcontextprotocol.client.transport.ServerParameters;
|
||||
import io.modelcontextprotocol.client.transport.StdioClientTransport;
|
||||
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.mcp.client.McpClient;
|
||||
import org.springframework.ai.mcp.client.McpSyncClient;
|
||||
import org.springframework.ai.mcp.client.transport.ServerParameters;
|
||||
import org.springframework.ai.mcp.client.transport.StdioClientTransport;
|
||||
import org.springframework.ai.mcp.spring.McpFunctionCallback;
|
||||
import org.springframework.ai.mcp.SyncMcpToolCallbackProvider;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -25,11 +26,11 @@ public class Application {
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner predefinedQuestions(ChatClient.Builder chatClientBuilder,
|
||||
List<McpFunctionCallback> functionCallbacks, ConfigurableApplicationContext context) {
|
||||
List<McpSyncClient> mcpClients, ConfigurableApplicationContext context) {
|
||||
|
||||
return args -> {
|
||||
var chatClient = chatClientBuilder
|
||||
.defaultFunctions(functionCallbacks.toArray(new McpFunctionCallback[0]))
|
||||
.defaultTools(new SyncMcpToolCallbackProvider(mcpClients))
|
||||
.build();
|
||||
System.out.println("Running predefined questions with AI model responses:\n");
|
||||
|
||||
@@ -59,17 +60,6 @@ public class Application {
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public List<McpFunctionCallback> functionCallbacks(McpSyncClient mcpClient) {
|
||||
|
||||
var callbacks = mcpClient.listTools(null)
|
||||
.tools()
|
||||
.stream()
|
||||
.map(tool -> new McpFunctionCallback(mcpClient, tool))
|
||||
.toList();
|
||||
return callbacks;
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "close")
|
||||
public McpSyncClient mcpClient() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user