Overview
Secure MCP Gateway automatically discovers available tools from MCP servers and makes them accessible to clients. The discovery service handles authentication, caching, validation, and forwards discovery requests to actual MCP servers.Discovery Flow
1
Client Request
MCP client requests tool discovery via
enkrypt_discover_all_tools2
Authentication
Gateway validates client credentials and retrieves configuration
3
Cache Check
Discovery service checks if tools are already cached
4
Forward Request
If cache miss, gateway forwards discovery request to MCP server
5
Validation
Optional guardrail validation of discovered tools
6
Cache Storage
Tools are cached for future requests (4 hours default)
7
Return Results
Discovered tools returned to client with metadata
DiscoveryService Implementation
Core Discovery Method
src/secure_mcp_gateway/services/discovery/discovery_service.py
Single Server Discovery
src/secure_mcp_gateway/services/discovery/discovery_service.py
All Servers Discovery
src/secure_mcp_gateway/services/discovery/discovery_service.py
Tool Validation
Optional guardrail validation during discovery:src/secure_mcp_gateway/services/discovery/discovery_service.py
Gateway Integration
The discovery service is integrated into the main gateway:src/secure_mcp_gateway/gateway.py
Tool Format
Discovered tools follow the MCP tool schema:Example Tool
Client Usage Examples
Predefined Tools
Servers can have predefined tools in configuration instead of dynamic discovery:enkrypt_mcp_config.json
Performance Optimization
Cache First: Discovery always checks cache before forwarding to MCP servers, reducing latency by 80-95%.
Parallel Discovery: When discovering all servers, requests are made in parallel for better performance.
Metrics and Monitoring
Discovery service emits telemetry:discovery.requests.total- Total discovery requestsdiscovery.cache_hits- Cache hitsdiscovery.cache_misses- Cache missesdiscovery.latency.ms- Discovery latencydiscovery.errors.count- Discovery errors