fastmcp.server.event_store
EventStore implementation backed by AsyncKeyValue.
This module provides an EventStore implementation that enables SSE polling/resumability
for Streamable HTTP transports. Events are stored using the key_value package’s
AsyncKeyValue protocol, allowing users to configure any compatible backend
(in-memory, Redis, etc.) following the same pattern as ResponseCachingMiddleware.
Classes
EventEntry
Stored event entry.
StreamEventList
List of event IDs for a stream.
EventStore
EventStore implementation backed by AsyncKeyValue.
Enables SSE polling/resumability by storing events that can be replayed
when clients reconnect. Works with any AsyncKeyValue backend (memory, Redis, etc.)
following the same pattern as ResponseCachingMiddleware and OAuthProxy.
Args:
storage: AsyncKeyValue backend. Defaults to MemoryStore.max_events_per_stream: Maximum events to retain per stream. Default 100.ttl: Event TTL in seconds. Default 3600 (1 hour). Set to None for no expiration.
store_event
stream_id: ID of the stream the event belongs tomessage: The JSON-RPC message to store, or None for priming events
- The generated event ID for the stored event
replay_events_after
last_event_id: The ID of the last event the client receivedsend_callback: A callback function to send events to the client
- The stream ID of the replayed events, or None if the event ID was not found

