Presidio MCP Server
Enables PII detection and anonymization using Microsoft Presidio with tools, resources, and prompts via MCP.
README
Presidio MCP Server
A production-ready Model Context Protocol (MCP) server that exposes Microsoft Presidio PII detection and anonymization capabilities using FastMCP 2.x.
Features
| Primitive | Count | Description |
|---|---|---|
| 🔧 Tools | 8 | PII analysis, anonymization, batch processing, risk scoring |
| 📦 Resources | 4 | Entity catalogue, operator guide, server config, examples |
| 💬 Prompts | 4 | Audit reports, sharing workflows, HR reviews, batch checks |
Tools
| Tool | Description |
|---|---|
analyze_text |
Detect PII entities with confidence scores & character offsets |
anonymize_text |
Anonymize PII with configurable per-entity operators |
deanonymize_text |
Reverse AES-encrypted anonymization |
batch_analyze |
Analyze up to 50 texts in one call |
list_supported_entities |
Return all detectable entity types |
add_custom_recognizer |
Dynamically register regex-based recognizers at runtime |
score_pii_risk |
Compute a 0–100 PII risk score with recommendations |
list_recognizers |
List all active recognizers with metadata |
Resources (read-only reference data)
| URI | Description |
|---|---|
presidio://entities/catalogue |
All supported PII types grouped by category |
presidio://operators/guide |
Anonymization operator reference with examples |
presidio://config/server |
Live server configuration snapshot |
presidio://examples/common |
Ready-to-use usage examples |
Prompts (reusable workflow templates)
| Prompt | Use case |
|---|---|
pii_audit_report |
Generate a compliance-ready PII audit report |
anonymize_for_sharing |
Anonymize a document before external sharing |
hr_data_privacy_review |
HR-specific PII review and anonymization |
batch_pii_policy_check |
Run policy compliance checks across record batches |
HR-Domain Custom Recognizers
Beyond Presidio's built-in NLP, this server includes custom recognizers for:
- EMPLOYEE_ID —
EMP-XXXXXXpatterns - SALARY — Currency amounts in USD/GBP/EUR + k-notation
- UK_NINO — UK National Insurance Numbers
- US_SSN — US Social Security Numbers (improved patterns)
- BANK_ACCOUNT — UK sort codes + IBAN prefixes
- PASSPORT — US and UK passport number formats
Project Structure
mcp-server/
├── presidio_mcp/
│ ├── __init__.py # Package metadata
│ ├── __main__.py # Module entry point (python -m presidio_mcp)
│ ├── server.py # FastMCP server — tools, resources, prompts
│ ├── engines.py # Singleton Presidio engine initialization
│ ├── models.py # Pydantic input/output models
│ └── recognizers.py # HR-domain custom recognizers
├── tests/
│ └── test_presidio_mcp.py # Comprehensive test suite
├── pyproject.toml # Project config & dependencies
├── requirements.txt # pip-installable dependencies
└── README.md
Setup & Installation
1. Prerequisites
- Python 3.10+
- pip or uv (recommended)
2. Create virtual environment
cd mcp-server
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
3. Install dependencies
# Production
pip install -r requirements.txt
# Or with dev tools (testing, linting):
pip install -e ".[dev]"
4. Download the spaCy NLP model
# Recommended (higher accuracy, ~741MB):
python -m spacy download en_core_web_lg
# Lightweight fallback (~12MB, auto-used if lg is missing):
python -m spacy download en_core_web_sm
Running the Server
stdio transport (Claude Desktop, Cursor, Continue)
python -m presidio_mcp
# or
presidio-mcp
HTTP/SSE transport (remote clients, testing)
python -m presidio_mcp --transport sse --host 0.0.0.0 --port 8001
Claude Desktop Integration
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"presidio": {
"command": "/path/to/mcp-server/.venv/bin/python",
"args": ["-m", "presidio_mcp"],
"cwd": "/path/to/mcp-server"
}
}
}
Running Tests
pytest tests/ -v
Test coverage includes:
- All 8 tools (happy paths + edge cases)
- All 4 resources (JSON validity, content checks)
- All 4 prompts (message structure, keyword presence)
- Validation errors (blank text, boundary scores)
- Multi-language support
Anonymization Operators Quick Reference
| Operator | Reversible | Best For |
|---|---|---|
replace |
✗ | General de-identification |
redact |
✗ | Complete removal |
mask |
✗ | Partial masking (credit cards) |
hash |
✗ | Consistent pseudonymization |
encrypt |
✅ | Reversible by authorised parties |
Example Usage (via LLM)
Analyze HR document:
Use analyze_text with:
text: "New hire John Smith (EMP-001234), SSN 123-45-6789, salary $95,000"
entities: ["PERSON", "EMPLOYEE_ID", "US_SSN", "SALARY"]
Anonymize for sharing:
Use anonymize_text with:
text: "Contact Alice at alice@corp.com, card: 4111-1111-1111-1111"
operators:
- entity_type: EMAIL_ADDRESS, operator: replace
- entity_type: CREDIT_CARD, operator: mask, chars_to_mask: 12
Risk-score a document:
Use score_pii_risk with:
text: "Full employee record with SSN, bank account, and salary details"
Architecture Decisions
| Decision | Rationale |
|---|---|
| Singleton engines | Presidio engine init is expensive (~2-5s). One instance per process. |
| Pydantic models as tool params | FastMCP uses model schemas for LLM tool descriptions + strict validation |
| Graceful spaCy fallback | Auto-falls back to en_core_web_sm if en_core_web_lg is missing |
readOnlyHint annotations |
Read-only tools skip confirmation prompts in MCP clients |
| Thread-safe double-checked locking | Engines are safe for concurrent asyncio tool calls |
| stderr for logs | MCP stdio protocol uses stdout; logs go to stderr to avoid interference |
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。