Number of active sessions
Current statistics
Broadcasts prompt list changed notification to all active sessions
Broadcasts resource list changed notification to all active sessions
Sends a resource updated notification to sessions subscribed to the given URI.
Unlike list-changed broadcasts (sent to all sessions), this only notifies
sessions that have subscribed to the specific resource URI via
resources/subscribe.
Broadcasts tool list changed notification to all active sessions.
Creates and registers a new session.
Capacity check and insertion are synchronous (no await between them), which is safe in Node.js single-threaded event loop. Do NOT introduce any async operations between hasCapacity() and sessions.set().
Session creation options
The created session, or undefined if at max capacity or shutting down
Finds sessions matching a predicate.
Iterates over all active sessions.
Gets an active session by ID. Does NOT update activity time (use touch() for that).
Gets all sessions of a specific transport type.
Checks if a session exists and is active.
Checks if there's capacity for new sessions.
Marks the store as shutting down (rejects new sessions).
Removes a session from the store and updates statistics.
Pure data operation — does NOT close transport or dispose MCP session. The caller (SessionManager) is responsible for I/O teardown.
Session identifier
Reason for closure (tracked in stats)
The removed session, or undefined if not found
Removes all sessions from the store during shutdown. Returns the removed sessions for the caller to handle I/O teardown.
Updates the last activity time for a session. Also resets missed heartbeat count.
Built-in in-memory session store using a
Map.Suitable for single-instance deployments. For horizontal scaling, implement the SessionStore interface with a shared backend.
Responsibilities:
Does NOT manage timers or background tasks.
Example