CloakLLM MCP Server
CloakLLM MCP 服务器
MCP 服务器,将 CloakLLM 的 Python SDK 封装为 Claude Desktop 和其他兼容 MCP 的客户端的工具。
重要提示:MCP 无法保护您的初始提示词。 MCP 工具是由 LLM 调用 的——您的提示词会先发送给 LLM 提供商,然后由 LLM 决定是否调用工具。这意味着原始提示词(包括任何 PII)在 CloakLLM 对其进行脱敏之前就已经到达了提供商处。该 MCP 服务器适用于对 LLM 在对话过程中处理的数据(文档、文件、工具输出)进行脱敏,但它无法阻止您的提示词到达提供商。
若要在提示词离开您的基础设施之前对其进行保护,请改用 SDK 中间件:
Python:
enable_openai(client)或cloakllm.enable()(LiteLLM)JavaScript:
cloakllm.enable(client)
工具
工具 | 描述 |
| 检测并掩码处理 PII,返回脱敏后的文本 + 令牌映射 ID + entity_details。传入 |
| 使用令牌映射 ID 还原原始值 |
| 检测 PII 而不进行掩码处理(纯分析) |
Related MCP server: Presidio MCP Server
安装
cd cloakllm-mcp
pip install -e .Claude Desktop 配置
添加到您的 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"
}
}
}
}或者使用 uvx:
{
"mcpServers": {
"cloakllm": {
"command": "uvx",
"args": ["mcp", "run", "/path/to/cloakllm-mcp/server.py"]
}
}
}使用示例
在发送给 LLM 之前对文本进行脱敏
工具调用: 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"
}多轮对话: 传入来自先前
sanitize响应的token_map_id,以便在对话轮次中重复使用相同的令牌映射。相同的 PII 将始终映射到相同的令牌。
响应:
{
"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]"}
]
}还原原始值
工具调用: desanitize
{
"text": "I've drafted an email to [EMAIL_0] regarding [PERSON_0]'s request.",
"token_map_id": "a1b2c3d4-..."
}响应:
{
"restored": "I've drafted an email to john@acme.com regarding Sarah Johnson's request."
}分析文本中的 PII(不进行掩码处理)
工具调用: analyze
{
"text": "Contact john@acme.com, SSN 123-45-6789"
}响应:
{
"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"}
]
}环境变量
变量 | 默认值 | 描述 |
|
| 审计日志目录 |
|
| 启用/禁用审计日志 |
|
| 用于 NER 的 spaCy 模型 |
|
| 启用基于 LLM 的检测 |
|
| 用于 LLM 检测的 Ollama 模型 |
|
| Ollama 端点 |
测试
# Test with MCP inspector
python -m mcp dev server.py
# Or run directly
python server.py另请参阅
CloakLLM Hub — 项目概览、架构和链接
CloakLLM Python SDK — 带有 spaCy NER + OpenAI / LiteLLM 中间件的 Python 库
CloakLLM JS SDK — 带有 OpenAI + Vercel AI 中间件的 JavaScript 库
许可证
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Scan prompts for injection attacks, redact PII, and audit LLM SDK usage from any MCP client
Detect and redact PII and secrets before text reaches an LLM, with reversible placeholders.
Detect and redact PII and secrets (API keys, tokens) in text, HTML or PDF before it reaches an LLM.
Security & DLP proxy for MCP: tool-poisoning scans, PII redaction on tool args/results. Beta.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides prompt injection detection, PII/secrets redaction, and an audit trail for AI agents via MCP tools.4MIT
- AlicenseNot gradedqualityDmaintenanceEnables PII detection and anonymization using Microsoft Presidio with tools, resources, and prompts via MCP.MIT
- AlicenseAqualityBmaintenanceLocal pseudonymisation MCP server that detects PII in text, replaces it with opaque tokens before sending to cloud LLMs, and restores tokens afterward.273 npm2MIT
- AlicenseNot gradedqualityDmaintenanceProvides MCP tools for prompt injection detection and content sanitization, safeguarding LLM pipelines. Also enables Japanese PII scanning and masking for secure data handling.MIT