Skip to main content

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 statistics
  • enkrypt_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

No parameters required - returns cache status for the authenticated user.

Return Value

string
required
Operation status: "success" or "error"
object
required
Detailed cache statistics

Usage Examples

Response Structure

Understanding Cache States

Tools were discovered and are cached:
These tools are served from cache until expiration.
Tools are defined in the configuration file:
These tools don’t need caching - they’re always available from config.
Server has no cached or configured tools:
Use enkrypt_discover_all_tools to discover and cache tools.
Cached tools have expired:
Next tool discovery will refresh the cache.

Tool Annotations


enkrypt_clear_cache

Tool Signature

Parameters

Context
required
MCP context (automatically provided)
str
default:"None"
Gateway/User ID whose cache to clear.
  • None: Uses authenticated user’s ID
  • Specific ID: Clears cache for that ID (requires permissions)
str
default:"None"
Name of server whose cache to clear.
  • None: Clears cache for all servers
  • Specific name: Clears cache for that server only
str
default:"None"
Type of cache to clear.
  • None or "all": Clears all caches (tools + config)
  • "gateway_config": Clears gateway configuration cache only
  • "server_config": Clears server tools cache only
Aliases: "gateway", "gateway_cache", "gateway_config_cache"

Return Value

string
required
Operation status: "success" or "info"
string
required
Description of what was cleared

Usage Examples

Response Examples

Tool Annotations


Cache Configuration

Configure cache behavior in enkrypt_mcp_config.json:

Configuration Options

integer
default:"4"
Hours to cache discovered tools
integer
default:"24"
Hours to cache gateway configuration
boolean
default:"false"
Whether to use external cache (Redis/KeyDB)
  • false: Use local in-memory cache
  • true: Use external Redis/KeyDB
string
default:"localhost"
Redis/KeyDB host (when external cache is enabled)
integer
default:"6379"
Redis/KeyDB port
integer
default:"0"
Redis database number
string
default:"null"
Redis password (if required)

Cache Types Comparison

Local Cache

Pros:
  • No external dependencies
  • Fastest access
  • Simple setup
Cons:
  • Not shared across instances
  • Lost on restart
  • Limited by memory

External Cache (Redis/KeyDB)

Pros:
  • Shared across instances
  • Persists across restarts
  • Scalable
Cons:
  • Requires external service
  • Network latency
  • Additional infrastructure

Common Use Cases

If tools aren’t showing up as expected:
This forces a fresh discovery.
After changing cache settings:
When a server is updated with new tools:
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

Cached tools are retrieved in less than 10ms vs 1-5 seconds for fresh discovery.

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.

List Servers

See which servers have cached tools

Discover Tools

Force fresh tool discovery

Timeout Metrics

Monitor cache performance metrics

Configuration

Configure cache settings