Skip to main content
Glama

Why This Exists

AI doesn't have a compliance layer. Not really.

Every time an LLM reads a document, processes customer data, or generates a summary, PII can leak through unnoticed. Governance today is an afterthought: bolted on at the end, enforced by policy documents nobody reads, and dependent on humans catching what machines miss. If you've spent any time in GRC, you know how that story ends.

AnonyMCP embeds governance directly into the AI workflow as a composable MCP server. Instead of asking "did we redact that?" after the fact, every piece of text becomes classifiable, auditable, and protectable before it ever reaches a model.

This is not just a PII scrubber. It's a policy-driven governance engine with configurable sensitivity levels, operator rules, real-time alerting, and a full audit trail. Compliance teams, legal, and engineering can finally look at the same config file and agree on what's happening.

The goal is simple: make responsible data handling the path of least resistance.

Why an MCP layer?

PII libraries exist. Presidio itself is solid. But a library sitting in a repo doesn't help when your AI stack is five services, three teams, and a RAG pipeline that nobody fully understands. MCP gives you a single governance checkpoint that any AI workflow can call without custom integration. Claude Desktop, LangChain agents, internal tools, whatever speaks MCP can use it. You don't modify your existing code. You add a tool call.

That composability is the point. Instead of every team writing their own PII handling (or more likely, not writing it), governance becomes a shared service with one policy file, one audit trail, and one place to answer the question "what happened to that data?"

Use Cases

  • Pre-LLM screening - Strip PII from user input before it hits the model context window

  • Post-LLM filtering - Catch PII the model leaks in generated responses

  • RAG pipeline governance - Classify and redact retrieved documents by sensitivity level

  • CI/CD gate - Scan prompt templates for hardcoded PII before deployment

  • Regulatory evidence - Export audit logs as compliance artifacts instead of writing policy docs nobody reads

See Real-World Scenarios below for detailed walkthroughs of how enterprises would actually deploy this.


Related MCP server: Security Guard MCP

Features

  • Detect - Identify 50+ PII entity types (emails, SSNs, credit cards, names, medical records, etc.) with confidence scores

  • Anonymize - Replace, redact, mask, hash, or encrypt PII using configurable per-entity operators

  • Classify - Categorize text as PUBLIC / INTERNAL / CONFIDENTIAL / RESTRICTED

  • Audit - Structured logging of every governance action with exporters (JSONL file, stdout, webhook)

  • Policy-driven - YAML-based governance policies with per-entity operator rules and alerting thresholds

  • MCP-native - Works with any MCP client: Claude Desktop, custom agents, RAG pipelines, or your own tooling


Architecture


Quick Start (Local / Dev)

Prerequisites

  • Python 3.11+

  • uv (recommended) or pip

Install

git clone https://github.com/frankkyazze9/anonymcp.git
cd anonymcp
uv sync          # installs all deps including the spaCy model

Explore the CLI

anonymcp --help

HTTP Server (for pipelines and integrations)

# Start the server
anonymcp --transport streamable-http --port 8100

# Verify it's running
curl http://localhost:8100/health
# → {"status":"ok","policy":"default","policy_version":"1.0"}

Claude Desktop (for prototyping)

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "anonymcp": {
      "command": "uv",
      "args": ["--directory", "/path/to/anonymcp", "run", "anonymcp"]
    }
  }
}

Restart Claude Desktop. You'll see 6 new tools.


Real-World Scenarios

These aren't hypothetical. These are the kinds of deployments AnonyMCP was designed for.

Health Insurance Support Chatbot

A mid-size health insurer has a customer support chatbot built on an LLM. Members type in messages like "my claim for procedure code 99213 was denied, my SSN is 452-29-1098 and my member ID is HX-8827431, can you check the status?" The chatbot feeds that into a RAG pipeline that pulls from claims databases and policy documents.

The problem. Their compliance team flagged that raw member messages, with SSNs, diagnosis codes, and member IDs, were hitting the LLM context window unredacted. Under HIPAA, that's a reportable exposure if the LLM provider ever logged or retained inputs. The legal team wanted evidence that PII was being stripped before model inference, not after.

The implementation. AnonyMCP runs as a sidecar in their Kubernetes cluster using streamable-http with mTLS (their infra already uses cert-based service mesh auth). The LangChain orchestration layer gets a new step before the LLM call: it sends the raw user message to scan_and_protect. The response comes back with the SSN redacted, the member ID replaced with a placeholder, and a classification of CONFIDENTIAL. The LLM sees clean text. The orchestration layer separately uses the original member ID to query the claims database, so the lookup still works.

