Skip to content

Commit 28b95e3

Browse files
committed
samples: improve client prompts and HTML output
Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
1 parent 4ee31c1 commit 28b95e3

File tree

2 files changed

+14
-1
lines changed
  • samples
    • sample-mcp-client-webflux/src/main/java/org/springaicommunity/mcp/security/sample/client
    • sample-mcp-client/src/main/java/org/springaicommunity/mcp/security/sample/client

2 files changed

+14
-1
lines changed

samples/sample-mcp-client-webflux/src/main/java/org/springaicommunity/mcp/security/sample/client/DemoController.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616

1717
package org.springaicommunity.mcp.security.sample.client;
1818

19-
import jakarta.servlet.http.HttpServletResponse;
2019
import java.io.IOException;
2120
import java.util.stream.Collectors;
2221

22+
import jakarta.servlet.http.HttpServletResponse;
23+
2324
import org.springframework.ai.chat.client.ChatClient;
2425
import org.springframework.ai.mcp.SyncMcpToolCallbackProvider;
2526
import org.springframework.util.StringUtils;
@@ -46,6 +47,7 @@ String index(String query) {
4647
var chatResponse = chatClient.prompt("""
4748
What is the weather in %s right now?
4849
Compare to historical data over the past 5 years.
50+
Tell me if it is within the usual range.
4951
Format the output in plain HTML, no CSS.""".formatted(query))
5052
.toolCallbacks(new SyncMcpToolCallbackProvider(mcpClientRepo.getClients()))
5153
.call()
@@ -68,13 +70,18 @@ String index(String query) {
6870
return """
6971
<h1>Demo controller</h1>
7072
%s
73+
74+
<hr>
75+
7176
<h2>Ask for the weather</h2>
7277
<p>In which city would you like to see the weather?</p>
7378
<form action="" method="GET">
7479
<input type="text" name="query" value="" placeholder="Paris" />
7580
<button type="submit">Ask the LLM</button>
7681
</form>
7782
83+
<hr>
84+
7885
<h2>Registered MCP servers:</h2>
7986
<ul>
8087
%s

samples/sample-mcp-client/src/main/java/org/springaicommunity/mcp/security/sample/client/DemoController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ String index(String query) {
4747
var chatResponse = chatClient.prompt("""
4848
What is the weather in %s right now?
4949
Compare to historical data over the past 5 years.
50+
Tell me if it is within the usual range.
5051
Format the output in plain HTML, no CSS.""".formatted(query))
5152
.toolCallbacks(new SyncMcpToolCallbackProvider(mcpClientRepo.getClients()))
5253
.call()
@@ -69,13 +70,18 @@ String index(String query) {
6970
return """
7071
<h1>Demo controller</h1>
7172
%s
73+
74+
<hr>
75+
7276
<h2>Ask for the weather</h2>
7377
<p>In which city would you like to see the weather?</p>
7478
<form action="" method="GET">
7579
<input type="text" name="query" value="" placeholder="Paris" />
7680
<button type="submit">Ask the LLM</button>
7781
</form>
7882
83+
<hr>
84+
7985
<h2>Registered MCP servers:</h2>
8086
<ul>
8187
%s

0 commit comments

Comments
 (0)