DeployStack Satellite provides a second MCP access method alongside the hierarchical router: path-based instance routing. This enables standard MCP clients to connect directly to individual instances using simple token authentication, without OAuth2 setup or meta-tool discovery.Documentation Index
Fetch the complete documentation index at: https://docs.deploystack.io/llms.txt
Use this file to discover all available pages before exploring further.
Use Case: Standard MCP clients that need direct access to a specific instance’s tools without the complexity of OAuth2 or the two-step discovery pattern of the hierarchical router.
The Problem It Solves
OAuth2 Complexity for Direct Integration
Standard MCP clients (libraries, scripts, custom applications) face challenges with OAuth2: Traditional OAuth2 Requirements:- Browser-based authorization flow
- Token refresh management
- Client ID/secret configuration
- Redirect URL handling
- State management
The Instance Router Solution
Path-based routing with token authentication provides direct access:- No OAuth2 flow required
- Single token in URL
- Works in scripts, CLIs, automation
- Standard MCP client compatibility
- No browser required
Architecture Overview
Two Parallel Routers
The satellite operates two independent MCP routers simultaneously:Key Design Principles
Shared Execution, Separate Sessions:- Both routers share the same
McpToolExecutorfor consistent tool execution - OAuth token injection, retry logic, and recovery are shared
- Each router maintains its own session manager to prevent collision
- Independent authentication mechanisms (OAuth2 vs token)
- Hierarchical Router: Multi-instance access for AI agents
- Instance Router: Single-instance access for direct clients
Route Endpoints
The instance router exposes three standard MCP endpoints:POST /i/:instancePath/mcp
Purpose: Client-to-server MCP messages (initialize, tools/list, tools/call) URL Format::instancePath- URL path parameter (e.g.,bold-penguin-42a3)token- Query parameter (e.g.,ds_inst_abc123...)
Content-Type: application/jsonmcp-session-id: <session-id>(optional, for session reuse)
- Initialize:
{"method": "initialize", ...} - List tools:
{"method": "tools/list", ...} - Call tool:
{"method": "tools/call", "params": {"name": "create_issue", "arguments": {...}}}
GET /i/:instancePath/mcp
Purpose: Server-to-client notifications via Server-Sent Events (SSE) URL Format:mcp-session-id: <session-id>(required)
DELETE /i/:instancePath/mcp
Purpose: Session termination URL Format:mcp-session-id: <session-id>(required)
Authentication Flow
Token Format
Instance tokens follow a specific format for easy identification:ds_inst_- Prefix for token type identification (12 characters)<64 hex>- Cryptographically random token (64 characters)- Total Length: 71 characters
SHA-256 Hash Validation
Tokens are validated using SHA-256 hash comparison: Storage:- Backend generates token during instance creation
- SHA-256 hash stored in database (
instance_token_hashcolumn) - Plain token shown to user ONCE (copy before closing)
- Hash included in satellite configuration
Authentication Error Responses
404 Not Found:Session Management
Session Lifecycle
The instance router supports three session modes:1. Create New Session (Initialize)
Trigger: Client sendsinitialize request without existing session
Process:
- Validate token
- Check if stdio process is active (respawn if dormant)
- Create new MCP session
- Generate unique session ID
- Set up MCP server with instance tools
- Return session ID in response
- Session ID in response
- Should include in subsequent requests as
mcp-session-idheader
2. Reuse Existing Session
Trigger: Client sends request with validmcp-session-id header
Process:
- Validate token
- Look up session by ID
- Verify session exists and is active
- Process request using existing session
- No session recreation overhead
- Maintains state between requests
- Faster request processing
3. Resurrect Stale Session
Trigger: Client sends request withmcp-session-id for non-existent session
Process:
- Validate token
- Session not found in memory (possibly satellite restarted)
- Respawn stdio process if needed
- Create new session with same ID
- Send synthetic
initializerequest to MCP server - Process client’s original request
- Handles satellite restarts gracefully
- Client doesn’t need to reinitialize manually
- Maintains user experience
Session Storage
Sessions are stored in a separateMcpSessionManager instance:
- Sessions isolated from hierarchical router
- No collision risk between routers
- Independent cleanup lifecycle
- Session ID format: UUID v4
Process Respawning (stdio Only)
For stdio-based MCP servers, the instance router ensures processes are active: When Respawning Happens:- Initialize request AND process is dormant/crashed
- Stale session resurrection AND stdio transport
- Respawn failures log warning and continue
- Client request proceeds anyway
- Tool execution will fail if process actually down
- Recovery system handles permanent failures
Tool Discovery & Execution
Tool List Response
Unlike the hierarchical router’s 2 meta-tools, the instance router returns ALL actual tools from the specific instance: Hierarchical Router (2 meta-tools):- Tool names are original/non-namespaced (
create_issuenotgithub:create_issue) - Full tool definitions included (name, description, inputSchema)
- Filtered to specific instance only (other instances’ tools hidden)
- No search required (direct list)
Tool Name Conversion
Internally, the instance router converts tool names for execution: Client Perspective (External Format):McpToolExecutorexpects namespaced format for routing- Maintains consistency with hierarchical router’s internal format
- Enables process-specific targeting
- Transparent to client (automatic conversion)
Shared Tool Executor
Both routers use the sameMcpToolExecutor instance:
Shared Functionality:
- stdio tool execution (JSON-RPC to subprocess)
- HTTP/SSE tool execution (HTTP requests to remote servers)
- OAuth token injection (for servers requiring authentication)
- Retry logic and error recovery
- Request logging and batching
- Status tracking integration
- No code duplication
- Consistent behavior across routers
- Single source of truth for execution logic
- Shared request log buffer (unified analytics)
Complete Request Flow
Step 1: Initialize Session
Request:- Token validated (SHA-256 hash comparison)
- Instance found by path:
bold-penguin-42a3 - stdio process respawned if dormant
- New session created with UUID
- MCP server set up with instance tools
- Initialize forwarded to underlying MCP server
- Extract session ID from response headers
- Include in all subsequent requests
Step 2: List Tools
Request:- Token validated
- Session reused (ID found in header)
- Filter cached tools by
processId - Return actual tool definitions (not meta-tools)
Step 3: Call Tool
Request:- Token validated
- Session reused
- Tool name converted:
create_issue→proc_123:create_issue - Routed to shared
McpToolExecutor - Tool executed via stdio subprocess
- Result returned
Comparison: Hierarchical vs Instance Router
| Aspect | Hierarchical (/mcp) | Instance (/i/:path/mcp) |
|---|---|---|
| Authentication | OAuth2 Bearer token | URL query param ?token= |
| Token Validation | Backend API introspection | SHA-256 hash (local, fast) |
| Authorization Scope | All user’s instances across team | Single specific instance only |
| Tools Exposed | 2 meta-tools (discover + execute) | ALL actual tools from instance |
| Tool Names | Namespaced (server:tool) | Original (tool) |
| Tool Discovery | Fuse.js fuzzy search | Direct list (no search) |
| Discovery Step | Required (two-step pattern) | Not required (tools in list) |
| Session Manager | Own instance | Own instance (separate) |
| Tool Executor | Shared | Shared |
| Primary Use Case | AI agents (Claude, Cursor, VS Code) | Direct clients (scripts, apps, CLIs) |
| Setup Complexity | OAuth2 flow required | Single token in URL |
| Browser Requirement | Yes (for OAuth authorization) | No |
| Multi-Instance Access | Yes (all user’s instances) | No (one instance per connection) |
| Best For | Interactive AI assistance | Automation, scripts, integrations |
Client Integration Examples
TypeScript/Node.js
Python
Raw HTTP (curl)
Performance Characteristics
Token Validation Latency
SHA-256 Hash Comparison:- Latency: < 1ms (local computation)
- No Network Calls: Unlike OAuth2 introspection (50-200ms)
- CPU Overhead: Negligible (SHA-256 is fast)
| Method | Latency | Network | Caching |
|---|---|---|---|
| SHA-256 Hash | < 1ms | No | N/A |
| OAuth2 Introspection | 50-200ms | Yes | Possible |
Session Overhead
New Session Creation:- Process respawn (stdio only): 500-2000ms
- Session setup: 5-10ms
- MCP initialize: 10-50ms
- Total: 15-60ms (HTTP/SSE), 515-2050ms (stdio with cold start)
- Session lookup: < 1ms
- No initialization overhead
- Total: < 1ms additional latency
- Similar to new session creation
- Synthetic initialize: +5ms
- Total: Same as new session
Shared Executor Benefits
Memory:- Single executor instance serves both routers
- No duplication of execution logic
- Shared request log buffer (batched emission)
- Same OAuth injection logic
- Same retry behavior
- Same error recovery
- Same logging format
- Routing overhead: < 1ms
- Tool execution time: depends on tool (stdio: 10-500ms, HTTP: 50-2000ms)
Implementation Details
Code Locations
Main Implementation:Key Classes and Methods
InstanceRouter Class:-
authenticateInstance()- Token validation middleware- Extracts token from query param
- Validates format (
ds_inst_prefix) - Computes SHA-256 hash
- Compares with stored hash
- Stores auth context in request
-
findInstanceByPath()- Instance lookup- Searches all enabled configs
- Matches by
instance_pathfield - Returns
{ processId, config }or null
-
setupInstanceMcpServer()- MCP server registration- Registers
tools/listhandler (returns actual tools) - Registers
tools/callhandler (converts names, executes) - Filters tools by process ID
- Returns MCP Server instance
- Registers
-
ensureProcessActive()- Process respawning- Checks process status
- Respawns if dormant (stdio only)
- Waits for ready state
- Non-fatal on failure
Dependencies
Direct Dependencies:@modelcontextprotocol/sdk- MCP protocol implementationfastify- HTTP server frameworkcrypto- SHA-256 hash computation
DynamicConfigManager- Instance configuration lookupUnifiedToolDiscoveryManager- Tool cache accessProcessManager- stdio process lifecycleMcpToolExecutor- Shared tool executionMcpSessionManager- Session lifecycle
Security Considerations
Token Security
Storage:- ✅ Plain token NEVER stored in database
- ✅ SHA-256 hash stored instead
- ✅ Token shown to user once (must copy)
- ❌ No token recovery if lost
- ⚠️ Token in URL query parameter (visible in logs)
- ✅ HTTPS required in production (encrypts URL)
- ✅ No token in request body (prevents accidental logging)
- Use HTTPS in production (required)
- Treat tokens like passwords (don’t share)
- Rotate tokens if compromised
- Monitor for unauthorized access attempts
Instance Isolation
Process-Level:- Each instance runs in separate subprocess (stdio)
- No cross-instance tool access
- Token scoped to specific instance
- Sessions isolated per instance
- No cross-session data leakage
- Independent session managers prevent collision
- Instance path uniqueness enforced in database
- Token hash uniqueness enforced in database
- No instance path collisions possible
When to Use Each Router
Use Hierarchical Router (/mcp) When:
✅ Building AI agent integrations (Claude Desktop, Cursor, VS Code)
✅ Users need access to multiple instances
✅ OAuth2 authentication is acceptable
✅ Two-step discovery pattern is okay
✅ User identity matters (per-user tool filtering)
Use Instance Router (/i/:path/mcp) When:
✅ Building automation scripts or CLIs
✅ Direct integration with standard MCP clients
✅ Single instance access is sufficient
✅ OAuth2 is too complex for use case
✅ Token-based auth is preferred
✅ Browser-less operation required
✅ Tool list should show all tools directly
Example Decision Tree
Related Documentation
- Hierarchical Router - OAuth2-based multi-instance access with 2 meta-tools
- Tool Discovery - Internal tool caching and discovery system
- Instance Lifecycle - Per-user instance management and status tracking
- Process Management - stdio MCP server process lifecycle
- MCP Transport Protocols - StreamableHTTP transport details
- Session Management - MCP session lifecycle and resurrection
- OAuth Authentication - OAuth token injection for MCP servers
- Architecture Overview - Complete satellite design and components

