Skip to main content

MCP server for CloakLLM — PII cloaking tools for Claude Desktop

Project description

CloakLLM MCP Server

MCP server that wraps CloakLLM's Python SDK as tools for Claude Desktop and other MCP-compatible clients.

Important: MCP does not protect your initial prompt. MCP tools are called by the LLM — your prompt is sent to the LLM provider first, then the LLM decides to invoke tools. This means the raw prompt (including any PII) reaches the provider before CloakLLM can sanitize it. The MCP server is useful for sanitizing data that the LLM processes during a conversation (documents, files, tool outputs), but it cannot prevent your prompt from reaching the provider.

To protect prompts before they leave your infrastructure, use the SDK middleware instead:

  • Python: enable_openai(client) or cloakllm.enable() (LiteLLM)
  • JavaScript: cloakllm.enable(client)

Tools

Tool Description
sanitize Detect & cloak PII, return sanitized text + token map ID + entity_details. Pass mode: "redact" for irreversible PII removal (no token_map_id returned).
desanitize Restore original values using a token map ID
analyze Detect PII without cloaking (pure analysis)

Install

cd cloakllm-mcp
pip install -e .

Claude Desktop Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "cloakllm": {
      "command": "python",
      "args": ["/path/to/cloakllm-mcp/server.py"],
      "env": {
        "CLOAKLLM_LOG_DIR": "./cloakllm_audit",
        "CLOAKLLM_LLM_DETECTION": "false"
      }
    }
  }
}

Or using uvx:

{
  "mcpServers": {
    "cloakllm": {
      "command": "uvx",
      "args": ["mcp", "run", "/path/to/cloakllm-mcp/server.py"]
    }
  }
}

Usage Examples

Sanitize text before sending to an LLM

Tool call: sanitize

{
  "text": "Email john@acme.com about the meeting with Sarah Johnson at 742 Evergreen Terrace",
  "model": "claude-sonnet-4-20250514",
  "token_map_id": "optional-id-for-multi-turn"
}

Multi-turn: Pass the token_map_id from a previous sanitize response to reuse the same token map across conversation turns. The same PII will always map to the same token.

Response:

{
  "sanitized": "Email [EMAIL_0] about the meeting with [PERSON_0] at 742 Evergreen Terrace",
  "token_map_id": "a1b2c3d4-...",
  "entity_count": 2,
  "categories": {"EMAIL": 1, "PERSON": 1},
  "entity_details": [
    {"category": "EMAIL", "start": 6, "end": 19, "length": 13, "confidence": 0.95, "source": "regex", "token": "[EMAIL_0]"},
    {"category": "PERSON", "start": 42, "end": 56, "length": 14, "confidence": 0.85, "source": "spacy", "token": "[PERSON_0]"}
  ]
}

Restore original values

Tool call: desanitize

{
  "text": "I've drafted an email to [EMAIL_0] regarding [PERSON_0]'s request.",
  "token_map_id": "a1b2c3d4-..."
}

Response:

{
  "restored": "I've drafted an email to john@acme.com regarding Sarah Johnson's request."
}

Analyze text for PII (no cloaking)

Tool call: analyze

{
  "text": "Contact john@acme.com, SSN 123-45-6789"
}

Response:

{
  "entity_count": 2,
  "entities": [
    {"text": "john@acme.com", "category": "EMAIL", "start": 8, "end": 21, "confidence": 0.95, "source": "regex"},
    {"text": "123-45-6789", "category": "SSN", "start": 27, "end": 38, "confidence": 0.95, "source": "regex"}
  ]
}

Environment Variables

Variable Default Description
CLOAKLLM_LOG_DIR ./cloakllm_audit Audit log directory
CLOAKLLM_AUDIT_ENABLED true Enable/disable audit logging
CLOAKLLM_SPACY_MODEL en_core_web_sm spaCy model for NER
CLOAKLLM_LLM_DETECTION false Enable LLM-based detection
CLOAKLLM_LLM_MODEL llama3.2 Ollama model for LLM detection
CLOAKLLM_OLLAMA_URL http://localhost:11434 Ollama endpoint

Testing

# Test with MCP inspector
python -m mcp dev server.py

# Or run directly
python server.py

See Also

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloakllm_mcp-0.6.3.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloakllm_mcp-0.6.3-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file cloakllm_mcp-0.6.3.tar.gz.

File metadata

  • Download URL: cloakllm_mcp-0.6.3.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cloakllm_mcp-0.6.3.tar.gz
Algorithm Hash digest
SHA256 452760f46f808cfe9ea56ae30658f42c99ec9190679d3bd9413f4433ac9e0aaa
MD5 35ec046f9539e6c0fba08a04a507cecf
BLAKE2b-256 a313db0f0f2065d8c3ff76ffb7129a7a61966968cc2645e1718a336af3ad67aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloakllm_mcp-0.6.3.tar.gz:

Publisher: publish.yml on cloakllm/cloakllm-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cloakllm_mcp-0.6.3-py3-none-any.whl.

File metadata

  • Download URL: cloakllm_mcp-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cloakllm_mcp-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5c2ffdf589a1f78a236449edd509a94d1305d53222f9ca6e53a8cfbc4258dd05
MD5 2ef27052760236db8eacfa2aa513691d
BLAKE2b-256 8886a88a83140f81cbb6420627dc2bcb719b41b4a555b996887015458bf5f3e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloakllm_mcp-0.6.3-py3-none-any.whl:

Publisher: publish.yml on cloakllm/cloakllm-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page