Overview
The Secure MCP Gateway caches discovered tools to improve performance. Two tools help you monitor and manage this cache:enkrypt_get_cache_status- View cache status and statisticsenkrypt_clear_cache- Clear cached data to force re-discovery
Cache management tools are primarily used for debugging and troubleshooting. Normal operation doesn’t require manual cache management.
enkrypt_get_cache_status
Tool Signature
Return Value
Operation status:
"success" or "error"Detailed cache statistics
Usage Examples
Response Structure
Understanding Cache States
Cached Tools (exists: true)
Cached Tools (exists: true)
Tools were discovered and are cached:These tools are served from cache until expiration.
Config Tools (are_tools_explicitly_defined: true)
Config Tools (are_tools_explicitly_defined: true)
Tools are defined in the configuration file:These tools don’t need caching - they’re always available from config.
Needs Discovery (needs_discovery: true)
Needs Discovery (needs_discovery: true)
Server has no cached or configured tools:Use
enkrypt_discover_all_tools to discover and cache tools.Expired Cache (is_expired: true)
Expired Cache (is_expired: true)
Cached tools have expired:Next tool discovery will refresh the cache.
Tool Annotations
enkrypt_clear_cache
Tool Signature
Parameters
MCP context (automatically provided)
Gateway/User ID whose cache to clear.
None: Uses authenticated user’s ID- Specific ID: Clears cache for that ID (requires permissions)
Name of server whose cache to clear.
None: Clears cache for all servers- Specific name: Clears cache for that server only
Type of cache to clear.
Noneor"all": Clears all caches (tools + config)"gateway_config": Clears gateway configuration cache only"server_config": Clears server tools cache only
"gateway", "gateway_cache", "gateway_config_cache"Return Value
Operation status:
"success" or "info"Description of what was cleared
Usage Examples
Response Examples
Tool Annotations
Cache Configuration
Configure cache behavior inenkrypt_mcp_config.json:
Configuration Options
Hours to cache discovered tools
Hours to cache gateway configuration
Whether to use external cache (Redis/KeyDB)
false: Use local in-memory cachetrue: Use external Redis/KeyDB
Redis/KeyDB host (when external cache is enabled)
Redis/KeyDB port
Redis database number
Redis password (if required)
Cache Types Comparison
Local Cache
Pros:
- No external dependencies
- Fastest access
- Simple setup
- Not shared across instances
- Lost on restart
- Limited by memory
External Cache (Redis/KeyDB)
Pros:
- Shared across instances
- Persists across restarts
- Scalable
- Requires external service
- Network latency
- Additional infrastructure
Common Use Cases
Troubleshoot Missing Tools
Troubleshoot Missing Tools
If tools aren’t showing up as expected:This forces a fresh discovery.
Verify Cache Configuration
Verify Cache Configuration
After changing cache settings:
Refresh After Server Update
Refresh After Server Update
When a server is updated with new tools:
Monitor Cache Health
Monitor Cache Health
Regular cache health checks:
Implementation Details
Service Locations
- Cache Status:
src/secure_mcp_gateway/services/cache/cache_status_service.py:55 - Cache Management:
src/secure_mcp_gateway/services/cache/cache_management_service.py:71 - Core Cache:
src/secure_mcp_gateway/services/cache/cache_service.py
Cache Key Format
Cache keys are hashed for security:Cache Registry
The gateway maintains a registry of all cache entries for efficient clearing:Performance Impact
Cache Hit Rates
Monitor cache effectiveness:Best Practices
Regular Monitoring
Check cache status periodically to ensure healthy operation.
Selective Clearing
Clear specific servers rather than all caches when possible.
External Cache for Production
Use Redis/KeyDB for production deployments with multiple instances.
Appropriate TTLs
Set cache expiration based on how frequently tools change.
Related Tools
List Servers
See which servers have cached tools
Discover Tools
Force fresh tool discovery
Timeout Metrics
Monitor cache performance metrics
Configuration
Configure cache settings