Skip to main content
Glama

⚠️ SECURITY & PRIVACY WARNING ⚠️

PLEASE READ CAREFULLY BEFORE USE

Using this MCP server to detect PII involves sending text data to the Presidio engine. While the processing happens locally within the container or python process, using this tool via an LLM Agent (like Claude, ChatGPT, etc.) implies that the text to be analyzed is being shared with that LLM.

RISKS:

  • PII Leakage: If you ask an LLM to "check this text for PII" or "anonymize this", you are sending the potentially sensitive text to the LLM provider first so they can construct the tool call.

  • Context Retention: The PII may be retained in the LLM's chat history, training data, or logs.

  • Transmitted Context: PII will be part of the prompt context transmitted over the network.

RECOMMENDED USE:

  • Local LLMs: Use with locally hosted LLMs where data does not leave your infrastructure.

  • Private/Enterprise Agents: Use in approved enterprise environments with strict data privacy agreements.

  • Non-LLM Integration: Use the underlying libraries directly in your code without an LLM intermediary if strict privacy is required.

ALTERNATIVE ARCHITECTURES: Consider using Presidio as a filter before the LLM. Tools like LiteLLM can integrate Presidio to sanitize input before it reaches the LLM provider, preventing PII from ever leaving your control. This MCP server is designed for agentic workflows where the LLM decides to check for PII, which inherently carries the risks mentioned above.

MCP Presidio

A Model Context Protocol (MCP) server that provides comprehensive PII (Personally Identifiable Information) detection and anonymization capabilities using Microsoft Presidio. This server enables LLMs to safely handle sensitive data by detecting and anonymizing PII in text and structured data.

Features

Core Capabilities

  • PII Detection: Identify 25+ types of PII including names, emails, phone numbers, credit cards, SSNs, addresses, and more

  • Text Anonymization: Multiple anonymization strategies (replace, redact, hash, mask, encrypt)

  • Structured Data Support: Analyze and anonymize JSON/dictionary data recursively

  • Batch Processing: Process multiple texts efficiently in batch operations

  • Custom Recognizers: Add domain-specific PII patterns with regex

  • Multi-language Support: Detect PII in multiple languages

  • Validation Tools: Test and validate detection accuracy with metrics

Available MCP Tools

  1. analyze_text - Detect PII entities in text with confidence scores

  2. anonymize_text - Anonymize PII using various operators

  3. get_supported_entities - List all supported PII entity types

  4. add_custom_recognizer - Add custom PII detection patterns

  5. batch_analyze - Analyze multiple texts for PII

  6. batch_anonymize - Anonymize multiple texts

  7. get_anonymization_operators - List available anonymization methods

  8. analyze_structured_data - Detect PII in JSON/structured data

  9. anonymize_structured_data - Anonymize PII in structured data

  10. validate_detection - Validate detection accuracy with metrics

Related MCP server: pii-anonymizer

Installation

Choose your preferred installation method:

  • 🐳 Docker - Self-contained, reproducible environment (recommended for production)

  • 🐍 Python - Direct installation with interactive setup

  • πŸ“¦ Manual - Full control over the installation process

For detailed Docker deployment instructions, see DOCKER.md.

Prerequisites

For Python Installation:

  • Python 3.10 or higher

  • pip or uv package manager

For Docker Installation:

  • Docker 20.10 or higher

  • Docker Compose (optional, for easier management)

Docker provides a self-contained, reproducible environment with all dependencies pre-installed.

Quick Start with Docker

# Clone the repository
git clone https://github.com/cmalpass/mcp-presidio.git
cd mcp-presidio

# Build the Docker image
docker build -t mcp-presidio .

# Run the container with stdio (default)
docker run -i mcp-presidio

Using Docker Compose

# Clone the repository
git clone https://github.com/cmalpass/mcp-presidio.git
cd mcp-presidio

# Build and start the container
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the container
docker-compose down

Configuring Claude Desktop with Docker

To use the Docker container with Claude Desktop, update your claude_desktop_config.json:

{
  "mcpServers": {
    "presidio": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp-presidio:latest"
      ],
      "env": {}
    }
  }
}

Or if using a pre-built image from a registry:

{
  "mcpServers": {
    "presidio": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/cmalpass/mcp-presidio:latest"
      ],
      "env": {}
    }
  }
}

Docker Image Details

The Docker image includes:

  • Python 3.11 slim base

  • All required dependencies (mcp, presidio-analyzer, presidio-anonymizer, spacy)

  • Pre-installed English language model (en_core_web_lg)

  • Security-hardened with non-root user

  • Multi-stage build for minimal image size (~500MB)

