Class HttpServletStatelessServerTransport.Builder
java.lang.Object
io.modelcontextprotocol.server.transport.HttpServletStatelessServerTransport.Builder
- Enclosing class:
- HttpServletStatelessServerTransport
Builder for creating instances of
HttpServletStatelessServerTransport.
This builder provides a fluent API for configuring and creating instances of HttpServletStatelessServerTransport with custom settings.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a new instance ofHttpServletStatelessServerTransportwith the configured settings.contextExtractor(McpTransportContextExtractor<jakarta.servlet.http.HttpServletRequest> 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.jsonMapper(McpJsonMapper jsonMapper) Sets the JsonMapper to use for JSON serialization/deserialization of MCP messages.messageEndpoint(String messageEndpoint) Sets the endpoint URI where clients should send their JSON-RPC messages.securityValidator(ServerTransportSecurityValidator securityValidator) Sets the security validator for validating HTTP requests.
-
Method Details
-
jsonMapper
Sets the JsonMapper to use for JSON serialization/deserialization of MCP messages.- Parameters:
jsonMapper- The JsonMapper instance. Must not be null.- Returns:
- this builder instance
- Throws:
IllegalArgumentException- if jsonMapper is null
-
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 HttpServletStatelessServerTransport.Builder contextExtractor(McpTransportContextExtractor<jakarta.servlet.http.HttpServletRequest> 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 aMcpTransportContext.- Returns:
- this builder instance
- Throws:
IllegalArgumentException- if contextExtractor is null
-
securityValidator
public HttpServletStatelessServerTransport.Builder securityValidator(ServerTransportSecurityValidator securityValidator) Sets the security validator for validating HTTP requests.- Parameters:
securityValidator- The security validator to use. Must not be null.- Returns:
- this builder instance
- Throws:
IllegalArgumentException- if securityValidator is null
-
build
Builds a new instance ofHttpServletStatelessServerTransportwith the configured settings.- Returns:
- A new HttpServletStatelessServerTransport instance
- Throws:
IllegalStateException- if required parameters are not set
-