event_store
Event storage interface for streamable-HTTP resumability.
EventStore and its supporting types are the contract a resumable
streamable-HTTP server plugs a store into (see mcp.server.streamable_http,
which re-exports every name here). They are defined in this transport-agnostic
module - no web framework imported - so servers and application code can name
and type against them without loading the HTTP stack.
EventMessage
dataclass
A JSONRPCMessage with an optional event ID for stream resumability.
Source code in src/mcp/server/event_store.py
23 24 25 26 27 28 | |
EventStore
Bases: ABC
Interface for resumability support via event storage.
Source code in src/mcp/server/event_store.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
store_event
abstractmethod
async
store_event(
stream_id: StreamId, message: JSONRPCMessage | None
) -> EventId
Stores an event for later retrieval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream_id
|
StreamId
|
ID of the stream the event belongs to |
required |
message
|
JSONRPCMessage | None
|
The JSON-RPC message to store, or None for priming events |
required |
Returns:
| Type | Description |
|---|---|
EventId
|
The generated event ID for the stored event. |
Source code in src/mcp/server/event_store.py
37 38 39 40 41 42 43 44 45 46 47 48 | |
replay_events_after
abstractmethod
async
replay_events_after(
last_event_id: EventId, send_callback: EventCallback
) -> StreamId | None
Replays events that occurred after the specified event ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
last_event_id
|
EventId
|
The ID of the last event the client received |
required |
send_callback
|
EventCallback
|
A callback function to send events to the client |
required |
Returns:
| Type | Description |
|---|---|
StreamId | None
|
The stream ID of the replayed events, or None if no events were found. |
Source code in src/mcp/server/event_store.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |