Class WebMvcSseServerTransportProvider.Builder
java.lang.Object
io.modelcontextprotocol.server.transport.WebMvcSseServerTransportProvider.Builder
- Enclosing class:
- WebMvcSseServerTransportProvider
Builder for creating instances of WebMvcSseServerTransportProvider.
This builder provides a fluent API for configuring and creating instances of WebMvcSseServerTransportProvider with custom settings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the base URL for the server transport.build()Builds a new instance of WebMvcSseServerTransportProvider with the configured settings.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.jsonMapper(io.modelcontextprotocol.json.McpJsonMapper jsonMapper) Sets the JSON object mapper to use for message 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.sseEndpoint(String sseEndpoint) Sets the endpoint path where clients will establish SSE connections.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
jsonMapper
public WebMvcSseServerTransportProvider.Builder jsonMapper(io.modelcontextprotocol.json.McpJsonMapper jsonMapper) Sets the JSON object mapper to use for message serialization/deserialization.- Parameters:
jsonMapper- The object mapper 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
WebMvcSseServerTransportProvider.DEFAULT_SSE_ENDPOINTwill be used.- Parameters:
sseEndpoint- The SSE endpoint path- Returns:
- This builder instance for method chaining
-
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
-
contextExtractor
public WebMvcSseServerTransportProvider.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 aMcpTransportContext.- Returns:
- this builder instance
- Throws:
IllegalArgumentException- if contextExtractor is null
-
build
Builds a new instance of WebMvcSseServerTransportProvider with the configured settings.- Returns:
- A new WebMvcSseServerTransportProvider instance
- Throws:
IllegalStateException- if jsonMapper or messageEndpoint is not set
-