Class WebMvcStreamableServerTransportProvider.Builder

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

public static class WebMvcStreamableServerTransportProvider.Builder extends Object
Builder for creating instances of WebMvcStreamableServerTransportProvider.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • jsonMapper

      public WebMvcStreamableServerTransportProvider.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
    • mcpEndpoint

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

      public WebMvcStreamableServerTransportProvider.Builder disallowDelete(boolean disallowDelete)
      Sets whether to disallow DELETE requests on the endpoint.
      Parameters:
      disallowDelete - true to disallow DELETE requests, false otherwise
      Returns:
      this builder instance
    • contextExtractor

      public WebMvcStreamableServerTransportProvider.Builder contextExtractor(McpTransportContextExtractor<org.springframework.web.servlet.function.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
    • keepAliveInterval

      public WebMvcStreamableServerTransportProvider.Builder keepAliveInterval(Duration keepAliveInterval)
      Sets the keep-alive interval for the transport. If set, a keep-alive scheduler will be created to periodically check and send keep-alive messages to clients.
      Parameters:
      keepAliveInterval - The interval duration for keep-alive messages, or null to disable keep-alive
      Returns:
      this builder instance
    • build

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