Class HttpServletStreamableServerTransportProvider.Builder
java.lang.Object
io.modelcontextprotocol.server.transport.HttpServletStreamableServerTransportProvider.Builder
- Enclosing class:
- HttpServletStreamableServerTransportProvider
Builder for creating instances of
HttpServletStreamableServerTransportProvider.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a new instance ofHttpServletStreamableServerTransportProviderwith the configured settings.contextExtractor(McpTransportContextExtractor<jakarta.servlet.http.HttpServletRequest> contextExtractor) Sets the context extractor for extracting transport context from the request.disallowDelete(boolean disallowDelete) Sets whether to disallow DELETE requests on the endpoint.keepAliveInterval(Duration keepAliveInterval) Sets the keep-alive interval for the transport.mcpEndpoint(String mcpEndpoint) Sets the endpoint URI where clients should send their JSON-RPC messages.objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Sets the ObjectMapper to use for JSON serialization/deserialization of MCP messages.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
objectMapper
public HttpServletStreamableServerTransportProvider.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
-
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
Sets whether to disallow DELETE requests on the endpoint.- Parameters:
disallowDelete- true to disallow DELETE requests, false otherwise- Returns:
- this builder instance
-
contextExtractor
public HttpServletStreamableServerTransportProvider.Builder contextExtractor(McpTransportContextExtractor<jakarta.servlet.http.HttpServletRequest> contextExtractor) Sets the context extractor for extracting transport context from the request.- Parameters:
contextExtractor- The context extractor to use. Must not be null.- Returns:
- this builder instance
- Throws:
IllegalArgumentException- if contextExtractor is null
-
keepAliveInterval
public HttpServletStreamableServerTransportProvider.Builder keepAliveInterval(Duration keepAliveInterval) Sets the keep-alive interval for the transport. If set, a keep-alive scheduler will be activated to periodically ping active sessions.- Parameters:
keepAliveInterval- The interval for keep-alive pings. If null, no keep-alive will be scheduled.- Returns:
- this builder instance
-
build
Builds a new instance ofHttpServletStreamableServerTransportProviderwith the configured settings.- Returns:
- A new HttpServletStreamableServerTransportProvider instance
- Throws:
IllegalStateException- if required parameters are not set
-