Advanced Docker Usage

Interactive Shell for Debugging:

docker run -it mcp-presidio bash

Custom Language Models: To include additional language models, modify the Dockerfile:

# Add after the English model installation
RUN python -m spacy download es_core_news_lg  # Spanish
RUN python -m spacy download fr_core_news_lg  # French
RUN python -m spacy download de_core_news_lg  # German

Then rebuild the image:

docker build -t mcp-presidio:multilang .

Volume Mounting for Custom Configurations:

docker run -i -v $(pwd)/config:/app/config:ro mcp-presidio

Python Installation (Quick Install)

Use the interactive installation script that handles dependencies and language models:

Unix/Linux/macOS:

# Clone the repository
git clone https://github.com/cmalpass/mcp-presidio.git
cd mcp-presidio

# Run the installation script
./install.sh
# or
python install.py

Windows:

# Clone the repository
git clone https://github.com/cmalpass/mcp-presidio.git
cd mcp-presidio

# Run the installation script
install.bat
# or
python install.py

The script will:

  • Check Python version compatibility

  • Install base dependencies (mcp, presidio-analyzer, presidio-anonymizer, spacy)

  • Prompt for language model installation (English, Spanish, French, German, etc.)

  • Optionally install development dependencies

  • Verify the installation

  • Test basic functionality

Python Installation (Manual)

If you prefer manual installation:

# Clone the repository
git clone https://github.com/cmalpass/mcp-presidio.git
cd mcp-presidio

# Install the package
pip install -e .

# Download required spaCy language model (for English)
python -m spacy download en_core_web_lg

For other languages, download the appropriate spaCy model:

# Spanish
python -m spacy download es_core_news_lg

# French
python -m spacy download fr_core_news_lg

# German
python -m spacy download de_core_news_lg

Usage

Running the Server

The server runs using stdio transport, suitable for MCP clients:

mcp-presidio

Or run directly with Python:

python -m mcp_presidio.server

Configuring with Claude Desktop

Add to your Claude Desktop configuration (claude_desktop_config.json):

{
  "mcpServers": {
    "presidio": {
      "command": "python",
      "args": ["-m", "mcp_presidio.server"],
      "env": {}
    }
  }
}

Or if installed as a script:

{
  "mcpServers": {
    "presidio": {
      "command": "mcp-presidio",
      "args": [],
      "env": {}
    }
  }
}

Example Usage in LLM Conversations

Detecting PII:

User: Can you check this text for PII? "My name is John Smith and my email is john@example.com"

LLM: I'll analyze that text for PII using the analyze_text tool.
[Tool calls analyze_text with the text]

Result: Found 2 PII entities:
- PERSON: "John Smith" (confidence: 0.85)
- EMAIL_ADDRESS: "john@example.com" (confidence: 1.0)

Anonymizing Text:

User: Can you anonymize this customer feedback? "I'm Jane Doe, call me at 555-123-4567"

LLM: I'll anonymize the PII in that text.
[Tool calls anonymize_text]

Result: "I'm <PERSON>, call me at <PHONE_NUMBER>"

Working with Structured Data:

User: Check this JSON for PII: {"user": "bob@email.com", "phone": "555-0100"}

LLM: I'll analyze the structured data.
[Tool calls analyze_structured_data]

Result: Found PII in 2 fields:
- .user: EMAIL_ADDRESS
- .phone: PHONE_NUMBER

Supported PII Entity Types

The server supports 25+ PII entity types including:

  • Personal: PERSON, DATE_TIME

  • Contact: EMAIL_ADDRESS, PHONE_NUMBER, URL

  • Financial: CREDIT_CARD, IBAN_CODE, US_BANK_NUMBER, CRYPTO

  • Government IDs: US_SSN, US_PASSPORT, US_DRIVER_LICENSE, UK_NHS

  • International IDs: SG_NRIC_FIN, IN_PAN, IN_AADHAAR, AU_ABN, AU_TFN, AU_MEDICARE

  • Location: LOCATION, IP_ADDRESS

  • Medical: MEDICAL_LICENSE

  • Other: And many more country-specific identifiers

Use the get_supported_entities tool to see all available types for your language.

Anonymization Operators

The server supports multiple anonymization strategies:

  1. replace - Replace PII with placeholder text (e.g., <EMAIL_ADDRESS>)

  2. redact - Remove PII entirely from text

  3. hash - Replace with cryptographic hash (SHA-256)

  4. mask - Mask characters (e.g., ***-**-1234)

  5. encrypt - Encrypt PII with AES encryption

  6. keep - Keep PII as-is (for selective anonymization)

