Class WebFluxSseServerTransportProvider.Builder

java.lang.Object
io.modelcontextprotocol.server.transport.WebFluxSseServerTransportProvider.Builder
Enclosing class:
WebFluxSseServerTransportProvider

public static class WebFluxSseServerTransportProvider.Builder extends Object
Builder for creating instances of WebFluxSseServerTransportProvider.

This builder provides a fluent API for configuring and creating instances of WebFluxSseServerTransportProvider with custom settings.

  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • jsonMapper

      public WebFluxSseServerTransportProvider.Builder jsonMapper(io.modelcontextprotocol.json.McpJsonMapper jsonMapper)
      Sets the McpJsonMapper to use for JSON serialization/deserialization of MCP messages.
      Parameters:
      jsonMapper - The McpJsonMapper instance. Must not be null.
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if jsonMapper is null
    • basePath

      Sets the project basePath as endpoint prefix where clients should send their JSON-RPC messages
      Parameters:
      baseUrl - the message basePath . Must not be null.
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if basePath is null
    • messageEndpoint

      public WebFluxSseServerTransportProvider.Builder messageEndpoint(String messageEndpoint)
      Sets the endpoint URI where clients should send their JSON-RPC messages.
      Parameters:
      messageEndpoint - The message endpoint URI. Must not be null.
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if messageEndpoint is null
    • sseEndpoint

      public WebFluxSseServerTransportProvider.Builder sseEndpoint(String sseEndpoint)
      Sets the SSE endpoint path.
      Parameters:
      sseEndpoint - The SSE endpoint path. Must not be null.
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if sseEndpoint is null
    • keepAliveInterval

      public WebFluxSseServerTransportProvider.Builder keepAliveInterval(Duration keepAliveInterval)
      Sets the interval for sending keep-alive pings to clients.
      Parameters:
      keepAliveInterval - The keep-alive interval duration. If null, keep-alive is disabled.
      Returns:
      this builder instance
    • contextExtractor

      public WebFluxSseServerTransportProvider.Builder contextExtractor(McpTransportContextExtractor<org.springframework.web.reactive.function.server.ServerRequest> contextExtractor)
      Sets the context extractor that allows providing the MCP feature implementations to inspect HTTP transport level metadata that was present at HTTP request processing time. This allows to extract custom headers and other useful data for use during execution later on in the process.
      Parameters:
      contextExtractor - The contextExtractor to fill in a McpTransportContext.
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if contextExtractor is null
    • build

      Builds a new instance of WebFluxSseServerTransportProvider with the configured settings.
      Returns:
      A new WebFluxSseServerTransportProvider instance
      Throws:
      IllegalStateException - if required parameters are not set