Tool Discovery Implementation
DeployStack Satellite implements automatic tool discovery from MCP servers across both HTTP/SSE remote endpoints and stdio subprocess servers. This unified system provides dynamic tool availability without manual configuration, enabling MCP clients to discover and execute tools through the satellite’s interface.Current Implementation: Tool discovery fully supports both HTTP/SSE remote MCP servers and stdio subprocess servers through a unified architecture. The
UnifiedToolDiscoveryManager
coordinates discovery across both transport types, merging tools into a single cache for seamless client access.Technical Overview
Unified Discovery Architecture
Tool discovery operates through three coordinated managers that handle different transport types and merge results:Core Components
UnifiedToolDiscoveryManager:- Coordinates discovery across HTTP/SSE and stdio transport types
- Merges tools from both managers into unified cache
- Routes discovery requests based on transport type
- Provides single interface for MCP protocol handlers
- Queries remote HTTP/SSE MCP servers during startup
- Parses Server-Sent Events responses
- Maintains in-memory cache with namespacing
- Handles differential configuration updates
- Discovers tools from stdio subprocess MCP servers
- Executes discovery after process spawn and handshake
- Automatically clears tools on process termination
- Tracks tools by server with namespacing
Discovery Process by Transport Type
HTTP/SSE Discovery (Startup)
Remote HTTP/SSE servers are discovered during satellite initialization:- Load enabled HTTP/SSE servers from dynamic configuration
- Query each server with
tools/list
JSON-RPC request - Parse SSE or JSON responses
- Cache tools with namespacing (
server_slug-tool_name
) - Expose through MCP transport endpoints
stdio Discovery (Post-Spawn)
stdio subprocess servers are discovered after process spawning:- Process spawned via Backend command
- MCP handshake completes (initialize + initialized)
- Discovery triggered automatically after handshake
- Tools cached with namespacing (
server_slug-tool_name
) - Tools cleared automatically on process termination
Discovery Timing Differences
HTTP/SSE (Eager):- Discovered at startup before serving requests
- All HTTP tools available immediately
- Configuration changes trigger rediscovery
- Discovered after process spawn completes
- Tools become available post-handshake
- Process termination removes tools automatically
Tool Caching Strategy
Unified Cache Design
Both transport types use identical caching and namespacing:- Unified Namespace: Same format across both transport types
- Memory Storage: No persistent storage or database
- Automatic Cleanup: stdio tools removed on process exit
- Conflict Prevention: server_slug ensures unique names
Namespacing Strategy
Both HTTP and stdio tools use identical namespacing:- Format:
{server_slug}-{originalToolName}
- HTTP: Uses
server_slug
from configuration - stdio: Extracts slug from installation name
- Routing: Internal server names used for team isolation
- User Display: Friendly namespaced names shown to clients
Configuration Management
Dynamic Configuration Updates
The unified manager handles configuration changes intelligently: Differential Updates:- Only discovers tools for added/modified servers
- Preserves tools for unchanged servers
- Removes tools for deleted servers
- Minimizes network overhead and latency
- HTTP/SSE: Static configuration from Backend polling
- stdio: Dynamic spawning via Backend commands
- Both: Support three-tier configuration system
Tool Execution Flow
Transport-Aware Routing
Tool execution routes to the correct transport based on discovery:- Routes to remote HTTP/SSE endpoint
- Uses HTTP Proxy Manager
- Handles SSE streaming responses
- Routes to local subprocess
- Uses ProcessManager JSON-RPC
- Communicates over stdin/stdout
Error Handling & Recovery
Discovery Failures
Both managers implement graceful failure handling: HTTP Discovery:- Server unreachable → Skip and continue
- Parse errors → Log and skip malformed tools
- Timeout → Mark server as failed
- Process not running → Error with status check
- No tools returned → Empty array (valid response)
- Communication failure → Process restart logic
Automatic Cleanup
stdio tools are automatically managed: Process Lifecycle:- Spawn: Tools discovered after handshake
- Running: Tools available for execution
- Terminate: Tools removed from cache automatically
Development Considerations
Debugging Support
The debug endpoint shows tools from both transport types:- Tools grouped by transport type (HTTP/stdio)
- Tools grouped by server name
- Discovery statistics for both managers
- Process status for stdio servers
Security Notice: The debug endpoint exposes detailed system information. Disable in production with
DEPLOYSTACK_STATUS_SHOW_MCP_DEBUG_ROUTE=false
.Testing Strategies
Unified Testing:Performance Characteristics
HTTP/SSE Performance
- Discovery Time: 2-5 seconds at startup
- Memory: ~1KB per tool
- Overhead: Single HTTP request per server
- Caching: Persistent until configuration change
stdio Performance
- Discovery Time: 1-2 seconds post-spawn
- Memory: ~1KB per tool
- Overhead: Single JSON-RPC request per process
- Caching: Automatic cleanup on process exit
Scalability
Combined Limits:- No hard server limit for either transport
- Memory-bound by total tool count
- HTTP: Limited by network connection pool
- stdio: Limited by system process limits
Implementation Status: Tool discovery is fully operational for both HTTP/SSE remote servers and stdio subprocess servers. The unified manager successfully coordinates discovery, merges tools, and routes execution requests to the appropriate transport.
Future Enhancements
Dynamic Capabilities
Planned Features:- Runtime refresh for HTTP servers without restart
- Configuration hot-reload for both transport types
- Health monitoring with automatic server detection
- Tool versioning support
Advanced Features
Under Consideration:- Load balancing across multiple server instances
- Circuit breakers for automatic failure recovery
- Detailed usage and performance analytics
- Cache persistence for faster startup (HTTP only)