The pipeline agent gets a read-role API key. The compliance team gets an admin-role key and runs a weekly script calling get_audit_log filtered to classification=CONFIDENTIAL to produce evidence for their HIPAA compliance binder.

A corporate legal department at a manufacturing company uses an internal AI tool to summarize contracts, employment agreements, and litigation documents. Lawyers upload PDFs, the system extracts text, and an LLM generates clause summaries and risk flags. About 40 attorneys and paralegals use it daily.

The problem. Employment agreements contain employee names, salaries, home addresses, and sometimes medical accommodation details. Litigation docs contain witness names, deposition content, and financial figures under NDA. The General Counsel doesn't want any of that flowing to even an internally-hosted LLM without classification and a record of what was processed. They also need different handling based on sensitivity: public contract boilerplate can go straight through, but employee health information needs full redaction.

The implementation. AnonyMCP runs as a Docker Compose service on the legal team's internal server. No TLS needed since it's on 127.0.0.1 behind the company VPN, but they enable API key auth because the server hosts other services. The document pipeline calls classify_sensitivity first on each extracted text chunk. Chunks classified as PUBLIC or INTERNAL pass through to the LLM as-is. CONFIDENTIAL chunks go through anonymize_text, which replaces names and masks financial figures. RESTRICTED chunks (containing medical accommodations, for example) get fully blocked: entity types are logged but the text never reaches the model.

The YAML policy file is co-authored by legal and IT. Legal defines which entity types map to which sensitivity tiers (they added SALARY and MEDICAL_CONDITION to the HIGH list). IT manages the deployment. When the policy changes, legal edits the YAML, IT rolls the deployment, and the audit log captures the policy change event with old and new version numbers.

CRM Platform with AI-Generated Sales Insights

A B2B SaaS company sells a CRM platform. They've shipped an "AI Insights" feature: the system analyzes call transcripts, email threads, and deal notes, then generates deal risk scores, next-step recommendations, and sentiment summaries. The feature uses an external LLM API.

The problem. Their CRM data contains PII from their customers' customers: the end contacts in the CRM. Names, phone numbers, email addresses, and sometimes notes like "spoke with CFO, he mentioned his wife's health issues are affecting the timeline." Enterprise prospects (banks, healthcare companies) are asking pointed questions during security reviews: "Does our CRM data get sent to a third-party LLM? What PII controls are in place? Can you prove it?" Without concrete answers, deals are stalling.

The implementation. AnonyMCP runs as a shared service in their AWS infrastructure behind an Application Load Balancer. TLS terminates at the ALB, mTLS between the ALB and AnonyMCP instances. Two replicas for availability. Every time the AI Insights feature processes a CRM record, the text passes through scan_and_protect before leaving their infrastructure for the external LLM API. The governance policy is tuned for their use case: PERSON and PHONE_NUMBER get replaced with generic tokens, EMAIL_ADDRESS gets masked, and anything health-related gets fully redacted. The LLM still gets enough context to generate useful insights ("spoke with CFO, [REDACTED] are affecting the timeline" is enough to flag a deal risk) but the actual PII never crosses the wire to the third-party provider.

The business unlock is the audit trail. When an enterprise prospect's security team sends their vendor questionnaire asking "describe your data handling for AI features," the product team points to the actual audit log showing every LLM call was pre-processed through a governance layer, with entity counts, classification levels, and policy versions. That turns a three-week security review into a check-the-box exercise. They also surface a lightweight version of the audit data in-app, a dashboard showing CRM admins how many PII entities were detected and anonymized across their account, which becomes a selling point rather than a liability.


Enterprise Deployment

Let's be honest: production AI governance doesn't run on Claude Desktop. Here's how AnonyMCP fits into real infrastructure.

HTTP Service (Most Common)

Run AnonyMCP as a standalone HTTP service. Your AI orchestration layer (LangChain, LlamaIndex, custom pipelines, whatever) calls it over the network like any other microservice.

# With TLS and auth (production)
ANONYMCP_TRANSPORT=streamable-http \
ANONYMCP_TLS_CERTFILE=/etc/ssl/certs/anonymcp.pem \
ANONYMCP_TLS_KEYFILE=/etc/ssl/private/anonymcp-key.pem \
ANONYMCP_REQUIRE_AUTH=true \
ANONYMCP_API_KEYS=your-secret-key \
uv run anonymcp

# Docker
cd docker && docker compose up --build

It's a stateless HTTP server, so horizontal scaling is straightforward. Put it behind your load balancer or service mesh and point your MCP client SDK at https://anonymcp-service:8100/mcp.

Kubernetes / Helm

