Skip to content

Commit e28f593

Browse files
authored
Merge pull request #223 from deploystackio/feat/Streamable-http
Feat/streamable http
2 parents ab5338f + 5e0c563 commit e28f593

File tree

5 files changed

+109
-94
lines changed

5 files changed

+109
-94
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/process-management.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,31 @@ The Gateway's process management system operates on a **persistent background pr
6262
</Card>
6363
</Cards>
6464

65+
## Selective Restart Capability
66+
67+
The Gateway supports **selective restart** functionality, allowing individual MCP servers to be managed without requiring a full gateway restart. This feature dramatically improves configuration update performance and eliminates downtime for unchanged servers.
68+
69+
### Key Features
70+
71+
- **Individual Server Control**: Add, remove, or restart specific MCP servers via HTTP API
72+
- **Change Detection**: Automatically detects added, removed, and modified server configurations
73+
- **Fallback Safety**: Falls back to full restart if selective operations fail
74+
- **Zero Downtime**: Unchanged servers continue running during configuration updates
75+
76+
### API Endpoints
77+
78+
The Gateway exposes HTTP endpoints for selective server management:
79+
80+
- `POST /api/mcp/servers` - Add new MCP servers to running gateway
81+
- `DELETE /api/mcp/servers/:serverName` - Remove specific servers
82+
- `POST /api/mcp/servers/:serverName/restart` - Restart individual servers
83+
84+
### Implementation Services
85+
86+
- **Selective Restart Service**: Handles HTTP communication with running gateway processes
87+
- **Configuration Change Service**: Detects configuration differences and orchestrates selective operations
88+
- **Process Manager Integration**: Provides individual server lifecycle control capabilities
89+
6590
## Process Lifecycle
6691

6792
### Gateway Startup Phase

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

docs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ DeployStack is the **Enterprise Control Plane for the Model Context Protocol (MC
3333

3434
<Card
3535
icon={<Server />}
36-
href="/self-hosted"
36+
href="/self-hosted/quick-start"
3737
title="Self-Hosted DeployStack"
3838
>
3939
Host DeployStack on your own infrastructure for complete control and security

docs/self-hosted/docker-compose.mdx

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,11 @@ This guide provides step-by-step instructions to install and configure DeploySta
2626

2727
- **RAM**: Ensure your environment has at least 4GB of RAM. Insufficient memory can cause processes to crash.
2828
- **Docker & Docker Compose**: Make sure both are installed and up-to-date.
29-
- **Storage**: At least 20GB of available disk space for images and persistent data.
30-
- **Network**: Stable internet connection for pulling Docker images.
29+
- **Storage**: At least 2GB of available disk space for images and persistent data.
3130

32-
## Option 1: One-line Setup
31+
## Beggining the setup for Docker Compose
3332

34-
Deploy DeployStack with a single command:
35-
36-
```bash
37-
curl -sSL https://raw.githubusercontent.com/deploystackio/deploystack/main/scripts/install.sh | bash
38-
```
39-
40-
This script will:
41-
1. Download the docker-compose.yml file
42-
2. Generate a secure encryption secret
43-
3. Start all services
44-
4. Display access information
45-
46-
## Option 2: Manual Setup
47-
48-
Follow these steps for a manual setup with full control.
33+
Follow these steps for a setup with docker compsoe
4934

5035
### Step 1: Download Docker Compose File
5136

@@ -258,54 +243,13 @@ docker-compose logs backend
258243
docker-compose logs frontend
259244
```
260245

261-
#### Port Conflicts
262-
263-
If ports 3000 or 8080 are already in use:
264-
265-
```bash
266-
# Update .env file
267-
FRONTEND_PORT=8081
268-
BACKEND_PORT=3001
269-
270-
# Restart services
271-
docker-compose down
272-
docker-compose up -d
273-
```
274-
275-
#### Permission Issues
276-
277-
```bash
278-
# Fix volume permissions
279-
sudo chown -R $USER:$USER $(docker volume inspect deploystack_backend_persistent --format '{{ .Mountpoint }}')
280-
```
281-
282-
#### Memory Issues
283-
284-
```bash
285-
# Check available memory
286-
free -h
287-
288-
# Monitor container resource usage
289-
docker stats
290-
```
291-
292246
### Getting Help
293247

294248
If you encounter issues not covered here:
295249

296-
1. Check the [Troubleshooting](/troubleshooting) guide
297-
2. Search existing [GitHub Issues](https://github.com/deploystackio/deploystack/issues)
298-
3. Join our [Discord community](https://discord.gg/UjFWwByB)
299-
4. Create a new issue with detailed logs and system information
300-
301-
## Next Steps
302-
303-
Once DeployStack is running:
304-
305-
1. **Create your first workspace** through the web interface
306-
2. **Configure global settings** for email and authentication
307-
3. **Set up user roles** and team permissions
308-
4. **Deploy your first MCP server** from the catalog
250+
1. Search existing [GitHub Issues](https://github.com/deploystackio/deploystack/issues)
251+
2. Join our [Discord community](https://discord.gg/42Ce3S7b3b)
252+
3. Create a new issue with detailed logs and system information
309253

310254
---
311255

0 commit comments

Comments
 (0)