Skip to main content

Overview

The Secure MCP Gateway provides automatic detection and redaction of Personally Identifiable Information (PII) to protect sensitive user data. The PII handling system operates transparently:
  1. Input: PII is detected and redacted before sending to MCP servers
  2. Processing: MCP servers see only redacted/anonymized data
  3. Output: PII is automatically restored in responses (de-anonymization)
Zero Trust for PII: Even trusted MCP servers never see original PII values, reducing data exposure risk.

How PII Redaction Works

Complete Flow

Step-by-Step Process

1

PII Detection

Input Analysis: Scan request for PII entitiesThe PII handler analyzes the input text using pattern matching and NLP models:
Example:
2

PII Redaction

Token Replacement: Replace PII with anonymized tokensEach PII entity is replaced with a unique token:
Example:
3

Protected Processing

Server Communication: Send redacted text to MCP serverThe MCP server receives only anonymized data:
4

PII Restoration (De-anonymization)

Token Replacement (Reverse): Restore original PII in responseUsing the stored mapping, tokens are replaced with original values:
Example:

Supported PII Types

Personal Information

Names:
  • Person names (first, last, full)
  • Organization names
  • Nicknames and aliases
Identifiers:
  • Social Security Numbers (SSN)
  • Tax IDs (EIN, ITIN)
  • National ID numbers
  • Passport numbers
  • Driver’s license numbers
Example:
Email Addresses:Phone Numbers:
  • US format: (555) 123-4567
  • International: +1-555-123-4567
  • Extensions: 555-1234 x567
Physical Addresses:
  • Street addresses
  • Cities, states, ZIP codes
  • Country information
  • PO boxes
Example:
Payment Cards:
  • Credit card numbers (Visa, MasterCard, Amex, Discover)
  • Debit card numbers
  • CVV codes
  • Expiration dates
Bank Details:
  • Account numbers
  • Routing numbers
  • IBAN codes
  • SWIFT codes
Example:
IP Addresses:
  • IPv4 (192.168.1.1)
  • IPv6 (2001:0db8:85a3::8a2e:0370:7334)
  • Private IPs (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
MAC Addresses:
  • Standard format (00:1B:44:11:3A:B7)
  • Cisco format (001B.4411.3AB7)
  • Windows format (00-1B-44-11-3A-B7)
Example:
Dates:
  • Birth dates
  • Event dates
  • Timestamps
Ages:
  • Exact ages
  • Age ranges (if specific)
Example:

Configuration

Enable PII Redaction

Per-Server Configuration:

Block on PII Detection (Optional)

You can also block requests that contain PII instead of redacting:
Use Case: Prevent users from accidentally including PII in public-facing tools.

Custom PII Entities

Configure which PII types to detect:

PII Mapping Security

Secure Storage

Ephemeral Mappings: PII mappings are stored only for the duration of the request/response cycle
The PII mapping is:
  1. Generated server-side by Enkrypt API
  2. Associated with a unique session key
  3. Never logged or persisted
  4. Automatically expires after use
  5. Encrypted in transit (HTTPS)

Mapping Key Structure

Security Properties:
  • Keys are cryptographically random (160+ bits of entropy)
  • Mappings are never exposed in logs
  • Keys cannot be reused across sessions
  • Server-side storage is encrypted at rest

Advanced Use Cases

Scenario 1: Customer Support

Goal: Protect customer PII when using AI tools
Flow:

Scenario 2: Data Analysis

Goal: Analyze customer data without exposing PII
Flow:

Scenario 3: Compliance (GDPR/CCPA)

Goal: Minimize PII exposure for compliance

Limitations & Best Practices

Not 100% Accurate: PII detection uses ML models with ~95-98% accuracyFalse Positives:
  • Generic names (“John Smith” in documentation)
  • Example emails (user@example.com)
  • Sample phone numbers (555-0100)
False Negatives:
  • Obfuscated PII (j.doe@example.com as “j dot doe at example”)
  • Non-standard formats
  • Context-dependent PII
Best Practice:
  • Test with sample data before production
  • Review redaction results periodically
  • Use additional guardrails (keyword detection) for critical PII
Latency: PII redaction adds 50-150ms per requestOptimization:
  • Enable only for servers handling user data
  • Use selective entity types (don’t detect all PII if unnecessary)
  • Cache redaction results for repeated inputs
Monitoring:
Challenge: Redaction may break context for AI understandingExample:
Mitigation:
  • Use partial redaction for non-sensitive patterns
  • Provide domain whitelist (e.g., allow @company.com)
  • Include metadata hints (e.g., “[EMAIL_1 from company.com]”)
Problem: Tokens don’t persist across sessionsExample:
Why: Each session gets a unique PII key for securityBest Practice: If consistency needed, use custom identifiers instead of PII

Testing PII Redaction

Manual Testing

Integration Testing

Automated Testing

Use the included test suite:

Monitoring & Metrics

PII Metrics

Available Metrics:
  • pii_redactions_total - Total PII redaction operations
  • pii_detections_by_type - PII detections by entity type (EMAIL, PHONE, etc.)
  • pii_redaction_latency - Time to redact PII
  • pii_restoration_latency - Time to restore PII
  • pii_failures_total - Failed PII operations
Grafana Dashboard: The gateway includes a PII monitoring dashboard showing:
  • Redaction rate over time
  • PII types detected
  • Latency percentiles (p50, p95, p99)
  • Error rates

Logging

PII events are logged (with PII values masked):

Next Steps

Security Testing

Test PII redaction with attack scenarios

Guardrail Types

Learn about other guardrail types

Configuration

Configure PII redaction for your servers

Compliance

GDPR/CCPA compliance guide