Class WebClientStreamableHttpTransport.Builder
java.lang.Object
io.modelcontextprotocol.client.transport.WebClientStreamableHttpTransport.Builder
- Enclosing class:
- WebClientStreamableHttpTransport
Builder for
WebClientStreamableHttpTransport.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Construct a fresh instance ofWebClientStreamableHttpTransportusing the current builder configuration.Configure the endpoint to make HTTP requests against.jsonMapper(io.modelcontextprotocol.json.McpJsonMapper jsonMapper) Configure theMcpJsonMapperto use.openConnectionOnStartup(boolean openConnectionOnStartup) Configure whether the client should open an SSE connection upon startup.resumableStreams(boolean resumableStreams) Configure whether to use the stream resumability feature by keeping track of SSE event ids.supportedProtocolVersions(List<String> supportedProtocolVersions) Sets the list of supported protocol versions used in version negotiation.webClientBuilder(org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder) Configure theWebClient.Builderto construct theWebClient.
-
Method Details
-
jsonMapper
public WebClientStreamableHttpTransport.Builder jsonMapper(io.modelcontextprotocol.json.McpJsonMapper jsonMapper) Configure theMcpJsonMapperto use.- Parameters:
jsonMapper- instance to use- Returns:
- the builder instance
-
webClientBuilder
public WebClientStreamableHttpTransport.Builder webClientBuilder(org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder) Configure theWebClient.Builderto construct theWebClient.- Parameters:
webClientBuilder- instance to use- Returns:
- the builder instance
-
endpoint
Configure the endpoint to make HTTP requests against.- Parameters:
endpoint- endpoint to use- Returns:
- the builder instance
-
resumableStreams
Configure whether to use the stream resumability feature by keeping track of SSE event ids.- Parameters:
resumableStreams- iftrueevent ids will be tracked and upon disconnection, the last seen id will be used upon reconnection as a header to resume consuming messages.- Returns:
- the builder instance
-
openConnectionOnStartup
public WebClientStreamableHttpTransport.Builder openConnectionOnStartup(boolean openConnectionOnStartup) Configure whether the client should open an SSE connection upon startup. Not all servers support this (although it is in theory possible with the current specification), so use with caution. By default, this value isfalse.- Parameters:
openConnectionOnStartup- iftruetheWebClientStreamableHttpTransport.connect(Function)method call will try to open an SSE connection before sending any JSON-RPC request- Returns:
- the builder instance
-
supportedProtocolVersions
public WebClientStreamableHttpTransport.Builder supportedProtocolVersions(List<String> supportedProtocolVersions) Sets the list of supported protocol versions used in version negotiation. By default, the client will send the latest of those versions in theMCP-Protocol-Versionheader.Setting this value only updates the values used in version negotiation, and does NOT impact the actual capabilities of the transport. It should only be used for compatibility with servers having strict requirements around the
MCP-Protocol-Versionheader.- Parameters:
supportedProtocolVersions- protocol versions supported by this transport- Returns:
- this builder
- See Also:
-
build
Construct a fresh instance ofWebClientStreamableHttpTransportusing the current builder configuration.- Returns:
- a new instance of
WebClientStreamableHttpTransport
-