duck.contrib.mcp.session¶
MCP session store.
Sessions are stored entirely in the configured InMemoryCache, which provides LRU eviction and TTL expiration automatically.
Module Contents¶
Classes¶
Represents a single MCP session. |
Data¶
API¶
- duck.contrib.mcp.session.DEFAULT_SESSION_REGISTRY¶
‘InMemoryCache(…)’
- class duck.contrib.mcp.session.SessionStore(cache: Optional[duck.utils.caching.InMemoryCache] = None, session_id: Optional[str] = None, ttl: int = 3600)[source]¶
Bases:
dictRepresents a single MCP session.
Session data is cached in-memory using the provided cache instance.
Initialization
Initialize a session.
- Parameters:
cache – Shared in-memory cache.
session_id – Existing session ID. A new one is generated if omitted.
ttl – Session lifetime in seconds.
- __slots__¶
(‘_session_id’, ‘_cache’, ‘_ttl’, ‘_loaded’, ‘_modified’)
- property loaded: bool¶
- property modified: bool¶
Whether the session data has changed since it was last loaded or saved.
- needs_update() bool[source]¶
Return whether the session has pending changes that haven’t been saved yet.
- property session_id: Optional[str]¶