Class HttpServletSseServerTransportProvider.Builder
java.lang.Object
io.modelcontextprotocol.server.transport.HttpServletSseServerTransportProvider.Builder
- Enclosing class:
- HttpServletSseServerTransportProvider
Builder for creating instances of HttpServletSseServerTransportProvider.
This builder provides a fluent API for configuring and creating instances of HttpServletSseServerTransportProvider with custom settings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the base URL for the server transport.build()Builds a new instance of HttpServletSseServerTransportProvider with the configured settings.contextExtractor(McpTransportContextExtractor<jakarta.servlet.http.HttpServletRequest> contextExtractor) Sets the context extractor for extracting transport context from the request.jsonMapper(McpJsonMapper jsonMapper) Sets the JsonMapper implementation to use for serialization/deserialization.keepAliveInterval(Duration keepAliveInterval) Sets the interval for keep-alive pings.messageEndpoint(String messageEndpoint) Sets the endpoint path where clients will send their messages.securityValidator(ServerTransportSecurityValidator securityValidator) Sets the security validator for validating HTTP requests.sseEndpoint(String sseEndpoint) Sets the endpoint path where clients will establish SSE connections.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
jsonMapper
Sets the JsonMapper implementation to use for serialization/deserialization. If not specified, a JacksonJsonMapper will be created from the configured ObjectMapper.- Parameters:
jsonMapper- The JsonMapper to use- Returns:
- This builder instance for method chaining
-
baseUrl
Sets the base URL for the server transport.- Parameters:
baseUrl- The base URL to use- Returns:
- This builder instance for method chaining
-
messageEndpoint
Sets the endpoint path where clients will send their messages.- Parameters:
messageEndpoint- The message endpoint path- Returns:
- This builder instance for method chaining
-
sseEndpoint
Sets the endpoint path where clients will establish SSE connections.If not specified, the default value of
HttpServletSseServerTransportProvider.DEFAULT_SSE_ENDPOINTwill be used.- Parameters:
sseEndpoint- The SSE endpoint path- Returns:
- This builder instance for method chaining
-
contextExtractor
public HttpServletSseServerTransportProvider.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
Sets the interval for keep-alive pings.If not specified, keep-alive pings will be disabled.
- Parameters:
keepAliveInterval- The interval duration for keep-alive pings- Returns:
- This builder instance for method chaining
-
securityValidator
public HttpServletSseServerTransportProvider.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 of HttpServletSseServerTransportProvider with the configured settings.- Returns:
- A new HttpServletSseServerTransportProvider instance
- Throws:
IllegalStateException- if jsonMapper or messageEndpoint is not set
-