Overview
Theenkrypt_secure_call_tools tool provides secure batch execution of MCP server tools with comprehensive guardrail checks, PII handling, and detailed response tracking.
Tool Signature
Parameters
MCP context (automatically provided by the client)
Name of the server containing the tools to execute
List of tool calls to execute. Each item should be an object with:Special behavior:
- Empty list
[]: Triggers tool discovery only (no execution) - Single item: Executes one tool
- Multiple items: Executes all tools in sequence within the same session
Important: If you need to execute multiple tools, pass them all in a single list. Multiple separate calls will create new sessions each time, which may fail or be inefficient.
Return Value
Overall status:
"success", "error", "blocked_input", or "blocked_output"Human-readable description of the execution result
Array of individual tool execution results
Summary statistics about the batch execution
Usage Examples
Execute a Single Tool
Execute Multiple Tools in Sequence
Discovery Mode (No Execution)
To discover tools without executing them:Response Structure
Successful Execution
Blocked by Input Guardrails
Blocked by Output Guardrails
Security Features
Input Guardrails
Before executing tools, the gateway validates input arguments:PII Detection & Redaction
PII Detection & Redaction
Automatically detects and redacts personally identifiable information:The original PII is stored securely and restored in the response.
Content Safety
Content Safety
Checks for:
- NSFW content
- Toxic language
- Hate speech
- Profanity
Injection Prevention
Injection Prevention
Detects and blocks:
- SQL injection attempts
- Command injection
- Prompt injection
- XSS attacks
Policy Enforcement
Policy Enforcement
Validates against custom organizational policies:
- Topic restrictions
- Keyword blocking
- Business rules
Output Guardrails
After execution, responses are validated:All Input Checks
All Input Checks
All input guardrail checks are also applied to outputs.
Relevancy Validation
Relevancy Validation
Ensures the response is relevant to the input:
Adherence Checking
Adherence Checking
Verifies the response follows instructions:
Hallucination Detection
Hallucination Detection
Identifies potentially fabricated information in responses.
PII De-anonymization
PII De-anonymization
Automatically restores redacted PII in the response if the output is safe.
Async Guardrails
For improved performance, guardrails can run asynchronously:Configuration
- Input guardrails and tool execution run in parallel
- Response is blocked if guardrails detect violations
- Reduces total execution time by ~50%
Implementation Details
Service Location
Implemented in:src/secure_mcp_gateway/services/execution/secure_tool_execution_service.py:64
Execution Flow
- Authentication - Validate gateway credentials
- Server Lookup - Find server configuration
- Tool Discovery - Ensure tools are available (cached or discovered)
- Session Creation - Open persistent session to server
- For each tool call:
- Input Guardrails - Validate input (if enabled)
- PII Redaction - Redact sensitive data (if enabled)
- Tool Execution - Call the actual tool
- Output Guardrails - Validate output (if enabled)
- PII Restoration - Restore redacted data (if safe)
- Session Cleanup - Close server connection
- Summary - Return execution results
Session Management
All tool calls in a single request share the same server session. This is critical for stateful operations.
Error Handling
Execution stops on first error or block:Tool Annotations
Performance Optimization
Batch Calls
Execute multiple tools in one request to reuse the session.
Async Guardrails
Enable async guardrails to run checks in parallel with execution.
Cache Tools
Ensure tools are discovered and cached before execution.
Timeout Tuning
Adjust timeout settings for slow tools via gateway config.
Common Use Cases
Safe API Calls
Safe API Calls
Execute external API calls with automatic PII protection:The gateway redacts the email before sending to the server.
Multi-step Workflows
Multi-step Workflows
Execute complex workflows in a single session:
Content Moderation
Content Moderation
Automatically filter inappropriate content:Toxic or NSFW content is blocked before posting.
Policy Enforcement
Policy Enforcement
Enforce organizational policies on tool usage:Policy violations are blocked automatically.
Error Codes
TOOL_NOT_FOUND
TOOL_NOT_FOUND
Error: Tool not found for this serverSolution: Use
enkrypt_discover_all_tools to see available toolsTOOL_EXECUTION_FAILED
TOOL_EXECUTION_FAILED
Error: Tool execution failedCauses: Server error, invalid arguments, connectivity issuesSolution: Check tool arguments and server logs
GUARDRAIL_VALIDATION_FAILED
GUARDRAIL_VALIDATION_FAILED
Error: Input/output blocked by guardrailsSolution: Review violation details in the response
AUTH_INVALID_CREDENTIALS
AUTH_INVALID_CREDENTIALS
Error: Authentication failedSolution: Verify gateway key configuration
Configuration Reference
Configure guardrails per-server inenkrypt_mcp_config.json:
Related Tools
List Servers
See available servers to execute tools from
Discover Tools
Find available tools before execution
Timeout Metrics
Monitor execution performance
Guardrails Config
Configure security policies