|
1 | | -# Design Document: Implementing Streamable HTTP Transport for Example Remote Server |
| 1 | +# Design Document: Streamable HTTP Transport Implementation |
2 | 2 |
|
3 | | -## Research Summary |
| 3 | +## Current Implementation |
4 | 4 |
|
5 | | -### Current SSE Transport Architecture |
| 5 | +### Dual Transport Architecture |
6 | 6 |
|
7 | | -The example remote server currently uses the following architecture: |
| 7 | +The example remote server implements both transport methods: |
8 | 8 |
|
| 9 | +**Legacy SSE Transport:** |
9 | 10 | 1. **SSE Endpoint**: `/sse` - Creates SSE connection using `SSEServerTransport` |
10 | 11 | 2. **Message Endpoint**: `/message` - Receives POST requests and forwards them via Redis |
11 | | -3. **Redis Integration**: Messages are published/subscribed through Redis channels using session IDs |
12 | | -4. **Auth**: Uses `requireBearerAuth` middleware with `EverythingAuthProvider` |
13 | | -5. **Session Management**: Each SSE connection gets a unique session ID used as Redis channel key |
| 12 | + |
| 13 | +**Modern Streamable HTTP Transport:** |
| 14 | +1. **Unified Endpoint**: `/mcp` - Handles GET, POST, DELETE with `StreamableHTTPServerTransport` |
| 15 | +2. **Stateful Sessions**: Requires initialization and session ID tracking |
| 16 | +3. **SSE Response Format**: Returns results via Server-Sent Events streams |
| 17 | + |
| 18 | +**Shared Infrastructure:** |
| 19 | +1. **Redis Integration**: Messages published/subscribed through Redis channels using session IDs |
| 20 | +2. **Auth**: Uses `requireBearerAuth` middleware with mode-dependent auth providers |
| 21 | +3. **Session Management**: Session ownership tracked via Redis for multi-user isolation |
14 | 22 |
|
15 | 23 | **Key Files:** |
16 | | -- `/src/index.ts:91` - SSE endpoint with auth and headers |
17 | | -- `/src/handlers/mcp.ts:55-118` - SSE connection handler with Redis integration |
18 | | -- `/src/handlers/mcp.ts:120-144` - Message POST handler |
| 24 | +- `/src/index.ts:156-162` - SSE and Streamable HTTP endpoints with auth |
| 25 | +- `/src/handlers/sse.ts` - SSE connection handler with Redis integration |
| 26 | +- `/src/handlers/shttp.ts` - Streamable HTTP handler |
| 27 | +- `/src/services/mcp.ts` - MCP server implementation with tools, resources, prompts |
19 | 28 |
|
20 | 29 | ### Streamable HTTP Transport Specification (2025-03-26) |
21 | 30 |
|
|
0 commit comments