Deploy as a sidecar or standalone service in your cluster:

# k8s deployment (simplified)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: anonymcp
spec:
  replicas: 2
  template:
    spec:
      containers:
        - name: anonymcp
          image: anonymcp:latest
          ports:
            - containerPort: 8100
          env:
            - name: ANONYMCP_TRANSPORT
              value: "streamable-http"
            - name: ANONYMCP_POLICY_PATH
              value: "/config/policy.yaml"
          volumeMounts:
            - name: policy-config
              mountPath: /config
      volumes:
        - name: policy-config
          configMap:
            name: anonymcp-policy

Store your governance policy in a ConfigMap or Secret. When the policy changes, roll the deployment. Hot-swap via the manage_policy tool works too, but GitOps is cleaner for audit purposes.

Python SDK Integration

If MCP feels like overkill for your use case, you can import the engine directly:

from anonymcp.engine.detector import TextDetector
from anonymcp.engine.anonymizer import TextAnonymizer
from anonymcp.engine.classifier import TextClassifier
from anonymcp.policy.engine import PolicyEngine

policy_engine = PolicyEngine.from_file("policies/default.yaml")
detector = TextDetector()
anonymizer = TextAnonymizer(policy=policy_engine.policy)
classifier = TextClassifier(policy_engine=policy_engine)

# Use in your pipeline
result = detector.detect("Customer SSN is 219-09-9999")
protected = anonymizer.anonymize(result.raw_results)

This is useful when you're embedding governance checks inside existing Python services and don't need the MCP protocol layer.

CI/CD Pipeline Gate

Run AnonyMCP as a pre-deployment check to scan prompts, templates, or LLM outputs before they ship:

# In your CI pipeline
echo "$PROMPT_TEMPLATE" | uv run python -c "
from anonymcp.engine.detector import TextDetector
import sys
detector = TextDetector()
result = detector.detect(sys.stdin.read())
if result.entities_found > 0:
    print(f'BLOCKED: {result.entities_found} PII entities found')
    sys.exit(1)
print('CLEAN')
"

Security

A governance tool that sends PII in plaintext over the network is worse than useless. It's a liability. AnonyMCP ships with TLS and API key authentication built in so the defaults are secure and any gaps are the implementor's config problem, not ours.

TLS (Transport Encryption)

Provide cert and key paths. AnonyMCP configures HTTPS automatically via uvicorn:

ANONYMCP_TRANSPORT=streamable-http \
ANONYMCP_TLS_CERTFILE=/etc/ssl/certs/anonymcp.pem \
ANONYMCP_TLS_KEYFILE=/etc/ssl/private/anonymcp-key.pem \
uv run anonymcp

If you bind to a network interface (0.0.0.0) without TLS configured, AnonyMCP logs a warning. Localhost-only deployments (127.0.0.1) skip the warning since the traffic never leaves the box.

Mutual TLS (mTLS)

For zero-trust environments where you need to verify the client too:

ANONYMCP_TLS_CA_CERTS=/etc/ssl/certs/client-ca.pem

This enables client certificate verification. Only clients presenting a cert signed by your CA can connect.

API Key Authentication

TLS encrypts the wire. Auth controls who gets in:

ANONYMCP_REQUIRE_AUTH=true
ANONYMCP_API_KEYS=pipeline-key:read,admin-key:admin

Every HTTP request must include Authorization: Bearer <key>. Keys are compared in constant time to prevent timing attacks. Missing or invalid keys get a 401/403 and a warning in the audit log.

Role-Based Access Control

Each API key is assigned a role that controls which tools it can call:

Role

Tools

Use Case

read

analyze_text, anonymize_text, classify_sensitivity, scan_and_protect

Pipeline agents, application integrations

admin

All tools including get_audit_log and manage_policy

Security team, CI/CD, ops tooling

Keys without a role suffix (e.g. my-key instead of my-key:read) default to admin for backward compatibility. stdio transport (Claude Desktop) always runs as admin since it's a local single-user context.

Security Model Summary

Layer

What It Does

Config

TLS

Encrypts data in transit

ANONYMCP_TLS_CERTFILE, ANONYMCP_TLS_KEYFILE

mTLS

Verifies client identity via certs

ANONYMCP_TLS_CA_CERTS

API Keys

Application-level access control

ANONYMCP_REQUIRE_AUTH, ANONYMCP_API_KEYS

RBAC

Per-key role scoping (read vs admin)

Role tag in ANONYMCP_API_KEYS

Policy Engine

Controls what gets redacted and how

ANONYMCP_POLICY_PATH

Audit Log

Records every governance action

ANONYMCP_AUDIT_ENABLED

