Expand description
Streamable HTTP session management for MCP transport
This module implements a lightweight session management system for MCP streamable HTTP with SSE support.
Structs§
- Session
- Per-session state
- Session
Handle - A handle to a session’s message stream
Functions§
- broadcast_
to_ all - Send the given JSON-RPC message to every active session.
- disconnect_
all - Disconnect all sessions
- expire_
old - Expire any sessions older than
max_age
, dropping them from the map. - get_
receiver - Get a session’s receiver for SSE streaming
- get_
sender - Fetch and “touch” the sender for this session, extending its lifetime.
Returns
None
if the session does not exist or has already expired. - new_
session - Create a brand new session.
Returns the
session_id
and aReceiver<String>
you can use to drive an SSE stream. - remove_
session - Explicitly remove/terminate a session. You can call this on client disconnect or after HTTP GET SSE finishes.
- send_
to_ session - Send the given JSON-RPC message to a specific session
- session_
count - Get count of active sessions
- session_
exists - Check if a session exists and touch it
- spawn_
session_ cleanup - Spawn session cleanup task for automatic session management