Class WebMvcStatelessServerTransport.Builder

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

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

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

  • Method Details

    • objectMapper

      public WebMvcStatelessServerTransport.Builder objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Sets the ObjectMapper to use for JSON serialization/deserialization of MCP messages.
      Parameters:
      objectMapper - The ObjectMapper instance. Must not be null.
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if objectMapper is null
    • messageEndpoint

      public WebMvcStatelessServerTransport.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
    • contextExtractor

      public WebMvcStatelessServerTransport.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
    • build

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