Skip to content

Commit 85ebbc8

Browse files
committed
update to latest MCP deps
Signed-off-by: Christian Tzolov <[email protected]>
1 parent 19f6d59 commit 85ebbc8

File tree

9 files changed

+46
-11
lines changed
  • model-context-protocol

9 files changed

+46
-11
lines changed

model-context-protocol/mcp-annotations/mcp-annotations-client/src/main/java/org/springframework/ai/mcp/samples/client/McpClientApplication.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
import io.modelcontextprotocol.client.McpSyncClient;
2727
import io.modelcontextprotocol.spec.McpSchema.CallToolRequest;
2828
import io.modelcontextprotocol.spec.McpSchema.CallToolResult;
29+
import io.modelcontextprotocol.spec.McpSchema.CompleteRequest;
30+
import io.modelcontextprotocol.spec.McpSchema.CompleteRequest.CompleteArgument;
31+
import io.modelcontextprotocol.spec.McpSchema.CompleteResult;
32+
import io.modelcontextprotocol.spec.McpSchema.GetPromptRequest;
33+
import io.modelcontextprotocol.spec.McpSchema.GetPromptResult;
34+
import io.modelcontextprotocol.spec.McpSchema.PromptReference;
2935

3036
@SpringBootApplication
3137
public class McpClientApplication {
@@ -49,10 +55,26 @@ public CommandLineRunner predefinedQuestions(
4955
.arguments(Map.of("input", "test input"))
5056
.progressToken("test-progress-token")
5157
.build();
52-
5358
CallToolResult response = mcpClient.callTool(toolRequest);
54-
5559
System.out.println("Tool response: " + response);
60+
61+
CompleteResult nameCompletion = mcpClient.completeCompletion(
62+
new CompleteRequest(
63+
new PromptReference("personalized-message"),
64+
new CompleteArgument("name", "J")));
65+
66+
System.out.println("Name completions: " + nameCompletion.completion());
67+
68+
String nameValue = nameCompletion.completion().values().get(3);
69+
70+
try {
71+
GetPromptResult promptResponse = mcpClient
72+
.getPrompt(new GetPromptRequest("personalized-message", Map.of("name", nameValue)));
73+
74+
System.out.println("Prompt response: " + promptResponse);
75+
} catch (Exception e) {
76+
System.err.println("Error getting prompt: " + e.getMessage());
77+
}
5678
}
5779
};
5880
}

model-context-protocol/mcp-annotations/mcp-annotations-server/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
</dependencyManagement>
3232

3333
<dependencies>
34+
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-actuator</artifactId>
38+
</dependency>
39+
3440
<dependency>
3541
<groupId>org.springframework.ai</groupId>
3642
<artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>

model-context-protocol/mcp-annotations/mcp-annotations-server/src/main/java/org/springframework/ai/mcp/sample/server/providers/PromptProvider.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ public GetPromptResult personalizedMessage(McpSyncServerExchange exchange,
6464
@McpArg(name = "interests", description = "The user's interests", required = false) String interests) {
6565

6666
exchange.loggingNotification(LoggingMessageNotification.builder()
67-
.level(LoggingLevel.INFO)
68-
.data("personalized-message event").build());
67+
// .level(LoggingLevel.INFO)
68+
.data("personalized-message event")
69+
.build());
6970

7071
StringBuilder message = new StringBuilder();
71-
message.append("Hello, ").append(name).append("!\n\n");
72+
message.append("\nHello, ").append(name).append("!\n");
7273