Advanced Features

Custom Recognizers

Add domain-specific PII patterns:

# Example: Detect custom employee IDs
add_custom_recognizer(
    name="employee_id_recognizer",
    entity_type="EMPLOYEE_ID",
    patterns=[
        {"name": "emp_pattern", "regex": "EMP-\\d{6}", "score": 0.9}
    ],
    context=["employee", "staff", "worker"]
)

Batch Processing

Process multiple documents efficiently:

# Analyze multiple texts
batch_analyze(
    texts=["Text 1...", "Text 2...", "Text 3..."],
    entities=["PERSON", "EMAIL_ADDRESS"],
    score_threshold=0.5
)

Language Support

Specify different languages:

analyze_text(
    text="Me llamo MarΓ­a GarcΓ­a",
    language="es"
)

Validation and Testing

Validate detection accuracy:

validate_detection(
    text="John lives at 123 Main St",
    expected_entities=[
        {"entity_type": "PERSON", "start": 0, "end": 4},
        {"entity_type": "LOCATION", "start": 14, "end": 27}
    ]
)
# Returns precision, recall, and F1 score

Architecture

This MCP server integrates:

  • MCP FastMCP: Provides the MCP protocol implementation

  • Presidio Analyzer: Detects PII using NLP and pattern matching

  • Presidio Anonymizer: Anonymizes detected PII with various operators

  • spaCy: Powers the NLP engine for accurate entity recognition

Security Considerations

  • All processing happens locally - no data is sent to external services

  • The server uses stdio transport for secure communication with MCP clients

  • Multiple anonymization strategies available for different privacy requirements

  • Supports compliance requirements (GDPR, HIPAA, CCPA)

  • Docker deployment provides additional isolation and security through containerization

  • Container runs as non-root user for enhanced security

Development

Running Tests

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/

Project Structure

mcp-presidio/
β”œβ”€β”€ src/
β”‚   └── mcp_presidio/
β”‚       β”œβ”€β”€ __init__.py
β”‚       └── server.py              # Main MCP server implementation
β”œβ”€β”€ tests/                         # Test suite
β”œβ”€β”€ Dockerfile                     # Docker container definition
β”œβ”€β”€ docker-compose.yml             # Docker Compose configuration
β”œβ”€β”€ docker-entrypoint.sh           # Container entrypoint script
β”œβ”€β”€ .dockerignore                  # Docker build exclusions
β”œβ”€β”€ pyproject.toml                 # Project configuration
β”œβ”€β”€ README.md                      # This file
β”œβ”€β”€ DOCKER.md                      # Detailed Docker deployment guide
└── .gitignore

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Acknowledgments

Support

For issues, questions, or contributions, please visit the GitHub repository.

Available Tools

10 tools
add_custom_recognizerA
Add a custom PII recognizer with regex patterns.

Args:
    name: Unique name for this recognizer
    entity_type: The entity type this recognizer detects
    patterns: List of pattern dicts with 'name', 'regex', and 'score' (0.0-1.0)
             Example: [{"name": "weak", "regex": "\d{3}", "score": 0.3}]
    context: Optional context words that increase confidence
    supported_language: Language code (default: "en")

Returns:
    JSON string confirming the recognizer was added

Inputs: name (required), entity_type (required), patterns (required), context, +1 more. Returns: result

analyze_structured_dataC
Analyze structured data (JSON/dict) for PII.

Args:
    data: JSON string representing structured data
    language: Language code (default: "en")
    entities: List of entity types to detect (default: all)
    score_threshold: Minimum confidence score (default: 0.0)

Returns:
    JSON string with PII findings organized by data structure path

Inputs: data (required), language, entities, score_threshold. Returns: result

analyze_textA
Analyze text to detect PII entities.

Args:
    text: The text to analyze for PII
    language: Language code (default: "en")
    entities: List of entity types to detect (default: all). Examples: PERSON, EMAIL_ADDRESS, 
             PHONE_NUMBER, CREDIT_CARD, LOCATION, DATE_TIME, etc.
    score_threshold: Minimum confidence score (0.0-1.0) for detection (default: 0.0)
    return_decision_process: Include detailed decision process in results (default: False)

Returns:
    JSON string with detected PII entities including type, location, and confidence score

Inputs: text (required), language, entities, score_threshold, +1 more. Returns: result

