Skip to main content

Overview

Guardrails provide security and content filtering for your MCP servers by validating requests before they reach the server (input guardrails) and responses before they return to the client (output guardrails).

What Are Guardrails?

Guardrails analyze content for:

Input Protection

  • PII detection & redaction
  • Injection attack prevention
  • Toxicity detection
  • NSFW content filtering
  • Policy violation detection
  • Keyword blocking
  • Bias detection

Output Protection

  • All input protections
  • Relevancy validation
  • Adherence checking
  • Hallucination detection
  • PII de-anonymization

Prerequisites

  • Secure MCP Gateway installed
  • Enkrypt API key (get from Enkrypt Dashboard)
  • Server configured in your gateway

Quick Start

Set Enkrypt API Key

First, configure your Enkrypt API key:
This stores the key in your guardrails configuration at ~/.enkrypt/enkrypt_mcp_config.json:

Enable Guardrails for a Server

Detector Types

Input Detectors

Output Detectors

PII Detection & Redaction

Enabling PII Redaction

1

Enable in input guardrails

2

PII is detected and redacted

Input: "My email is john@example.com and SSN is 123-45-6789"Redacted: "My email is [PII_EMAIL_1] and SSN is [PII_SSN_1]"
3

Response is de-anonymized

The gateway automatically restores PII in the response using the mapping created during redaction.

How PII Redaction Works

Custom Policies

Creating a Policy in Enkrypt Dashboard

1

Navigate to Policies

2

Create New Policy

Click “Create Policy” and name it (e.g., “Production API Policy”)
3

Configure Detectors

Select which detectors to enable and their thresholds:
  • Injection Attack: Threshold 0.7, Action: Block
  • Toxicity: Threshold 0.6, Action: Warn
  • PII: Always detect, Action: Redact
  • Keywords: Add custom blocked terms
4

Save and Use

Save the policy and reference it in your config:

Example: Strict Security Policy

Example: Lenient Development Policy

Advanced Configuration

Async Guardrails

Enable asynchronous guardrail processing for improved performance:
Async guardrails process in the background and don’t block requests. Use only for logging/monitoring, not for blocking malicious content.

Guardrail Timeouts

Configure timeout settings in the common config:

Per-Tool Guardrails

Apply guardrails to specific tools only:

Testing Guardrails

Test Input Guardrails

Test Output Guardrails

Check Guardrail Logs

Guardrail detections are logged in the gateway logs:
Look for entries like:

Monitoring & Metrics

View Guardrail Activity

In Claude Desktop, ask:
Or use the CLI:

Enkrypt Dashboard

View detailed guardrail analytics in the Enkrypt Dashboard:
  • Request/block rates
  • Top violations
  • PII detection trends
  • Policy effectiveness

Use Cases

Protect sensitive financial data:
Detects and redacts:
  • Credit card numbers
  • SSNs
  • Account numbers
  • Tax IDs
Ensure HIPAA compliance:
Protects:
  • Patient names
  • Medical record numbers
  • Health information
  • Insurance IDs
Protect student data (FERPA):
Prevent code injection:

Troubleshooting

Guardrails Not Working

1

Verify API Key

Ensure it matches your key from Enkrypt Dashboard
2

Check Policy Exists

Log into Enkrypt Dashboard and verify the policy name exists in your account
3

Confirm Guardrails Enabled

Look for "enabled": true in guardrails policies
4

Test Connectivity

False Positives

  • Adjust thresholds: Lower detector sensitivity in Enkrypt Dashboard
  • Whitelist terms: Add exceptions to keyword detector
  • Refine policy: Use more specific detectors instead of broad ones

Performance Issues

  • Enable async guardrails: For non-blocking operation
  • Increase timeout: Adjust guardrail_timeout in config
  • Cache policies: Guardrail results are cached by default
  • Use fewer detectors: Only enable necessary protections

Best Practices

Start Lenient

Begin with minimal detectors and add more based on observed threats

Test Thoroughly

Test guardrails in development before production deployment

Monitor Metrics

Review Enkrypt Dashboard regularly for policy effectiveness

Different Policies per Environment

Use strict policies in production, lenient in development

Enable PII Redaction

Always enable PII redaction for servers handling sensitive data

Document Policies

Keep a record of which policies are used where and why

Next Steps

OAuth Setup

Secure remote servers with OAuth authentication

External Cache

Improve guardrail performance with Redis caching

Custom Plugins

Create custom guardrail providers

API Reference

Explore guardrails API endpoints