Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit 120b5b2

Browse files
committed
demo
1 parent b22ee0a commit 120b5b2

File tree

1 file changed

+49
-9
lines changed
  • spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot

1 file changed

+49
-9
lines changed

spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot/McpApplication.java

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,50 @@ public CommandLineRunner test(ChatClient.Builder chatClientBuilder, List<McpFunc
3131
var chatClient = chatClientBuilder.defaultFunctions(functionCallbacks.toArray(new McpFunctionCallback[0]))
3232
.build();
3333

34-
var response = chatClient.prompt("What is the content of the test.txt file?").call().content();
34+
System.out.println(
35+
"Can you connect to my SQLite database and tell me what products are available, and their prices?");
36+
37+
var response = chatClient.prompt(
38+
"Can you connect to my SQLite database and tell me what products are available, and their prices?")
39+
.call().content();
40+
41+
System.out.println(response);
42+
43+
System.out.println("\nWhat's the average price of all products in the database?");
44+
45+
response = chatClient.prompt(
46+
"What's the average price of all products in the database?")
47+
.call().content();
48+
49+
System.out.println(response);
50+
51+
System.out.println("\nCan you analyze the price distribution and suggest any pricing optimizations?");
52+
53+
response = chatClient.prompt(
54+
"Can you analyze the price distribution and suggest any pricing optimizations?")
55+
.call().content();
3556

3657
System.out.println(response);
3758

59+
System.out.println("\nCould you help me design and create a new table for storing customer orders?");
60+
3861
response = chatClient.prompt(
39-
"Please summarize the content of the test.txt file, covert the result in markdown format and store it into test.md")
40-
.call()
41-
.content();
42-
System.out.println("Summary:" + response);
62+
"Could you help me design and create a new table for storing customer orders?")
63+
.call().content();
64+
65+
System.out.println(response);
66+
67+
// var response = chatClient.prompt("What is the content of the test.txt
68+
// file?").call().content();
69+
70+
// System.out.println(response);
71+
72+
// response = chatClient.prompt(
73+
// "Please summarize the content of the test.txt file, covert the result in
74+
// markdown format and store it into test.md")
75+
// .call()
76+
// .content();
77+
// System.out.println("Summary:" + response);
4378
};
4479
}
4580

@@ -54,11 +89,16 @@ public List<McpFunctionCallback> functionCallbacks(McpSyncClient mcpClient) {
5489
}
5590

5691
@Bean(destroyMethod = "close")
57-
public McpSyncClient clientSession() {
92+
public McpSyncClient mcpClient() {
93+
94+
// var stdioParams = ServerParameters.builder("npx")
95+
// .args("-y", "@modelcontextprotocol/server-filesystem",
96+
// "/Users/christiantzolov/Dev/projects/demo/mcp-server/dir")
97+
// .build();
5898

59-
var stdioParams = ServerParameters.builder("npx")
60-
.args("-y", "@modelcontextprotocol/server-filesystem",
61-
"/Users/christiantzolov/Dev/projects/demo/mcp-server/dir")
99+
var stdioParams = ServerParameters.builder("uvx")
100+
.args("mcp-server-sqlite", "--db-path",
101+
"/Users/christiantzolov/test.db")
62102
.build();
63103

64104
McpSyncClient mcpClient = null;

0 commit comments

Comments
 (0)