anonymize_structured_dataC
Anonymize PII in structured data (JSON/dict).

Args:
    data: JSON string representing structured data
    language: Language code (default: "en")
    operator: Anonymization operator (default: "replace")
    entities: List of entity types to anonymize (default: all)
    score_threshold: Minimum confidence score (default: 0.0)

Returns:
    JSON string with anonymized structured data

Inputs: data (required), language, operator, entities, +1 more. Returns: result

anonymize_textA
Anonymize PII in text using various operators.

Args:
    text: The text to anonymize
    language: Language code (default: "en")
    operator: Anonymization operator - "replace", "redact", "hash", "mask", "encrypt" (default: "replace")
    entities: List of entity types to anonymize (default: all)
    score_threshold: Minimum confidence score for detection (default: 0.0)
    operator_params: Additional parameters for the operator (e.g., {"new_value": "ANONYMIZED"})

Returns:
    JSON string with anonymized text and list of anonymized entities

Inputs: text (required), language, operator, entities, +2 more. Returns: result

batch_analyzeB
Analyze multiple texts in batch for PII detection.

Args:
    texts: List of texts to analyze
    language: Language code (default: "en")
    entities: List of entity types to detect (default: all)
    score_threshold: Minimum confidence score (default: 0.0)

Returns:
    JSON string with results for each text indexed by position

Inputs: texts (required), language, entities, score_threshold. Returns: result

batch_anonymizeB
Anonymize multiple texts in batch.

Args:
    texts: List of texts to anonymize
    language: Language code (default: "en")
    operator: Anonymization operator (default: "replace")
    entities: List of entity types to anonymize (default: all)
    score_threshold: Minimum confidence score (default: 0.0)

Returns:
    JSON string with anonymized results for each text

Inputs: texts (required), language, operator, entities, +1 more. Returns: result

get_anonymization_operatorsB
Get list of available anonymization operators and their descriptions.

Returns:
    JSON string with operator names, descriptions, and example parameters

Inputs: no named parameters. Returns: result

get_supported_entitiesA
Get list of all supported PII entity types for a language.

Args:
    language: Language code (default: "en")

Returns:
    JSON string with list of supported entity types and their descriptions

Inputs: language. Returns: result

validate_detectionA
Validate PII detection against expected results (useful for testing).

Args:
    text: The text to analyze
    expected_entities: List of expected entities with 'entity_type', 'start', 'end'
    language: Language code (default: "en")

Returns:
    JSON string with validation results including precision, recall, and F1 score

Inputs: text (required), expected_entities (required), language. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 10 tools

    Disambiguation5/5

    Every tool has a clearly distinct purpose with no ambiguity. The tools are well-organized into categories: custom recognizer management (add_custom_recognizer), analysis (analyze_text, analyze_structured_data, batch_analyze), anonymization (anonymize_text, anonymize_structured_data, batch_anonymize), metadata retrieval (get_supported_entities, get_anonymization_operators), and validation (validate_detection). Each tool serves a unique function within the PII processing workflow.

    Naming Consistency5/5

    The tool names follow a highly consistent verb_noun pattern throughout. All tools use snake_case with clear action-object naming: add_custom_recognizer, analyze_text, anonymize_structured_data, batch_analyze, get_supported_entities, validate_detection. The naming convention is perfectly uniform across all 10 tools, making them predictable and easy to understand.

    Tool Count5/5

    With 10 tools, this server is well-scoped for PII detection and anonymization. Each tool earns its place by covering essential operations: analysis (single, structured, batch), anonymization (single, structured, batch), configuration (custom recognizers), metadata (entities, operators), and validation. The count is appropriate for the domain without being overwhelming or insufficient.

    Completeness5/5

    The tool surface provides complete coverage for PII processing workflows. It includes all necessary CRUD-like operations: adding custom recognizers, analyzing text/structured data (individually and in batch), anonymizing with various operators (individually and in batch), retrieving metadata about supported entities and operators, and validating detection accuracy. There are no obvious gaps that would hinder agent workflows.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      AI-powered sensitive info detection and masking MCP server supporting 14+ types with regex, checksum, and optional LLM semantic detection, enabling flexible masking strategies like mask, replace, hash, and redact.
      6
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      MCP server for automatic detection and redaction of PII in text, with anonymization and deanonymization capabilities, all local processing.
      1
      -
    • A
      license
      A
      quality
      C
      maintenance
      An MCP server that redacts PII/PHI from text before it ever reaches an LLM β€” self-hosted, fail-closed, and HIPAA-aware.
      3
      MIT