public class WebRxSseClientTransport extends Object implements McpClientTransport
McpTransport that follows the MCP HTTP with SSE
transport specification.
This transport establishes a bidirectional communication channel where:
The message flow follows these steps:
HttpUtilsBuilder for HTTP communications and supports JSON. and base JDK8
serialization/deserialization of messages.| Modifier and Type | Class and Description |
|---|---|
static class |
WebRxSseClientTransport.Builder
Builder for
WebRxSseClientTransport. |
| Modifier and Type | Field and Description |
|---|---|
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper
JSON object mapper for message serialization/deserialization
|
| Constructor and Description |
|---|
WebRxSseClientTransport(org.noear.solon.net.http.HttpUtilsBuilder webBuilder)
Creates a new transport instance with default HTTP client and object mapper.
|
WebRxSseClientTransport(org.noear.solon.net.http.HttpUtilsBuilder webBuilder,
com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Creates a new transport instance with custom HTTP client builder and object mapper.
|
WebRxSseClientTransport(org.noear.solon.net.http.HttpUtilsBuilder webBuilder,
String sseEndpoint,
com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Creates a new transport instance with custom HTTP client builder and object mapper.
|
| Modifier and Type | Method and Description |
|---|---|
static WebRxSseClientTransport.Builder |
builder(org.noear.solon.net.http.HttpUtilsBuilder webBuilder)
Creates a new builder for
WebRxSseClientTransport. |
reactor.core.publisher.Mono<Void> |
closeGracefully()
Gracefully closes the transport connection.
|
reactor.core.publisher.Mono<Void> |
connect(Function<reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>,reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>> handler)
Establishes the SSE connection with the server and sets up message handling.
|
reactor.core.publisher.Mono<Void> |
sendMessage(McpSchema.JSONRPCMessage message)
Sends a JSON-RPC message to the server.
|
<T> T |
unmarshalFrom(Object data,
com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
Unmarshals data to the specified type using the configured object mapper.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcloseprotected com.fasterxml.jackson.databind.ObjectMapper objectMapper
public WebRxSseClientTransport(org.noear.solon.net.http.HttpUtilsBuilder webBuilder)
webBuilder - the HttpUtilsBuilder to use for creating the HttpUtils instancepublic WebRxSseClientTransport(org.noear.solon.net.http.HttpUtilsBuilder webBuilder,
com.fasterxml.jackson.databind.ObjectMapper objectMapper)
webBuilder - the HttpUtilsBuilder to use for creating the HttpUtils instanceobjectMapper - the object mapper for JSON serialization/deserializationIllegalArgumentException - if objectMapper or clientBuilder is nullpublic WebRxSseClientTransport(org.noear.solon.net.http.HttpUtilsBuilder webBuilder,
String sseEndpoint,
com.fasterxml.jackson.databind.ObjectMapper objectMapper)
webBuilder - the HttpUtilsBuilder to use for creating the HttpUtils instancesseEndpoint - the SSE endpoint pathobjectMapper - the object mapper for JSON serialization/deserializationIllegalArgumentException - if objectMapper or clientBuilder is nullpublic static WebRxSseClientTransport.Builder builder(org.noear.solon.net.http.HttpUtilsBuilder webBuilder)
WebRxSseClientTransport.webBuilder - the HttpUtilsBuilder to use for creating the HttpUtils instancepublic reactor.core.publisher.Mono<Void> connect(Function<reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>,reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>> handler)
This method:
connect in interface McpClientTransportconnect in interface McpTransporthandler - the function to process received JSON-RPC messagespublic reactor.core.publisher.Mono<Void> sendMessage(McpSchema.JSONRPCMessage message)
This method waits for the message endpoint to be discovered before sending the message. The message is serialized to JSON and sent as an HTTP POST request.
sendMessage in interface McpTransportmessage - the JSON-RPC message to sendMcpError - if the message endpoint is not available or the wait times outpublic reactor.core.publisher.Mono<Void> closeGracefully()
Sets the closing flag and cancels any pending connection future. This prevents new messages from being sent and allows ongoing operations to complete.
closeGracefully in interface McpTransportpublic <T> T unmarshalFrom(Object data, com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
unmarshalFrom in interface McpTransportT - the target typedata - the data to unmarshaltypeRef - the type reference for the target typeCopyright © 2025. All rights reserved.