mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-22 00:04:21 +01:00
StreamableHttp -- resumability support for servers (#587)
This commit is contained in:
@@ -9,6 +9,7 @@ A simple MCP server example demonstrating the StreamableHttp transport, which en
|
||||
- Task management with anyio task groups
|
||||
- Ability to send multiple notifications over time to the client
|
||||
- Proper resource cleanup and lifespan management
|
||||
- Resumability support via InMemoryEventStore
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -32,6 +33,23 @@ The server exposes a tool named "start-notification-stream" that accepts three a
|
||||
- `count`: Number of notifications to send (e.g., 5)
|
||||
- `caller`: Identifier string for the caller
|
||||
|
||||
## Resumability Support
|
||||
|
||||
This server includes resumability support through the InMemoryEventStore. This enables clients to:
|
||||
|
||||
- Reconnect to the server after a disconnection
|
||||
- Resume event streaming from where they left off using the Last-Event-ID header
|
||||
|
||||
|
||||
The server will:
|
||||
- Generate unique event IDs for each SSE message
|
||||
- Store events in memory for later replay
|
||||
- Replay missed events when a client reconnects with a Last-Event-ID header
|
||||
|
||||
Note: The InMemoryEventStore is designed for demonstration purposes only. For production use, consider implementing a persistent storage solution.
|
||||
|
||||
|
||||
|
||||
## Client
|
||||
|
||||
You can connect to this server using an HTTP client, for now only Typescript SDK has streamable HTTP client examples or you can use (Inspector)[https://github.com/modelcontextprotocol/inspector]
|
||||
You can connect to this server using an HTTP client, for now only Typescript SDK has streamable HTTP client examples or you can use [Inspector](https://github.com/modelcontextprotocol/inspector)
|
||||
Reference in New Issue
Block a user