7374
if (age != null) {
7475
message.append("At ").append(age).append(" years old, you have ");

model-context-protocol/mcp-annotations/mcp-annotations-server/src/test/java/org/springframework/ai/mcp/sample/client/ClientStdio.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import io.modelcontextprotocol.client.transport.ServerParameters;
2121
import io.modelcontextprotocol.client.transport.StdioClientTransport;
22+
import io.modelcontextprotocol.json.McpJsonMapper;
2223

2324
/**
2425
* With stdio transport, the MCP server is automatically started by the client.
@@ -41,7 +42,7 @@ public static void main(String[] args) {
4142
"model-context-protocol/weather/starter-webmvc-server/target/mcp-weather-starter-webmvc-server-0.0.1-SNAPSHOT.jar")
4243
.build();
4344

44-
var transport = new StdioClientTransport(stdioParams);
45+
var transport = new StdioClientTransport(stdioParams, McpJsonMapper.createDefault());
4546

4647
new SampleClient(transport).run();
4748
}

model-context-protocol/sampling/annotations/mcp-sampling-server-annotations/src/test/java/org/springframework/ai/mcp/sample/client/ClientStdio.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import io.modelcontextprotocol.client.transport.ServerParameters;
2121
import io.modelcontextprotocol.client.transport.StdioClientTransport;
22+
import io.modelcontextprotocol.json.McpJsonMapper;
2223

2324
/**
2425
* With stdio transport, the MCP server is automatically started by the client.
@@ -41,7 +42,7 @@ public static void main(String[] args) {
4142
"model-context-protocol/sampling/mcp-weather-webmvc-server/target/mcp-sampling-weather-server-0.0.1-SNAPSHOT.jar")
4243
.build();
4344

44-
var transport = new StdioClientTransport(stdioParams);
45+
var transport = new StdioClientTransport(stdioParams, McpJsonMapper.createDefault());
4546

4647
new SampleClient(transport).run();
4748
}

model-context-protocol/sampling/mcp-sampling-server/src/test/java/org/springframework/ai/mcp/sample/client/ClientStdio.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import io.modelcontextprotocol.client.transport.ServerParameters;
2121
import io.modelcontextprotocol.client.transport.StdioClientTransport;
22+
import io.modelcontextprotocol.json.McpJsonMapper;
2223

2324
/**
2425
* With stdio transport, the MCP server is automatically started by the client.
@@ -41,7 +42,7 @@ public static void main(String[] args) {
4142
"model-context-protocol/sampling/mcp-weather-webmvc-server/target/mcp-sampling-weather-server-0.0.1-SNAPSHOT.jar")
4243
.build();
4344

44-
var transport = new StdioClientTransport(stdioParams);
45+
var transport = new StdioClientTransport(stdioParams, McpJsonMapper.createDefault());
4546

4647
new SampleClient(transport).run();
4748
}

model-context-protocol/weather/starter-webflux-server/src/test/java/org/springframework/ai/mcp/sample/client/ClientSse.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.springframework.ai.mcp.sample.client;
1717

1818
import io.modelcontextprotocol.client.transport.WebFluxSseClientTransport;
19+
import io.modelcontextprotocol.json.McpJsonMapper;
1920

2021
import org.springframework.web.reactive.function.client.WebClient;
2122

@@ -25,7 +26,7 @@
2526
public class ClientSse {
2627

2728
public static void main(String[] args) {
28-
var transport = new WebFluxSseClientTransport(WebClient.builder().baseUrl("http://localhost:8080"));
29+
var transport = new WebFluxSseClientTransport(WebClient.builder().baseUrl("http://localhost:8080"), McpJsonMapper.createDefault());
2930
new SampleClient(transport).run();
3031
}
3132

model-context-protocol/weather/starter-webflux-server/src/test/java/org/springframework/ai/mcp/sample/client/ClientStdio.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import io.modelcontextprotocol.client.transport.ServerParameters;
2121
import io.modelcontextprotocol.client.transport.StdioClientTransport;
22+
import io.modelcontextprotocol.json.McpJsonMapper;
2223

2324
/**
2425
* With stdio transport, the MCP server is automatically started by the client.
@@ -41,7 +42,7 @@ public static void main(String[] args) {
4142
"model-context-protocol/weather/starter-webflux-server/target/mcp-weather-starter-webflux-server-0.0.1-SNAPSHOT.jar")
4243
.build();
4344

44-
var transport = new StdioClientTransport(stdioParams);
45+
var transport = new StdioClientTransport(stdioParams, McpJsonMapper.createDefault());
4546

4647
new SampleClient(transport).run();
4748
}

model-context-protocol/weather/starter-webmvc-server/src/test/java/org/springframework/ai/mcp/sample/client/ClientStdio.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import io.modelcontextprotocol.client.transport.ServerParameters;
2121
import io.modelcontextprotocol.client.transport.StdioClientTransport;
22+
import io.modelcontextprotocol.json.McpJsonMapper;
2223

2324
/**
2425
* With stdio transport, the MCP server is automatically started by the client.
@@ -41,7 +42,7 @@ public static void main(String[] args) {
4142
"model-context-protocol/weather/starter-webmvc-server/target/mcp-weather-starter-webmvc-server-0.0.1-SNAPSHOT.jar")
4243
.build();
4344

44-
var transport = new StdioClientTransport(stdioParams);
45+
var transport = new StdioClientTransport(stdioParams, McpJsonMapper.createDefault());
4546

4647
new SampleClient(transport).run();
4748
}

0 commit comments

Comments
 (0)