Skip to content

Commit 58dd1fd

Browse files
author
Lasim
committed
docs: update Gateway documentation to reflect support for Streamable HTTP transport and enhance session management details
1 parent ab5338f commit 58dd1fd

File tree

2 files changed

+77
-31
lines changed

2 files changed

+77
-31
lines changed

docs/development/gateway/index.mdx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ The DeployStack Gateway is the local secure proxy that connects developers to th
1414

1515
## Architecture Overview
1616

17-
The Gateway implements a sophisticated Control Plane / Data Plane architecture with dual transport support:
17+
The Gateway implements a sophisticated Control Plane / Data Plane architecture with comprehensive transport support:
1818

1919
- **Control Plane**: Authenticates with `cloud.deploystack.io` to download team configurations and access policies
20-
- **Data Plane**: Manages local MCP server processes with both stdio and SSE transport protocols
20+
- **Data Plane**: Manages local MCP server processes with stdio, SSE, and Streamable HTTP transport protocols
2121
- **Security Layer**: Injects credentials securely into process environments without exposing them to developers
2222
- **Session Management**: Handles secure SSE connections with cryptographic session IDs for VS Code compatibility
23+
- **Transport Layer**: Supports both legacy SSE transport and modern Streamable HTTP transport for maximum client compatibility
2324

2425
## Core Features
2526

2627
<Cards>
2728
<Card
2829
icon={<Terminal />}
29-
title="Dual Transport Support"
30+
title="Triple Transport Support"
3031
>
31-
Supports both stdio transport for CLI tools and SSE transport for VS Code compatibility
32+
Supports stdio transport for CLI tools, SSE transport for VS Code compatibility, and Streamable HTTP for modern MCP clients
3233
</Card>
3334

3435
<Card
@@ -118,9 +119,11 @@ Manages the lifecycle of MCP server processes, including:
118119
- Environment variable injection
119120

120121
### HTTP Proxy Server
121-
Exposes dual endpoints for different client types:
122-
- **GET /sse**: SSE connection establishment for VS Code
122+
Exposes multiple endpoints for different client types:
123+
- **GET /sse**: SSE connection establishment for VS Code and legacy clients
123124
- **POST /message**: Session-based JSON-RPC for SSE clients
125+
- **POST /mcp**: Streamable HTTP endpoint for modern MCP clients
126+
- **GET /health**: Health check endpoint for monitoring
124127

125128
### Session Manager
126129
Handles secure SSE connections with:
@@ -163,11 +166,16 @@ The Gateway works with MCP server configurations in this format:
163166
1. **Authentication**: Gateway authenticates with cloud control plane
164167
2. **Config Download**: Downloads team's MCP server configurations
165168
3. **Persistent Process Startup**: Starts all configured MCP servers as background processes when gateway launches
166-
4. **HTTP Server**: Starts local HTTP server with SSE endpoints immediately available (default: `localhost:9095/sse`)
167-
5. **Request Handling**: Receives MCP requests from development tools and routes to already-running processes
169+
4. **HTTP Server**: Starts local HTTP server with multiple endpoints immediately available:
170+
- SSE endpoint: `localhost:9095/sse` (for VS Code and legacy clients)
171+
- Messages endpoint: `localhost:9095/message` (for session-based JSON-RPC)
172+
- MCP endpoint: `localhost:9095/mcp` (for modern Streamable HTTP clients)
173+
- Health endpoint: `localhost:9095/health` (for monitoring)
174+
5. **Request Handling**: Receives MCP requests from development tools and intelligently routes to appropriate transport
168175
6. **Process Management**: Maintains persistent background processes as described in [Gateway Process Management](/development/gateway/process-management).
169176
7. **Credential Injection**: Securely injects environment variables into running processes at startup
170177
8. **Tool Routing**: Routes namespaced tool calls to persistent MCP servers via stdio transport
178+
9. **Transport Selection**: Automatically detects client capabilities and uses appropriate transport (SSE or Streamable HTTP)
171179

172180
For detailed information about the caching system, see [Gateway Caching System](/development/gateway/caching-system).
173181

@@ -207,10 +215,3 @@ The Gateway is actively under development. Key areas for contribution:
207215
- **Performance**: Optimizing stdio communication
208216
- **Platform Support**: Adding Windows/Linux compatibility
209217
- **Error Handling**: Robust error recovery
210-
211-
## Roadmap
212-
213-
- **Phase 2**: Enhanced process lifecycle management
214-
- **Phase 3**: Support for remote MCP servers (HTTP transport)
215-
- **Phase 4**: Advanced monitoring and analytics
216-
- **Future**: Plugin system for custom MCP server types

docs/development/gateway/session-management.mdx

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Session Management
3-
description: Cryptographically secure session lifecycle management for SSE connections
3+
description: Cryptographically secure session lifecycle management for SSE and Streamable HTTP connections
44
sidebar: Session Management
55
icon: Key
66
---
@@ -10,14 +10,16 @@ import { Key, Clock, Shield, Trash2 } from 'lucide-react';
1010

