Skip to main content
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.
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.
For AI agents and applications requiring access to multiple instances, see Hierarchical Router which uses OAuth2 and provides 2 meta-tools for dynamic tool discovery.

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
Impact on Simple Clients:

The Instance Router Solution

Path-based routing with token authentication provides direct access:
Benefits:
  • 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 McpToolExecutor for 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)
Single Responsibility:
  • 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:
Parameters:
  • :instancePath - URL path parameter (e.g., bold-penguin-42a3)
  • token - Query parameter (e.g., ds_inst_abc123...)
Headers:
  • Content-Type: application/json
  • mcp-session-id: <session-id> (optional, for session reuse)
Body: JSON-RPC 2.0 request Examples:
  • 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:
Headers:
  • mcp-session-id: <session-id> (required)
Response: SSE stream with MCP notifications

DELETE /i/:instancePath/mcp

Purpose: Session termination URL Format:
Headers:
  • mcp-session-id: <session-id> (required)
Response: Session closed

Authentication Flow

Token Format

Instance tokens follow a specific format for easy identification:
Example:
Components:
  • 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_hash column)
  • Plain token shown to user ONCE (copy before closing)
  • Hash included in satellite configuration
Validation Process:

Authentication Error Responses

404 Not Found:
401 Unauthorized (Missing Token):
401 Unauthorized (Invalid Token):
500 Internal Server Error:

Session Management

Session Lifecycle

The instance router supports three session modes:

1. Create New Session (Initialize)

Trigger: Client sends initialize request without existing session Process:
  1. Validate token
  2. Check if stdio process is active (respawn if dormant)
  3. Create new MCP session
  4. Generate unique session ID
  5. Set up MCP server with instance tools
  6. Return session ID in response
Client Receives:
  • Session ID in response
  • Should include in subsequent requests as mcp-session-id header

2. Reuse Existing Session

Trigger: Client sends request with valid mcp-session-id header Process:
  1. Validate token
  2. Look up session by ID
  3. Verify session exists and is active
  4. Process request using existing session
Benefits:
  • No session recreation overhead
  • Maintains state between requests
  • Faster request processing

3. Resurrect Stale Session

Trigger: Client sends request with mcp-session-id for non-existent session Process:
  1. Validate token
  2. Session not found in memory (possibly satellite restarted)
  3. Respawn stdio process if needed
  4. Create new session with same ID
  5. Send synthetic initialize request to MCP server
  6. Process client’s original request
Why This Matters:
  • Handles satellite restarts gracefully
  • Client doesn’t need to reinitialize manually
  • Maintains user experience

Session Storage

Sessions are stored in a separate McpSessionManager instance:
Key Points:
  • 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
Process:
Non-Fatal:
  • 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):
Instance Router (actual tools):
Key Differences:
  • Tool names are original/non-namespaced (create_issue not github: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):
Satellite Internal (Routing Format):
Why Conversion is Needed:
  • McpToolExecutor expects 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 same McpToolExecutor 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
Benefits:
  • 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:
Processing:
  1. Token validated (SHA-256 hash comparison)
  2. Instance found by path: bold-penguin-42a3
  3. stdio process respawned if dormant
  4. New session created with UUID
  5. MCP server set up with instance tools
  6. Initialize forwarded to underlying MCP server
Response:
Client Action:
  • Extract session ID from response headers
  • Include in all subsequent requests

Step 2: List Tools

Request:
Processing:
  1. Token validated
  2. Session reused (ID found in header)
  3. Filter cached tools by processId
  4. Return actual tool definitions (not meta-tools)
Response:

Step 3: Call Tool

Request:
Processing:
  1. Token validated
  2. Session reused
  3. Tool name converted: create_issueproc_123:create_issue
  4. Routed to shared McpToolExecutor
  5. Tool executed via stdio subprocess
  6. Result returned
Response:

Comparison: Hierarchical vs Instance Router

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)
Comparison:

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 Reuse:
  • Session lookup: < 1ms
  • No initialization overhead
  • Total: < 1ms additional latency
Stale Session Resurrection:
  • 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)
Consistency:
  • Same OAuth injection logic
  • Same retry behavior
  • Same error recovery
  • Same logging format
Latency:
  • Routing overhead: < 1ms
  • Tool execution time: depends on tool (stdio: 10-500ms, HTTP: 50-2000ms)

Implementation Details

Code Locations

Main Implementation:
Shared Modules:
Integration:

Key Classes and Methods

InstanceRouter Class:
Key Methods:
  1. 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
  2. findInstanceByPath() - Instance lookup
    • Searches all enabled configs
    • Matches by instance_path field
    • Returns { processId, config } or null
  3. setupInstanceMcpServer() - MCP server registration
    • Registers tools/list handler (returns actual tools)
    • Registers tools/call handler (converts names, executes)
    • Filters tools by process ID
    • Returns MCP Server instance
  4. 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 implementation
  • fastify - HTTP server framework
  • crypto - SHA-256 hash computation
Internal Dependencies:
  • DynamicConfigManager - Instance configuration lookup
  • UnifiedToolDiscoveryManager - Tool cache access
  • ProcessManager - stdio process lifecycle
  • McpToolExecutor - Shared tool execution
  • McpSessionManager - 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
Transmission:
  • ⚠️ Token in URL query parameter (visible in logs)
  • ✅ HTTPS required in production (encrypts URL)
  • ✅ No token in request body (prevents accidental logging)
Best Practices:
  • 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
Session-Level:
  • Sessions isolated per instance
  • No cross-session data leakage
  • Independent session managers prevent collision
Configuration-Level:
  • 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