sessions
Global sessions instance that automatically selects the appropriate backend based on environment configuration. It follows a Repository-inspired interface for managing MCP sessions.
Configuration
The storage backend is selected automatically:Storage Methods
generateSessionId(): string
Generate a unique session ID.
create(session: Session): Promise<void>
Create a new session. Throws if session already exists.
update(userId: string, sessionId: string, data: Partial<Session>): Promise<void>
Update an existing session with partial data. Throws if session doesnโt exist.
status: 'pending') receive a short OAuth-window expiration; active sessions (status: 'active') are retained until explicit deletion or dormant-session cleanup.
get(userId: string, sessionId: string): Promise<Session | null>
Retrieve session data.
list(userId: string): Promise<Session[]>
Get all session data for a user ID.
listIds(userId: string): Promise<string[]>
Get all session IDs for a user ID.
delete(userId: string, sessionId: string): Promise<void>
Delete a session.
listAllIds(): Promise<string[]>
Get all session IDs across all users (admin operation).
clearAll(): Promise<void>
Clear all sessions (admin operation).
cleanupExpired(): Promise<void>
Clean up expired pending sessions and dormant active sessions where the backend supports scheduled/manual cleanup.
disconnect(): Promise<void>
Disconnect from storage backend.

