Package io.modelcontextprotocol.spec
Class DefaultMcpStreamableServerSessionFactory
java.lang.Object
io.modelcontextprotocol.spec.DefaultMcpStreamableServerSessionFactory
- All Implemented Interfaces:
McpStreamableServerSession.Factory
public class DefaultMcpStreamableServerSessionFactory
extends Object
implements McpStreamableServerSession.Factory
A default implementation of
McpStreamableServerSession.Factory.- Author:
- Dariusz Jędrzejczyk
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultMcpStreamableServerSessionFactory(Duration requestTimeout, McpStreamableServerSession.InitRequestHandler initRequestHandler, Map<String, McpRequestHandler<?>> requestHandlers, Map<String, McpNotificationHandler> notificationHandlers) Deprecated.DefaultMcpStreamableServerSessionFactory(Duration requestTimeout, McpStreamableServerSession.InitRequestHandler initRequestHandler, Map<String, McpRequestHandler<?>> requestHandlers, Map<String, McpNotificationHandler> notificationHandlers, Function<String, reactor.core.publisher.Mono<Void>> onClose) Constructs an instance.DefaultMcpStreamableServerSessionFactory(Duration requestTimeout, McpStreamableServerSession.InitRequestHandler initRequestHandler, Map<String, McpRequestHandler<?>> requestHandlers, Map<String, McpNotificationHandler> notificationHandlers, Function<String, reactor.core.publisher.Mono<Void>> onClose, JsonSchemaValidator jsonSchemaValidator) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionstartSession(McpSchema.InitializeRequest initializeRequest) Given an initialize request, create a composite for the session initialization
-
Constructor Details
-
DefaultMcpStreamableServerSessionFactory
public DefaultMcpStreamableServerSessionFactory(Duration requestTimeout, McpStreamableServerSession.InitRequestHandler initRequestHandler, Map<String, McpRequestHandler<?>> requestHandlers, Map<String, McpNotificationHandler> notificationHandlers, Function<String, reactor.core.publisher.Mono<Void>> onClose, JsonSchemaValidator jsonSchemaValidator) Constructs an instance.- Parameters:
requestTimeout- timeout for requestsinitRequestHandler- initialization request handlerrequestHandlers- map of MCP request handlers keyed by method namenotificationHandlers- map of MCP notification handlers keyed by method nameonClose- reactive callback invoked with the session ID when a session is closedjsonSchemaValidator- optional validator threaded to sessions user-provided schema validation
-
DefaultMcpStreamableServerSessionFactory
public DefaultMcpStreamableServerSessionFactory(Duration requestTimeout, McpStreamableServerSession.InitRequestHandler initRequestHandler, Map<String, McpRequestHandler<?>> requestHandlers, Map<String, McpNotificationHandler> notificationHandlers, Function<String, reactor.core.publisher.Mono<Void>> onClose) Constructs an instance.- Parameters:
requestTimeout- timeout for requestsinitRequestHandler- initialization request handlerrequestHandlers- map of MCP request handlers keyed by method namenotificationHandlers- map of MCP notification handlers keyed by method nameonClose- reactive callback invoked with the session ID when a session is closed
-
DefaultMcpStreamableServerSessionFactory
@Deprecated public DefaultMcpStreamableServerSessionFactory(Duration requestTimeout, McpStreamableServerSession.InitRequestHandler initRequestHandler, Map<String, McpRequestHandler<?>> requestHandlers, Map<String, McpNotificationHandler> notificationHandlers) Deprecated.Constructs an instance.- Parameters:
requestTimeout- timeout for requestsinitRequestHandler- initialization request handlerrequestHandlers- map of MCP request handlers keyed by method namenotificationHandlers- map of MCP notification handlers keyed by method name
-
-
Method Details
-
startSession
public McpStreamableServerSession.McpStreamableServerSessionInit startSession(McpSchema.InitializeRequest initializeRequest) Description copied from interface:McpStreamableServerSession.FactoryGiven an initialize request, create a composite for the session initialization- Specified by:
startSessionin interfaceMcpStreamableServerSession.Factory- Parameters:
initializeRequest- the initialization request from the client- Returns:
- a composite allowing the session to start
-
DefaultMcpStreamableServerSessionFactory(Duration, McpStreamableServerSession.InitRequestHandler, Map, Map, Function)instead