Class WebClientStreamableHttpTransport
java.lang.Object
io.modelcontextprotocol.client.transport.WebClientStreamableHttpTransport
- All Implemented Interfaces:
McpClientTransport,McpTransport
An implementation of the Streamable HTTP protocol as defined by the
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 HttpClientSseClientTransport or
WebFluxSseClientTransport.
- Author:
- Dariusz Jędrzejczyk
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder(org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder) Create a stateful builder for creatingWebClientStreamableHttpTransportinstances.reactor.core.publisher.Mono<Void>reactor.core.publisher.Mono<Void>connect(Function<reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>, reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>> handler) reactor.core.publisher.Mono<Void>sendMessage(McpSchema.JSONRPCMessage message) voidsetExceptionHandler(Consumer<Throwable> handler) <T> TunmarshalFrom(Object data, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.modelcontextprotocol.spec.McpTransport
close
-
Method Details
-
protocolVersion
- Specified by:
protocolVersionin interfaceMcpTransport
-
builder
public static WebClientStreamableHttpTransport.Builder builder(org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder) Create a stateful builder for creatingWebClientStreamableHttpTransportinstances.- Parameters:
webClientBuilder- theWebClient.Builderto use- Returns:
- a builder which will create an instance of
WebClientStreamableHttpTransportonceWebClientStreamableHttpTransport.Builder.build()is called
-
connect
public reactor.core.publisher.Mono<Void> connect(Function<reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>, reactor.core.publisher.Mono<McpSchema.JSONRPCMessage>> handler) - Specified by:
connectin interfaceMcpClientTransport
-
setExceptionHandler
- Specified by:
setExceptionHandlerin interfaceMcpClientTransport
-
closeGracefully
- Specified by:
closeGracefullyin interfaceMcpTransport
-
sendMessage
- Specified by:
sendMessagein interfaceMcpTransport
-
unmarshalFrom
- Specified by:
unmarshalFromin interfaceMcpTransport
-