1111
# Session Management
1212

13-
The DeployStack Gateway implements a robust session management system that provides cryptographically secure session handling for persistent SSE connections while ensuring automatic cleanup and resource management.
13+
The DeployStack Gateway implements a robust session management system that provides cryptographically secure session handling for both persistent SSE connections and optional Streamable HTTP sessions while ensuring automatic cleanup and resource management.
1414

1515
## Architecture Overview
1616

17-
The session management system consists of two primary components working together to provide secure, persistent connections:
17+
The session management system consists of multiple components working together to provide secure connections across different transport protocols:
1818

1919
- **SessionManager**: Handles session lifecycle, validation, and SSE stream management
2020
- **SSEHandler**: Manages Server-Sent Events connections and message routing
21+
- **StreamableHTTPHandler**: Manages Streamable HTTP connections with optional session support
22+
- **Transport Layer**: Intelligent routing between SSE and Streamable HTTP based on client capabilities
2123

2224
## Core Components
2325

@@ -78,14 +80,16 @@ private validateSessionId(sessionId: string): boolean {
7880
## Session Lifecycle
7981

8082
### 1. Creation Phase
81-
**Trigger**: SSE connection establishment via `GET /sse`
83+
**Triggers**:
84+
- SSE connection establishment via `GET /sse`
85+
- Optional session creation for Streamable HTTP via `POST /mcp` with session headers
8286

8387
**Process:**
8488
1. Generate cryptographically secure session ID
8589
2. Create session object with metadata
86-
3. Associate with SSE stream
90+
3. Associate with SSE stream (for SSE transport) or track session state (for Streamable HTTP)
8791
4. Schedule automatic cleanup timer
88-
5. Send endpoint event to client
92+
5. Send endpoint event to client (SSE) or return session headers (Streamable HTTP)
8993

9094
**Session Object:**
9195
```typescript
@@ -219,6 +223,24 @@ getStatus() {
219223
- **Cleanup Events**: Cleanup reasons and timing logged
220224
- **Error Conditions**: Detailed error logging for troubleshooting
221225

226+
## Transport-Specific Session Handling
227+
228+
### SSE Transport Sessions
229+
SSE transport requires persistent sessions for connection management:
230+
231+
- **Mandatory Sessions**: All SSE connections must have associated sessions
232+
- **Stream Binding**: Sessions are bound to specific SSE streams
233+
- **Real-time Communication**: Messages sent via SSE events in real-time
234+
- **Connection Lifecycle**: Session lifecycle tied to SSE connection state
235+
236+
### Streamable HTTP Transport Sessions
237+
Streamable HTTP transport supports optional sessions for enhanced functionality:
238+
239+
- **Optional Sessions**: Sessions can be used but are not required
240+
- **Stateless Operation**: Supports both stateless and session-based operation
241+
- **Header-Based**: Session IDs passed via `Mcp-Session-Id` header
242+
- **Flexible Lifecycle**: Sessions can span multiple HTTP requests
243+
222244
## Integration Points
223245

224246
### SSE Handler Integration
@@ -235,21 +257,44 @@ this.sseHandler.sendMessage(sessionId, response);
235257
this.sseHandler.sendError(sessionId, errorResponse);
236258
```
237259

238-
### HTTP Proxy Integration
239-
Session validation in the HTTP proxy:
260+
### Streamable HTTP Handler Integration
261+
The session manager provides optional session support for Streamable HTTP:
240262

241263
```typescript
242-
// Session validation on each request
243-
const session = this.sessionManager.getSession(sessionId);
244-
if (!session) {
245-
// Handle invalid session
264+
// Optional session validation for Streamable HTTP
265+
const sessionId = request.headers['mcp-session-id'];
266+
if (sessionId) {
267+
const session = this.sessionManager.getSession(sessionId);
268+
if (session) {
269+
this.sessionManager.updateActivity(sessionId);
270+
}
246271
}
247272

248-
// Activity tracking
249-
this.sessionManager.updateActivity(sessionId);
273+
// Stateless operation when no session provided
274+
if (!sessionId) {
275+
// Handle request without session context
276+
}
277+
```
278+
279+
### HTTP Proxy Integration
280+
Session validation across both transports in the HTTP proxy:
250281

251-
// Error counting
252-
this.sessionManager.incrementErrorCount(sessionId);
282+
```typescript
283+
// Transport-aware session handling
284+
if (isSSETransport) {
285+
// SSE requires session validation
286+
const session = this.sessionManager.getSession(sessionId);
287+
if (!session) {
288+
throw new Error('Invalid session for SSE transport');
289+
}
290+
this.sessionManager.updateActivity(sessionId);
291+
} else if (isStreamableHTTP && sessionId) {
292+
// Streamable HTTP optional session support
293+
const session = this.sessionManager.getSession(sessionId);
294+
if (session) {
295+
this.sessionManager.updateActivity(sessionId);
296+
}
297+
}
253298
```
254299

255300
## Best Practices

0 commit comments

Comments
 (0)