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.This document focuses on the internal tool discovery mechanism. To learn how tools are exposed to MCP clients through the hierarchical router pattern, see Hierarchical Router Implementation.Technical Overview
Unified Discovery Architecture
Tool discovery operates through three coordinated managers that handle different transport types and merge results:Core Components
UnifiedToolDiscoveryManager:- Coordinates tool discovery across both HTTP/SSE and stdio transport types
- Merges discovered tools from both managers into a unified cache
- Routes discovery requests to the appropriate 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
- Tools persist in cache even when processes go dormant
- 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/listJSON-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 persist in cache even when process terminates (for fast respawn)
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
- Tools persist even when process goes dormant (enables fast respawn)
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
- Persistent Caching: stdio tools remain cached even when processes go dormant
- Conflict Prevention: server_slug ensures unique names
Namespacing Strategy
Both HTTP and stdio tools use identical namespacing:- Format:
{server_slug}-{originalToolName} - HTTP: Uses
server_slugfrom 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 persist in cache for optimal performance: Process Lifecycle:- Spawn: Tools discovered after handshake
- Running: Tools available for execution
- Idle/Dormant: Process terminated, tools remain cached for fast respawn
- Respawn: Process restarts automatically, tools already available (no rediscovery)
- Uninstall: Tools cleared only when server is explicitly removed
Idle Process Management: stdio processes that remain inactive for the configured idle timeout (default: 3 minutes) are automatically terminated to save memory. However, tools remain cached so when a client requests them, the process respawns instantly without needing to rediscover tools. This reduces respawn time from 1-3 seconds to 1-2 seconds. See Idle Process Management for details.
Tool Metadata Collection
After tool discovery completes, the satellite emits tool metadata to the backend for storage and analysis.Event Emission (Post-Discovery)
Following successful tool discovery (both HTTP/SSE and stdio), the satellite:- Calculates token consumption using the
token-counter.tsutility - Builds event payload with tool metadata including per-tool token counts
- Emits
mcp.tools.discoveredevent to backend via EventBus - Backend stores metadata in
mcpToolMetadatatable for team visibility
StdioToolDiscoveryManager: Emits after stdio tool discovery completesRemoteToolDiscoveryManager: Emits after HTTP/SSE tool discovery completesEventBus: Batches events every 3 seconds for efficient transmission- Backend handler: Stores tools with delete-then-insert strategy
estimateMcpServerTokens() from token-counter.ts to calculate:
- Per-tool tokens:
name+description+JSON.stringify(inputSchema) - Total server tokens: Sum of all tool tokens
- Uses
gpt-tokenizerlibrary (provider-agnostic)
- Store tool metadata in backend database for team visibility
- Calculate hierarchical router token savings (traditional vs 2-meta-tool approach)
- Enable frontend tool catalog display with token consumption metrics
- Provide analytics on MCP server complexity and context window usage
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
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 (first time only)
- Memory: ~1KB per tool (persists even when process dormant)
- Overhead: Single JSON-RPC request per process (cached for respawns)
- Caching: Persistent - tools remain even when process goes dormant
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)

