This commit is contained in:
Christian Tzolov 2024-12-11 01:35:20 +01:00
commit 120b5b2242

View file

@ -31,15 +31,50 @@ public class McpApplication {
var chatClient = chatClientBuilder.defaultFunctions(functionCallbacks.toArray(new McpFunctionCallback[0])) var chatClient = chatClientBuilder.defaultFunctions(functionCallbacks.toArray(new McpFunctionCallback[0]))
.build(); .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(response);
System.out.println("\nWhat's the average price of all products in the database?");
response = chatClient.prompt( response = chatClient.prompt(
"Please summarize the content of the test.txt file, covert the result in markdown format and store it into test.md") "What's the average price of all products in the database?")
.call() .call().content();
.content();
System.out.println("Summary:" + response); 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") @Bean(destroyMethod = "close")
public McpSyncClient clientSession() { public McpSyncClient mcpClient() {
var stdioParams = ServerParameters.builder("npx") // var stdioParams = ServerParameters.builder("npx")
.args("-y", "@modelcontextprotocol/server-filesystem", // .args("-y", "@modelcontextprotocol/server-filesystem",
"/Users/christiantzolov/Dev/projects/demo/mcp-server/dir") // "/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(); .build();
McpSyncClient mcpClient = null; McpSyncClient mcpClient = null;