Skip to main content

Overview

The enkrypt_discover_all_tools tool discovers available tools from a specific MCP server or all servers, validates them through security guardrails, and caches the results for future use.
Tool discovery happens automatically when you use enkrypt_list_all_servers with discover_tools=true. Use this tool to force re-discovery or troubleshoot specific servers.

Tool Signature

Parameters

Context
required
MCP context (automatically provided by the client)
str
default:"None"
Name of the server to discover tools for.
  • None or "null": Discovers tools for all servers
  • Specific name (e.g., "github"): Discovers tools for that server only

Return Value

string
required
Operation status: "success" or "error"
string
Human-readable description of the result
object
Dictionary or list of discovered tools (single server mode)
object
Dictionary of servers with their tools (all servers mode)
string
Where tools came from: "config", "cache", or "discovery"
array
List of tools blocked by security guardrails
integer
Number of tools blocked

Usage Examples

Discover Tools for a Specific Server

Discover Tools for All Servers

This discovers and caches tools from every configured server.

Force Re-discovery

To bypass cache and force fresh discovery:
This uses enkrypt_clear_cache followed by enkrypt_discover_all_tools.

Response Structure

Single Server Discovery

All Servers Discovery

Tool Sources

Tools can come from three sources:
Tools are explicitly defined in the gateway configuration file under the tools property for the server.Advantages:
  • Instant availability
  • No discovery overhead
  • Can restrict which tools are accessible
Example:
Tools were previously discovered and cached. Default cache duration is 4 hours.Advantages:
  • Fast retrieval
  • No server connection needed
  • Automatic refresh after expiration
Note: Use enkrypt_get_cache_status to check cache expiration.
Tools are dynamically discovered by connecting to the server and requesting its tool list.Advantages:
  • Always up-to-date
  • Discovers new tools automatically
  • Validates tool availability
Note: Results are automatically cached for future use.

Security Validation

Tool Guardrails

If tool guardrails are enabled for a server, discovered tools are validated before being made available:
Example: Blocked Tools
Blocked tools will not be available for execution via enkrypt_secure_call_tools.

Server Validation

Before tool discovery, the server itself is validated:
Example: Blocked Server

Implementation Details

Service Location

Implemented in: src/secure_mcp_gateway/services/discovery/discovery_service.py:52

Three-Phase Parallel Discovery

When discovering tools for all servers, the gateway uses an optimized three-phase approach:

Phase 1: Server Validation

All servers are validated in parallel against security guardrails:

Phase 2: Separation

Servers are separated into two groups:
  • Servers with config tools: Have pre-defined tools in configuration
  • Servers needing discovery: Require dynamic tool discovery

Phase 3: Parallel Execution

Both groups are processed in parallel:
  • Config tools: Validated against guardrails
  • Discovery tools: Discovered and validated
This parallel approach can reduce discovery time from 30+ seconds to under 5 seconds for multiple servers.

Caching Strategy

Discovered tools are cached using a composite key:
  • Cache duration: 4 hours (configurable)
  • Cache invalidation: Automatic expiration or manual via enkrypt_clear_cache
  • Cache types: Local (in-memory) or External (Redis/KeyDB)

Tool Annotations

Common Use Cases

After adding a new server to your configuration:
When a server is updated with new tools:
When expected tools aren’t showing up:
To see if any tools are being blocked:

Error Handling

Error: Server not availableCause: Server name doesn’t exist in configurationSolution: Use enkrypt_list_all_servers to see available servers
Error: Tool discovery failedCauses:
  • Server command/arguments incorrect
  • Required dependencies not installed
  • Server not responding
  • Network connectivity issues
Solution: Check server configuration and logs
Error: Server blocked by security guardrailsCause: Server configuration violates security policiesSolution: Review server configuration and guardrail policies
Error: Discovery operation timed outCause: Server taking too long to respondSolution:
  • Check server performance
  • Adjust timeout settings in gateway config
  • Use enkrypt_get_timeout_metrics to diagnose

Performance Optimization

Use Cache

Don’t force re-discovery unless necessary. Cached tools are returned instantly.

Discover in Background

Use enkrypt_list_all_servers with discover_tools=true to discover all tools at once.

Pre-configure Tools

Define tools in your config file to skip discovery entirely.

External Cache

Use Redis/KeyDB for shared cache across multiple gateway instances.

List Servers

See all configured servers before discovery

Execute Tools

Use discovered tools securely

Cache Status

Check cache status and expiration

Clear Cache

Force re-discovery by clearing cache