stdio transport (Claude Desktop, local dev) does not need any of this because traffic never hits the network.

For the full threat model, hardening guide, and known limitations, see SECURITY.md.


MCP Tools

Tool

Description

analyze_text

Detect and locate PII entities with confidence scores

anonymize_text

Anonymize PII using configurable operators (replace, redact, mask, hash, encrypt)

classify_sensitivity

Classify text as PUBLIC / INTERNAL / CONFIDENTIAL / RESTRICTED

scan_and_protect

Full detect, classify, anonymize pipeline in one call

get_audit_log

Query audit records with filters (action, classification, time range)

manage_policy

View, list entity types, or hot-swap the active governance policy


Governance Policies

Policies are YAML files that control how AnonyMCP classifies, anonymizes, and alerts. See policies/default.yaml for the full schema.

entity_sensitivity:
  HIGH: [US_SSN, CREDIT_CARD, IBAN_CODE, US_BANK_NUMBER]
  MEDIUM: [EMAIL_ADDRESS, PHONE_NUMBER, PERSON, US_PASSPORT]
  LOW: [URL, DATE_TIME, IP_ADDRESS]

anonymization:
  HIGH:
    operator: redact
  MEDIUM:
    operator: replace
    params:
      new_value: "[{entity_type}]"
  LOW:
    operator: mask
    params:
      masking_char: "*"
      chars_to_mask: 4
      from_end: false

Configuration

Variable

Default

Description

ANONYMCP_TRANSPORT

stdio

stdio or streamable-http

ANONYMCP_POLICY_PATH

./policies/default.yaml

Path to governance policy

ANONYMCP_SCORE_THRESHOLD

0.4

Minimum PII detection confidence

ANONYMCP_AUDIT_ENABLED

true

Enable audit logging

ANONYMCP_HOST

0.0.0.0

HTTP server bind address

ANONYMCP_PORT

8100

HTTP server port

ANONYMCP_TLS_CERTFILE

none

Path to TLS certificate (enables HTTPS)

ANONYMCP_TLS_KEYFILE

none

Path to TLS private key

ANONYMCP_TLS_CA_CERTS

none

CA certs for mutual TLS (client verification)

ANONYMCP_REQUIRE_AUTH

false

Require API key for HTTP requests

ANONYMCP_API_KEYS

none

Comma-separated valid API keys


Who Is This For?

Every detection, classification, and anonymization action gets logged with timestamps, entity types, classification levels, and policy versions. That's your evidence trail. Governance policies are defined in human-readable YAML, so legal can review and approve the rules without asking engineering to translate. Classification levels (PUBLIC through RESTRICTED) map directly to standard data classification frameworks you're already using for GDPR, HIPAA, and PCI-DSS.

For CISOs and Security Leaders

AnonyMCP is a security control that sits in the data path and enforces sensitivity policies before data reaches LLMs or downstream systems. Alerting rules trigger on high-severity classifications or entity count thresholds and push to your existing incident response via webhooks. Fully self-hosted. No data leaves your infrastructure. The policy engine supports hot-swapping, so governance rules update without service restarts.

For Privacy Engineers and Developers

Drop-in MCP server you can wire into any AI workflow in minutes. Wraps Microsoft Presidio (the industry-standard NLP-based PII engine) behind a clean tool interface with six composable operations. Use scan_and_protect for a one-call pipeline, or chain analyze_text then classify_sensitivity then anonymize_text for granular control. Custom recognizers, per-entity operator overrides, and YAML policy files give you full flexibility without touching core code.


Development

# Install dev dependencies
uv sync --dev

# Run tests (67 tests)
uv run pytest tests/ -v

# Lint
uv run ruff check src/ tests/

# Type check
uv run mypy src/anonymcp/

Roadmap

  • Multi-language PII detection

  • Image and document PII redaction (OCR pipeline)

  • Structured data scanning (JSON, CSV, databases)

  • Compliance preset policies (HIPAA, PCI-DSS, GDPR)

  • Prometheus metrics and OpenTelemetry exporter

  • Custom recognizer plugin system

  • Web dashboard for audit log visualization

  • Batch processing mode for large document sets


Contributing

Contributions welcome. Open an issue first to discuss what you'd like to change. See CONTRIBUTING.md for guidelines.

License

Apache 2.0. See LICENSE.


Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP proxy that pseudo-anonymizes PII before data reaches external AI providers like Claude, ChatGPT, or Gemini.
      18
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables secure interaction between LLMs and MCP tools by applying zero-trust security controls, including sensitive data masking, file system protection, and policy enforcement.
      MIT
    • 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