Skip to content

Commit 9be29fe

Browse files
committed
Merge remote-tracking branch 'origin/main'
# Conflicts: # mcp/src/main/java/io/modelcontextprotocol/server/transport/HttpServletSseServerTransportProvider.java
2 parents 6561d16 + 261554b commit 9be29fe

File tree

95 files changed

+3635
-8569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3635
-8569
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
A set of projects that provide Java SDK integration for the [Model Context Protocol](https://modelcontextprotocol.org/docs/concepts/architecture).
55
This SDK enables Java applications to interact with AI models and tools through a standardized interface, supporting both synchronous and asynchronous communication patterns.
66

7-
## 📚 Reference Documentation
7+
## 📚 Reference Documentation
88

99
#### MCP Java SDK documentation
1010
For comprehensive guides and SDK API documentation, visit the [MCP Java SDK Reference Documentation](https://modelcontextprotocol.io/sdk/java/mcp-overview).

mcp-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.modelcontextprotocol.sdk</groupId>
99
<artifactId>mcp-parent</artifactId>
10-
<version>0.9.0-SNAPSHOT</version>
10+
<version>0.10.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>mcp-bom</artifactId>

mcp-spring/mcp-spring-webflux/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.modelcontextprotocol.sdk</groupId>
88
<artifactId>mcp-parent</artifactId>
9-
<version>0.9.0-SNAPSHOT</version>
9+
<version>0.10.0-SNAPSHOT</version>
1010
<relativePath>../../pom.xml</relativePath>
1111
</parent>
1212
<artifactId>mcp-spring-webflux</artifactId>
@@ -25,13 +25,13 @@
2525
<dependency>
2626
<groupId>io.modelcontextprotocol.sdk</groupId>
2727
<artifactId>mcp</artifactId>
28-
<version>0.9.0-SNAPSHOT</version>
28+
<version>0.10.0-SNAPSHOT</version>
2929
</dependency>
3030

3131
<dependency>
3232
<groupId>io.modelcontextprotocol.sdk</groupId>
3333
<artifactId>mcp-test</artifactId>
34-
<version>0.9.0-SNAPSHOT</version>
34+
<version>0.10.0-SNAPSHOT</version>
3535
<scope>test</scope>
3636
</dependency>
3737

mcp-spring/mcp-spring-webflux/src/main/java/io/modelcontextprotocol/client/transport/WebFluxSseClientTransport.java

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class WebFluxSseClientTransport implements McpClientTransport {
7979
* Default SSE endpoint path as specified by the MCP transport specification. This
8080
* endpoint is used to establish the SSE connection with the server.
8181
*/
82-
private static final String SSE_ENDPOINT = "/sse";
82+
private static final String DEFAULT_SSE_ENDPOINT = "/sse";
8383

8484
/**
8585
* Type reference for parsing SSE events containing string data.
@@ -117,6 +117,12 @@ public class WebFluxSseClientTransport implements McpClientTransport {
117117
*/
118118
protected final Sinks.One<String> messageEndpointSink = Sinks.one();
119119

120+
/**
121+
* The SSE endpoint URI provided by the server. Used for sending outbound messages via
122+
* HTTP POST requests.
123+
*/
124+
private String sseEndpoint;
125+
120126
/**
121127
* Constructs a new SseClientTransport with the specified WebClient builder. Uses a
122128
* default ObjectMapper instance for JSON processing.
@@ -137,11 +143,27 @@ public WebFluxSseClientTransport(WebClient.Builder webClientBuilder) {
137143
* @throws IllegalArgumentException if either parameter is null
138144
*/
139145
public WebFluxSseClientTransport(WebClient.Builder webClientBuilder, ObjectMapper objectMapper) {
146+
this(webClientBuilder, objectMapper, DEFAULT_SSE_ENDPOINT);
147+
}
148+
149+
/**
150+
* Constructs a new SseClientTransport with the specified WebClient builder and
151+
* ObjectMapper. Initializes both inbound and outbound message processing pipelines.
152+
* @param webClientBuilder the WebClient.Builder to use for creating the WebClient
153+
* instance
154+
* @param objectMapper the ObjectMapper to use for JSON processing
155+
* @param sseEndpoint the SSE endpoint URI to use for establishing the connection
156+
* @throws IllegalArgumentException if either parameter is null
157+
*/
158+
public WebFluxSseClientTransport(WebClient.Builder webClientBuilder, ObjectMapper objectMapper,
159+
String sseEndpoint) {
140160
Assert.notNull(objectMapper, "ObjectMapper must not be null");
141161
Assert.notNull(webClientBuilder, "WebClient.Builder must not be null");
162+
Assert.hasText(sseEndpoint, "SSE endpoint must not be null or empty");
142163

143164
this.objectMapper = objectMapper;
144165
this.webClient = webClientBuilder.build();
166+
this.sseEndpoint = sseEndpoint;
145167
}
146168

147169
/**
@@ -254,7 +276,7 @@ public Mono<Void> sendMessage(JSONRPCMessage message) {
254276
protected Flux<ServerSentEvent<String>> eventStream() {// @formatter:off
255277
return this.webClient
256278
.get()
257-
.uri(SSE_ENDPOINT)
279+
.uri(this.sseEndpoint)
258280
.accept(MediaType.TEXT_EVENT_STREAM)
259281
.retrieve()
260282
.bodyToFlux(SSE_TYPE)
@@ -321,4 +343,66 @@ public <T> T unmarshalFrom(Object data, TypeReference<T> typeRef) {
321343
return this.objectMapper.convertValue(data, typeRef);
322344
}
323345

346+
/**
347+
* Creates a new builder for {@link WebFluxSseClientTransport}.
348+
* @param webClientBuilder the WebClient.Builder to use for creating the WebClient
349+
* instance
350+
* @return a new builder instance
351+
*/
352+
public static Builder builder(WebClient.Builder webClientBuilder) {
353+
return new Builder(webClientBuilder);
354+
}
355+
356+
/**
357+
* Builder for {@link WebFluxSseClientTransport}.
358+
*/
359+
public static class Builder {
360+
361+
private final WebClient.Builder webClientBuilder;
362+
363+
private String sseEndpoint = DEFAULT_SSE_ENDPOINT;
364+
365+
private ObjectMapper objectMapper = new ObjectMapper();
366+
367+
/**
368+
* Creates a new builder with the specified WebClient.Builder.
369+
* @param webClientBuilder the WebClient.Builder to use
370+
*/
371+
public Builder(WebClient.Builder webClientBuilder) {
372+
Assert.notNull(webClientBuilder, "WebClient.Builder must not be null");
373+
this.webClientBuilder = webClientBuilder;
374+
}
375+
376+
/**
377+
* Sets the SSE endpoint path.
378+
* @param sseEndpoint the SSE endpoint path
379+
* @return this builder
380+
*/
381+
public Builder sseEndpoint(String sseEndpoint) {
382+
Assert.hasText(sseEndpoint, "sseEndpoint must not be empty");
383+
this.sseEndpoint = sseEndpoint;
384+
return this;
385+
}
386+
387+
/**
388+
* Sets the object mapper for JSON serialization/deserialization.
389+
* @param objectMapper the object mapper
390+
* @return this builder
391+
*/
392+
public Builder objectMapper(ObjectMapper objectMapper) {
393+
Assert.notNull(objectMapper, "objectMapper must not be null");
394+
this.objectMapper = objectMapper;
395+
return this;
396+
}
397+
398+
/**
399+
* Builds a new {@link WebFluxSseClientTransport} instance.
400+
* @return a new transport instance
401+
*/
402+
public WebFluxSseClientTransport build() {
403+
return new WebFluxSseClientTransport(webClientBuilder, objectMapper, sseEndpoint);
404+
}
405+
406+
}
407+
324408
}

0 commit comments

Comments
 (0)