# MCP Presidio Examples
This file contains example usage of the MCP Presidio server tools.
## Basic PII Detection
### Analyze simple text
```json
{
"tool": "analyze_text",
"arguments": {
"text": "My name is John Smith and my email is john.smith@example.com. Call me at 555-123-4567.",
"language": "en"
}
}
```
Expected output:
```json
[
{
"entity_type": "PERSON",
"start": 11,
"end": 21,
"score": 0.85,
"text": "John Smith"
},
{
"entity_type": "EMAIL_ADDRESS",
"start": 38,
"end": 61,
"score": 1.0,
"text": "john.smith@example.com"
},
{
"entity_type": "PHONE_NUMBER",
"start": 75,
"end": 87,
"score": 0.75,
"text": "555-123-4567"
}
]
```
## Text Anonymization
### Replace PII with placeholders
```json
{
"tool": "anonymize_text",
"arguments": {
"text": "Contact Sarah at sarah@company.com or 555-0100",
"operator": "replace"
}
}
```
Result:
```json
{
"anonymized_text": "Contact <PERSON> at <EMAIL_ADDRESS> or <PHONE_NUMBER>",
"entities": [
{"entity_type": "PERSON", "start": 8, "end": 13, "operator": "replace"},
{"entity_type": "EMAIL_ADDRESS", "start": 17, "end": 35, "operator": "replace"},
{"entity_type": "PHONE_NUMBER", "start": 39, "end": 47, "operator": "replace"}
]
}
```
### Mask PII
```json
{
"tool": "anonymize_text",
"arguments": {
"text": "Card number: 4111-1111-1111-1111",
"operator": "mask",
"operator_params": {
"chars_to_mask": 12,
"masking_char": "*",
"from_end": false
}
}
}
```
### Hash PII
```json
{
"tool": "anonymize_text",
"arguments": {
"text": "SSN: 123-45-6789",
"operator": "hash",
"operator_params": {
"hash_type": "sha256"
}
}
}
```
## Working with Specific Entity Types
### Detect only specific entities
```json
{
"tool": "analyze_text",
"arguments": {
"text": "User: alice@test.com, Phone: 555-1234, Location: New York",
"entities": ["EMAIL_ADDRESS", "LOCATION"]
}
}
```
### Set confidence threshold
```json
{
"tool": "analyze_text",
"arguments": {
"text": "Maybe John called from 555-1234",
"score_threshold": 0.7
}
}
```
## Structured Data Analysis
### Analyze JSON data
```json
{
"tool": "analyze_structured_data",
"arguments": {
"data": "{\"customer\": {\"name\": \"Bob Johnson\", \"email\": \"bob@example.com\", \"phone\": \"555-9876\", \"address\": \"123 Main Street\"}}"
}
}
```
Result:
```json
{
"total_fields_with_pii": 4,
"findings": [
{
"path": "customer.name",
"value": "Bob Johnson",
"entities": [{"entity_type": "PERSON", "start": 0, "end": 11, "score": 0.85, "text": "Bob Johnson"}]
},
{
"path": "customer.email",
"value": "bob@example.com",
"entities": [{"entity_type": "EMAIL_ADDRESS", "start": 0, "end": 15, "score": 1.0, "text": "bob@example.com"}]
}
]
}
```
### Anonymize JSON data
```json
{
"tool": "anonymize_structured_data",
"arguments": {
"data": "{\"user\": \"jane@test.com\", \"id\": \"EMP-12345\"}",
"operator": "replace"
}
}
```
## Batch Processing
### Analyze multiple texts
```json
{
"tool": "batch_analyze",
"arguments": {
"texts": [
"Email me at alice@example.com",
"Call Bob at 555-1234",
"Meet Jane at 10 AM"
],
"entities": ["PERSON", "EMAIL_ADDRESS", "PHONE_NUMBER"]
}
}
```
### Batch anonymization
```json
{
"tool": "batch_anonymize",
"arguments": {
"texts": [
"User 1: john@test.com",
"User 2: jane@test.com",
"User 3: bob@test.com"
],
"operator": "redact"
}
}
```
## Custom Recognizers
### Add a custom pattern for employee IDs
```json
{
"tool": "add_custom_recognizer",
"arguments": {
"name": "employee_id_recognizer",
"entity_type": "EMPLOYEE_ID",
"patterns": [
{
"name": "emp_strong",
"regex": "EMP-\\d{6}",
"score": 0.9
},
{
"name": "emp_weak",
"regex": "E\\d{4}",
"score": 0.5
}
],
"context": ["employee", "staff", "worker"],
"supported_language": "en"
}
}
```
### Use custom recognizer
```json
{
"tool": "analyze_text",
"arguments": {
"text": "Employee John (EMP-123456) submitted the report"
}
}
```
## Multi-language Support
### Spanish text
```json
{
"tool": "analyze_text",
"arguments": {
"text": "Me llamo María García y mi correo es maria@ejemplo.com",
"language": "es"
}
}
```
### French text
```json
{
"tool": "analyze_text",
"arguments": {
"text": "Je m'appelle Pierre Dupont, email: pierre@exemple.fr",
"language": "fr"
}
}
```
## Validation and Testing
### Validate detection accuracy
```json
{
"tool": "validate_detection",
"arguments": {
"text": "John Smith lives at 123 Oak Street",
"expected_entities": [
{"entity_type": "PERSON", "start": 0, "end": 10},
{"entity_type": "LOCATION", "start": 20, "end": 34}
]
}
}
```
Result:
```json
{
"metrics": {
"precision": 1.0,
"recall": 1.0,
"f1_score": 1.0,
"true_positives": 2,
"false_positives": 0,
"false_negatives": 0
},
"detected": [...],
"expected": [...],
"missing": [],
"unexpected": []
}
```
## Getting Available Options
### List supported entity types
```json
{
"tool": "get_supported_entities",
"arguments": {
"language": "en"
}
}
```
### List anonymization operators
```json
{
"tool": "get_anonymization_operators",
"arguments": {}
}
```
Result:
```json
[
{
"operator": "replace",
"description": "Replace PII with a placeholder string",
"example_params": {"new_value": "<ANONYMIZED>"}
},
{
"operator": "redact",
"description": "Remove PII entirely from text",
"example_params": {}
},
{
"operator": "hash",
"description": "Replace PII with a hash value",
"example_params": {"hash_type": "sha256"}
}
]
```