Class McpServer.Builder
java.lang.Object
com.soklet.McpServer.Builder
- Enclosing interface:
McpServer
Builder for
McpServer instances.- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the MCP server.concurrentConnectionLimit(@Nullable Integer concurrentConnectionLimit) Sets the concurrent connection limit for the MCP server.connectionQueueCapacity(@Nullable Integer connectionQueueCapacity) Sets the outbound queue capacity for live MCP streams.corsAuthorizer(@Nullable McpCorsAuthorizer corsAuthorizer) Sets the MCP CORS authorizer.handlerResolver(@Nullable McpHandlerResolver handlerResolver) Sets the handler resolver.heartbeatInterval(@Nullable Duration heartbeatInterval) Sets the heartbeat interval for long-lived MCP event streams.Sets the host to bind, ornullto use the server default.maximumHeaderCount(@Nullable Integer maximumHeaderCount) Sets the maximum number of HTTP header fields accepted in one MCP request.maximumRequestSizeInBytes(@Nullable Integer maximumRequestSizeInBytes) Sets the maximum accepted MCP request size in bytes.maximumRequestTargetLengthInBytes(@Nullable Integer maximumRequestTargetLengthInBytes) Sets the maximum MCP HTTP request-target length accepted in bytes.Sets the port to bind.requestAdmissionPolicy(@Nullable McpRequestAdmissionPolicy requestAdmissionPolicy) Sets the request admission policy.requestBodyTimeout(@Nullable Duration requestBodyTimeout) Sets the maximum duration for reading the MCP HTTP request body after the request line and headers have been received.requestHandlerConcurrency(@Nullable Integer requestHandlerConcurrency) Sets the handler concurrency level.requestHandlerExecutorServiceSupplier(@Nullable Supplier<ExecutorService> requestHandlerExecutorServiceSupplier) Sets the supplier used to create the handler executor service.requestHandlerQueueCapacity(@Nullable Integer requestHandlerQueueCapacity) Sets the handler queue capacity.requestHandlerTimeout(@Nullable Duration requestHandlerTimeout) Sets the timeout for MCP handler execution, including framework-managedMcpEndpoint.initialize(McpInitializationContext, McpSessionContext)calls.requestHeaderTimeout(@Nullable Duration requestHeaderTimeout) Sets the maximum duration for reading the MCP HTTP request line and headers.requestInterceptor(@Nullable McpRequestInterceptor requestInterceptor) Sets the request interceptor.requestReadBufferSizeInBytes(@Nullable Integer requestReadBufferSizeInBytes) Sets the read buffer size used while reading MCP requests.responseMarshaler(@Nullable McpResponseMarshaler responseMarshaler) Sets the response marshaler used for tool structured content.sessionIdGenerator(@Nullable IdGenerator<String> sessionIdGenerator) Sets the generator used for MCP session IDs.sessionStore(@Nullable McpSessionStore sessionStore) Sets the session store.shutdownTimeout(@Nullable Duration shutdownTimeout) Sets the shutdown timeout.writeTimeout(@Nullable Duration writeTimeout) Sets the transport write timeout.
-
Method Details
-
port
Sets the port to bind.- Parameters:
port- the port- Returns:
- this builder
-
host
Sets the host to bind, ornullto use the server default.- Parameters:
host- the host to bind- Returns:
- this builder
-
handlerResolver
Sets the handler resolver.- Parameters:
handlerResolver- the handler resolver- Returns:
- this builder
-
requestAdmissionPolicy
public @NonNull McpServer.Builder requestAdmissionPolicy(@Nullable McpRequestAdmissionPolicy requestAdmissionPolicy) Sets the request admission policy.- Parameters:
requestAdmissionPolicy- the admission policy- Returns:
- this builder
-
requestInterceptor
public @NonNull McpServer.Builder requestInterceptor(@Nullable McpRequestInterceptor requestInterceptor) Sets the request interceptor.- Parameters:
requestInterceptor- the request interceptor- Returns:
- this builder
-
responseMarshaler
public @NonNull McpServer.Builder responseMarshaler(@Nullable McpResponseMarshaler responseMarshaler) Sets the response marshaler used for tool structured content.- Parameters:
responseMarshaler- the response marshaler- Returns:
- this builder
-
corsAuthorizer
Sets the MCP CORS authorizer.- Parameters:
corsAuthorizer- the CORS authorizer- Returns:
- this builder
-
sessionStore
Sets the session store.- Parameters:
sessionStore- the session store- Returns:
- this builder
-
requestHeaderTimeout
Sets the maximum duration for reading the MCP HTTP request line and headers.If this value is not specified, Soklet uses the server default.
- Parameters:
requestHeaderTimeout- the request header timeout, ornullfor the default- Returns:
- this builder
-
requestBodyTimeout
Sets the maximum duration for reading the MCP HTTP request body after the request line and headers have been received.If this value is not specified, Soklet uses the server default.
- Parameters:
requestBodyTimeout- the request body timeout, ornullfor the default- Returns:
- this builder
-
requestHandlerTimeout
Sets the timeout for MCP handler execution, including framework-managedMcpEndpoint.initialize(McpInitializationContext, McpSessionContext)calls.- Parameters:
requestHandlerTimeout- the handler timeout- Returns:
- this builder
-
requestHandlerConcurrency
public @NonNull McpServer.Builder requestHandlerConcurrency(@Nullable Integer requestHandlerConcurrency) Sets the handler concurrency level.- Parameters:
requestHandlerConcurrency- the handler concurrency- Returns:
- this builder
-
requestHandlerQueueCapacity
public @NonNull McpServer.Builder requestHandlerQueueCapacity(@Nullable Integer requestHandlerQueueCapacity) Sets the handler queue capacity.- Parameters:
requestHandlerQueueCapacity- the handler queue capacity- Returns:
- this builder
-
requestHandlerExecutorServiceSupplier
public @NonNull McpServer.Builder requestHandlerExecutorServiceSupplier(@Nullable Supplier<ExecutorService> requestHandlerExecutorServiceSupplier) Sets the supplier used to create the handler executor service.- Parameters:
requestHandlerExecutorServiceSupplier- the executor service supplier- Returns:
- this builder
-
maximumRequestSizeInBytes
public @NonNull McpServer.Builder maximumRequestSizeInBytes(@Nullable Integer maximumRequestSizeInBytes) Sets the maximum accepted MCP request size in bytes.The MCP transport rejects a header section larger than this limit and rejects requests whose declared body size is larger than this limit.
- Parameters:
maximumRequestSizeInBytes- the maximum request size, ornullfor the default- Returns:
- this builder
-
maximumHeaderCount
Sets the maximum number of HTTP header fields accepted in one MCP request.- Parameters:
maximumHeaderCount- the maximum header count, ornullfor the default- Returns:
- this builder
-
maximumRequestTargetLengthInBytes
public @NonNull McpServer.Builder maximumRequestTargetLengthInBytes(@Nullable Integer maximumRequestTargetLengthInBytes) Sets the maximum MCP HTTP request-target length accepted in bytes.- Parameters:
maximumRequestTargetLengthInBytes- the maximum request-target length, ornullfor the default- Returns:
- this builder
-
requestReadBufferSizeInBytes
public @NonNull McpServer.Builder requestReadBufferSizeInBytes(@Nullable Integer requestReadBufferSizeInBytes) Sets the read buffer size used while reading MCP requests.- Parameters:
requestReadBufferSizeInBytes- the read buffer size- Returns:
- this builder
-
concurrentConnectionLimit
public @NonNull McpServer.Builder concurrentConnectionLimit(@Nullable Integer concurrentConnectionLimit) Sets the concurrent connection limit for the MCP server.- Parameters:
concurrentConnectionLimit- the concurrent connection limit- Returns:
- this builder
-
connectionQueueCapacity
public @NonNull McpServer.Builder connectionQueueCapacity(@Nullable Integer connectionQueueCapacity) Sets the outbound queue capacity for live MCP streams.- Parameters:
connectionQueueCapacity- the outbound queue capacity- Returns:
- this builder
-
shutdownTimeout
Sets the shutdown timeout.- Parameters:
shutdownTimeout- the shutdown timeout- Returns:
- this builder
-
writeTimeout
Sets the transport write timeout.- Parameters:
writeTimeout- the write timeout- Returns:
- this builder
-
heartbeatInterval
Sets the heartbeat interval for long-lived MCP event streams.- Parameters:
heartbeatInterval- the heartbeat interval- Returns:
- this builder
-
sessionIdGenerator
public @NonNull McpServer.Builder sessionIdGenerator(@Nullable IdGenerator<String> sessionIdGenerator) Sets the generator used for MCP session IDs.Custom generators must return globally unique, cryptographically strong, visible-ASCII IDs suitable for
MCP-Session-Idheader values.- Parameters:
sessionIdGenerator- the session ID generator- Returns:
- this builder
-
build
-