public class WebRxStreamableHttpTransport extends java.lang.Object implements McpClientTransport
2025-03-26 version of the MCP specification.
The transport is capable of resumability and reconnects. It reacts to transport-level
session invalidation and will propagate appropriate exceptions to the higher level abstraction layer when needed in order to
allow proper state management. The implementation handles servers that are stateful and
provide session meta information, but can also communicate with stateless servers that
do not provide a session identifier and do not support SSE streams.
This implementation does not handle backwards compatibility with the "HTTP
with SSE" transport. In order to communicate over the phased-out
2024-11-05 protocol, use WebRxSseClientTransport or
WebRxSseClientTransport.
| 限定符和类型 | 类和说明 |
|---|---|
static class |
WebRxStreamableHttpTransport.Builder
Builder for
WebRxStreamableHttpTransport. |
| 限定符和类型 | 方法和说明 |
|---|---|
static WebRxStreamableHttpTransport.Builder |
builder(org.noear.solon.net.http.HttpUtilsBuilder webClientBuilder)
Create a stateful builder for creating
WebRxStreamableHttpTransport
instances. |
reactor.core.publisher.Mono<java.lang.Void> |
closeGracefully()
Closes the transport connection and releases any associated resources
asynchronously.
|
reactor.core.publisher.Mono<java.lang.Void> |
connect(java.util.function.Function<reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>,reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>> handler)
Used to register the incoming messages' handler and potentially (eagerly) connect
to the server.
|
java.util.List<java.lang.String> |
protocolVersions() |
reactor.core.publisher.Mono<java.lang.Void> |
sendMessage(McpSchema.JSONRPCMessage message)
Sends a message to the peer asynchronously.
|
void |
setExceptionHandler(java.util.function.Consumer<java.lang.Throwable> handler)
Sets the exception handler for exceptions raised on the transport layer.
|
<T> T |
unmarshalFrom(java.lang.Object data,
TypeRef<T> typeRef)
Unmarshals the given data into an object of the specified type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclosepublic java.util.List<java.lang.String> protocolVersions()
protocolVersions 在接口中 McpTransportpublic static WebRxStreamableHttpTransport.Builder builder(org.noear.solon.net.http.HttpUtilsBuilder webClientBuilder)
WebRxStreamableHttpTransport
instances.webClientBuilder - the HttpUtilsBuilder to useWebRxStreamableHttpTransport once WebRxStreamableHttpTransport.Builder.build() is calledpublic reactor.core.publisher.Mono<java.lang.Void> connect(java.util.function.Function<reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>,reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>> handler)
McpClientTransportconnect 在接口中 McpClientTransporthandler - a transformer for incoming messagesMono that terminates upon successful client setup. It can mean
establishing a connection (which can be later disposed) but it doesn't have to,
depending on the transport type. The successful termination of the returned
Mono simply means the client can now be used. An error can be retried
according to the application requirements.public void setExceptionHandler(java.util.function.Consumer<java.lang.Throwable> handler)
McpClientTransportsetExceptionHandler 在接口中 McpClientTransporthandler - Allows reacting to transport level exceptions by the higher layerspublic reactor.core.publisher.Mono<java.lang.Void> closeGracefully()
McpTransportcloseGracefully 在接口中 McpTransportMono that completes when the connection has been closed.public reactor.core.publisher.Mono<java.lang.Void> sendMessage(McpSchema.JSONRPCMessage message)
McpTransportThis method handles the transmission of messages to the server in an asynchronous manner. Messages are sent in JSON-RPC format as specified by the MCP protocol.
sendMessage 在接口中 McpTransportmessage - the McpSchema.JSONRPCMessage to be sent to the serverMono that completes when the message has been sentpublic <T> T unmarshalFrom(java.lang.Object data,
TypeRef<T> typeRef)
McpTransportunmarshalFrom 在接口中 McpTransportT - the type of the object to unmarshaldata - the data to unmarshaltypeRef - the type reference for the object to unmarshal