Documentation
MCP Server, REST API, and SDK integration guides for anonym.legal and cloak.business
MCP Server Setup
NPM: @anthropic-ai/mcp-server-anonym-legal · 7 tools · REST API under the hood
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"anonymize": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-server-anonym-legal"],
"env": { "ANONYM_LEGAL_API_KEY": "your-api-key" }
}
}
}
macOS: ~/Library/Application Support/Claude/claude_desktop_config.jsonWindows: %APPDATA%\Claude\claude_desktop_config.json
Cursor IDE
Add to Cursor MCP settings (Settings › Features › MCP):
{
"mcpServers": {
"anonymize": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-server-anonym-legal"],
"env": { "ANONYM_LEGAL_API_KEY": "your-api-key" }
}
}
}
7 MCP Tools
| Tool | Description |
|---|---|
anonymize_text | Anonymize text — replace, redact, hash, encrypt, mask, or keep per entity |
analyze_text | Detect PII entities — returns positions, types, and confidence scores |
detokenize_text | Restore original values from session tokens |
get_balance | Check remaining token balance |
estimate_cost | Estimate token cost before calling anonymize_text |
list_sessions | List active anonymization sessions |
delete_session | Delete a session — GDPR Art. 17 erasure |
Environment Variables
| Variable | Required | Description |
|---|---|---|
ANONYM_LEGAL_API_KEY | Yes | API key from anonym.legal |
ANONYM_METHOD | No | Default: replace. Options: replace, redact, hash, encrypt, mask, keep |
ANONYM_LANGUAGE | No | Default: auto. ISO 639-1 language code |
REST API
anonym.legal REST API — no SDK required, direct HTTP integration
Base URL
https://api.anonym.legal/v1
Authentication
Include your API key in the Authorization header:
Authorization: Bearer your-api-key
POST/anonymize
Anonymize text and detect PII entities.
Request Body
{
"text": "John Smith's email is john@example.com",
"method": "replace",
"language": "en",
"entities": ["PERSON", "EMAIL_ADDRESS"]
}
Response
{
"anonymized": "Max Mueller's email is max.mueller@example.de",
"entities": [{ "type": "PERSON", "original": "John Smith", "start": 0, "end": 10 }],
"tokens_used": 2
}
POST/detokenize
Restore original values from session tokens.
{ "text": "enc_xK9mP2... email is enc_jL7nQ4...", "session_id": "abc123" }
Code Examples
anonym.legal REST API — Python, JavaScript, cURL
Python (requests)
import requests
API_KEY = "your-api-key"
BASE_URL = "https://api.anonym.legal/v1"
def anonymize(text, method="replace"):
response = requests.post(
f"{BASE_URL}/anonymize",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"text": text, "method": method}
)
return response.json()
result = anonymize("Contact John at john@example.com")
print(result["anonymized"])
# → "Contact Max Mueller at max.mueller@example.de"
JavaScript / Node.js
const BASE_URL = 'https://api.anonym.legal/v1';
const API_KEY = 'your-api-key';
const result = await fetch(`${BASE_URL}/anonymize`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ text: 'Contact John at john@example.com', method: 'replace' })
}).then(r => r.json());
console.log(result.anonymized);
// → "Contact Max Mueller at max.mueller@example.de"
cURL
curl -X POST https://api.anonym.legal/v1/anonymize \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{"text":"Contact John at john@example.com","method":"replace"}'
Anonymization Methods
Choose the right method for your use case
replace
Default
Replaces PII with realistic fake data. Maintains document readability.
"John Smith" → "Max Mueller"
redact
Completely removes PII. Irreversible but maximum privacy.
"john@example.com" → "[REDACTED]"
hash
SHA-256
One-way cryptographic hash. Consistent pseudonymization.
"555-0123" → "a7f3c9d2..."
encrypt
AES-256-GCM
Military-grade encryption. Fully reversible with the correct key.
"DE89370400..." → "enc_xK9mP2..."
mask
Partial visibility with masked characters. Shows structure.
"4532-1234-5678-9012" → "4532-****-****-9012"
Need help?
Our team is ready to help you integrate Anonymize.dev into your workflow.