Interface McpSessionStore
Compare-and-set persistence contract for MCP sessions.
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classBuilder for Soklet's default in-memory MCP session store. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull McpSessionStore.Builderbuilder()Acquires a builder for Soklet's default in-memory MCP session store.Creates and admits a new session for the given request and endpoint class.voiddeleteBySessionId(@NonNull String sessionId) Deletes a session by ID.findBySessionId(@NonNull String sessionId) Loads a session by ID.static @NonNull McpSessionStoreAcquires Soklet's default in-memory MCP session store.static @NonNull McpSessionStoreAcquires the default in-memory session store using Soklet's default idle timeout.replace(@NonNull McpStoredSession expected, @NonNull McpStoredSession updated) Replaces a session using compare-and-set semantics.
-
Method Details
-
create
@NonNull Optional<McpStoredSession> create(@NonNull Request request, @NonNull Class<? extends McpEndpoint> endpointClass) Creates and admits a new session for the given request and endpoint class.Implementations are responsible for generating a valid MCP session ID and enforcing their own concurrency limits atomically with persistence. Returning
Optional.empty()declines admission before session state is created (for example, when a concurrent-session limit is reached).Returned sessions must be new, uninitialized, unterminated sessions for
endpointClass. Soklet will complete initialization withreplace(McpStoredSession, McpStoredSession)after the endpoint'sMcpEndpoint.initialize(McpInitializationContext, McpSessionContext)callback succeeds.- Parameters:
request- the initialize requestendpointClass- the MCP endpoint class that will own the session- Returns:
- the newly-created stored session, or empty if the store declined admission
-
findBySessionId
Loads a session by ID.- Parameters:
sessionId- the session ID- Returns:
- the stored session, if it exists and has not expired
-
replace
Replaces a session using compare-and-set semantics.- Parameters:
expected- the currently-stored session snapshotupdated- the replacement session snapshot- Returns:
trueif the replacement succeeded
-
deleteBySessionId
Deletes a session by ID.- Parameters:
sessionId- the session ID to delete
-
builder
Acquires a builder for Soklet's default in-memory MCP session store.- Returns:
- a new MCP session store builder
-
fromDefaults
Acquires Soklet's default in-memory MCP session store.- Returns:
- a new in-memory session store
-
fromInMemory
Acquires the default in-memory session store using Soklet's default idle timeout.Expired sessions are reclaimed opportunistically during lookup and subsequent session-creation activity; exact deletion timing is therefore best-effort rather than timer-driven.
- Returns:
- a new in-memory session store
-