From 120b5b224245d0474dd5914b83c000e586c131dc Mon Sep 17 00:00:00 2001 From: Christian Tzolov Date: Wed, 11 Dec 2024 01:35:20 +0100 Subject: [PATCH] demo --- .../ai/mcp/spring/boot/McpApplication.java | 58 ++++++++++++++++--- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot/McpApplication.java b/spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot/McpApplication.java index f603956..b7a2758 100644 --- a/spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot/McpApplication.java +++ b/spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot/McpApplication.java @@ -31,15 +31,50 @@ public class McpApplication { var chatClient = chatClientBuilder.defaultFunctions(functionCallbacks.toArray(new McpFunctionCallback[0])) .build(); - var response = chatClient.prompt("What is the content of the test.txt file?").call().content(); + System.out.println( + "Can you connect to my SQLite database and tell me what products are available, and their prices?"); + + var response = chatClient.prompt( + "Can you connect to my SQLite database and tell me what products are available, and their prices?") + .call().content(); System.out.println(response); + System.out.println("\nWhat's the average price of all products in the database?"); + response = chatClient.prompt( - "Please summarize the content of the test.txt file, covert the result in markdown format and store it into test.md") - .call() - .content(); - System.out.println("Summary:" + response); + "What's the average price of all products in the database?") + .call().content(); + + System.out.println(response); + + System.out.println("\nCan you analyze the price distribution and suggest any pricing optimizations?"); + + response = chatClient.prompt( + "Can you analyze the price distribution and suggest any pricing optimizations?") + .call().content(); + + System.out.println(response); + + System.out.println("\nCould you help me design and create a new table for storing customer orders?"); + + response = chatClient.prompt( + "Could you help me design and create a new table for storing customer orders?") + .call().content(); + + System.out.println(response); + + // var response = chatClient.prompt("What is the content of the test.txt + // file?").call().content(); + + // System.out.println(response); + + // response = chatClient.prompt( + // "Please summarize the content of the test.txt file, covert the result in + // markdown format and store it into test.md") + // .call() + // .content(); + // System.out.println("Summary:" + response); }; } @@ -54,11 +89,16 @@ public class McpApplication { } @Bean(destroyMethod = "close") - public McpSyncClient clientSession() { + public McpSyncClient mcpClient() { - var stdioParams = ServerParameters.builder("npx") - .args("-y", "@modelcontextprotocol/server-filesystem", - "/Users/christiantzolov/Dev/projects/demo/mcp-server/dir") + // var stdioParams = ServerParameters.builder("npx") + // .args("-y", "@modelcontextprotocol/server-filesystem", + // "/Users/christiantzolov/Dev/projects/demo/mcp-server/dir") + // .build(); + + var stdioParams = ServerParameters.builder("uvx") + .args("mcp-server-sqlite", "--db-path", + "/Users/christiantzolov/test.db") .build(); McpSyncClient mcpClient = null;