Class WebClientStreamableHttpTransport.Builder

java.lang.Object
io.modelcontextprotocol.client.transport.WebClientStreamableHttpTransport.Builder
Enclosing class:
WebClientStreamableHttpTransport

public static class WebClientStreamableHttpTransport.Builder extends Object
  • Method Details

    • jsonMapper

      public WebClientStreamableHttpTransport.Builder jsonMapper(io.modelcontextprotocol.json.McpJsonMapper jsonMapper)
      Configure the McpJsonMapper to 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 the WebClient.Builder to construct the WebClient.
      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

      public WebClientStreamableHttpTransport.Builder resumableStreams(boolean resumableStreams)
      Configure whether to use the stream resumability feature by keeping track of SSE event ids.
      Parameters:
      resumableStreams - if true event 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 is false.
      Parameters:
      openConnectionOnStartup - if true the WebClientStreamableHttpTransport.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 the MCP-Protocol-Version header.

      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-Version header.

      Parameters:
      supportedProtocolVersions - protocol versions supported by this transport
      Returns:
      this builder
      See Also:
    • build

      Construct a fresh instance of WebClientStreamableHttpTransport using the current builder configuration.
      Returns:
      a new instance of WebClientStreamableHttpTransport