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.idGenerator(@Nullable IdGenerator<String> idGenerator) Sets the generator used for MCP session IDs.maximumRequestSizeInBytes(@Nullable Integer maximumRequestSizeInBytes) Sets the maximum accepted MCP request size in bytes.Sets the port to bind.requestAdmissionPolicy(@Nullable McpRequestAdmissionPolicy requestAdmissionPolicy) Sets the request admission policy.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.requestInterceptor(@Nullable McpRequestInterceptor requestInterceptor) Sets the request interceptor.requestReadBufferSizeInBytes(@Nullable Integer requestReadBufferSizeInBytes) Sets the read buffer size used while reading MCP requests.requestTimeout(@Nullable Duration requestTimeout) Sets the end-to-end request timeout.responseMarshaler(@Nullable McpResponseMarshaler responseMarshaler) Sets the response marshaler used for tool structured content.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
-
requestTimeout
Sets the end-to-end request timeout.- Parameters:
requestTimeout- the request timeout- Returns:
- this builder
-
requestHandlerTimeout
Sets the timeout for MCP handler execution.- 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.- Parameters:
maximumRequestSizeInBytes- the maximum request size- 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
-
idGenerator
Sets the generator used for MCP session IDs.- Parameters:
idGenerator- the session ID generator- Returns:
- this builder
-
build
-