MCP Server
The PII Firewall MCP Server integrates directly with Claude Desktop and AI agent pipelines, providing privacy protection as a native tool.
What is MCP?
Model Context Protocol (MCP) is an open standard by Anthropic that allows AI models to use external tools. The PII Firewall MCP Server exposes 9 tools that Claude can call automatically.
Available Tools
| Tool | Category | Description |
|---|---|---|
detect_pii | Detection | Detect PII types and locations in text |
mask_pii | Masking | Mask PII and return a token map |
restore_pii | Restore | Restore a single masked token |
restore_all | Restore | Restore all tokens in a response |
detect_injection | Security | Detect prompt injection attempts |
detect_all_injections | Security | Detect SQL injection + prompt injection simultaneously (composite attack detection) |
rag_ingest | Secure RAG | Tokenize PII in documents and split into RAG chunks safely |
rag_resolve | Secure RAG | Restore PII tokens in RAG search results |
store_status | Management | Check session and credit status |
API Key Detection — All Major AI Providers
mask_pii automatically detects and masks API keys from all major AI providers.
| Provider | Key Format |
|---|---|
| Anthropic (Claude) | sk-ant-api03-... |
| OpenAI (ChatGPT) | sk-proj-... / sk-... |
| Google AI (Gemini) | AIzaSy... |
| Hugging Face | hf_... |
| Groq | gsk_... |
| Perplexity | pplx-... |
| Replicate | r8_... |
| AWS Bedrock | AKIA... |
| GitHub | ghp_... / ghs_... |
| Stripe | sk_live_... / sk_test_... |
No matter which AI you use, your API keys stay protected.
Installation
Claude Desktop
- Install the MCP Server globally:
npm install -g @pii-firewall/mcp-server- Open your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- Add the PII Firewall server:
{
"mcpServers": {
"pii-firewall": {
"command": "npx",
"args": ["-y", "@pii-firewall/mcp-server"],
"env": {
"PII_FIREWALL_LANG": "en"
}
}
}
}Restart Claude Desktop
You will see a 🔌 icon indicating the MCP Server is connected
Usage in Claude Desktop
Once installed, you can ask Claude to protect your data naturally:
"Mask the PII in this text before we continue: My name is Alice and my email is alice@corp.com"
Claude will automatically call mask_pii and proceed with the masked version.
"Restore the original values in Claude's last response"
Claude will call restore_all to replace tokens with your original data.
Usage in Agent Pipelines
import { MCPClient } from '@modelcontextprotocol/sdk/client'
const client = new MCPClient()
await client.connect(/* your transport */)
// Mask PII before passing to agent
const maskResult = await client.callTool('mask_pii', {
text: userInput,
lang: 'en',
})
// Agent processes masked text
const agentResponse = await runAgent(maskResult.masked)
// Restore PII in agent response
const restoreResult = await client.callTool('restore_all', {
text: agentResponse,
sessionId: maskResult.sessionId,
})Tip: Mask All Messages for an Entire Session
"Mask everything in this session"
When you're working with lots of personal data in a session, just say this at the start:
For this session, please run mask_pii on every message I send
before generating your response — no exceptions.How it works:
[One instruction at session start]
↓
Claude calls mask_pii on every subsequent message
↓
Responds using only the masked textUse cases
- Reviewing customer data, contracts, or bulk records in one session
- Working with data that contains many email addresses or phone numbers
- When you want a clear guarantee that PII Firewall is "on" for the session
Difference from CLAUDE.md
CLAUDE.md makes protection permanent across all sessions.
This one-liner activates protection for the current session only — no config changes needed.
Ideal when you need a temporary boost, or when you open a new session for a specific task.
Auto PII Protection Setup (Recommended)
Installing the MCP Server allows you to call tools manually, but we recommend configuring always-on automatic PII protection from the moment a session starts.
Method A: Add instructions to CLAUDE.md (Easy — Recommended)
If you use Claude Code, add the following to ~/.claude/CLAUDE.md (global config). This enables automatic PII protection in every session without any manual tool invocation.
## PII Auto-Protection Rule
When a user message may contain personal information (email, phone number,
name, address, etc.), always call mcp__pii-firewall__mask_pii first and
use the masked text before generating a response.How it works:
User input: "Contact Alice Smith at alice@corp.com, phone 555-1234"
↓ Claude automatically calls mask_pii
Masked: "Contact [SECURED:type=name,...] at [SECURED:type=email,...], phone [SECURED:type=phone,...]"
↓ Claude responds using the masked text
PII never reaches the AI model ✅We recommend this implementation
Once configured, PII is automatically protected throughout every session — no manual tool calls needed.
Zero friction for users. Zero PII exposure to the LLM.
Method B: UserPromptSubmit Hook for Full Automation (Advanced)
Claude Code's hooks feature lets you run a script automatically every time a user submits a message. Add the following to ~/.claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "curl -s -X POST https://pii-firewallproxy-production.up.railway.app/mask -H 'Content-Type: application/json' -d '{\"text\": \"{{prompt}}\", \"lang\": \"en\"}'"
}
]
}
]
}
}| Method A | Method B | |
|---|---|---|
| Setup difficulty | ✅ Simple | 🔧 Advanced |
| Automation reliability | 🟡 Depends on Claude's judgment | ✅ Fully automatic |
| Works with | Claude Code | Claude Code |
| Recommended | ⭐⭐⭐ Start here | ⭐⭐ If Method A is insufficient |
Related Pages
| Page | Description |
|---|---|
| Secure RAG | Use internal documents safely in RAG without cloud exposure |
| Composite Attack Detection | SQL + prompt injection composite defense |
Environment Variables
| Variable | Required | Description |
|---|---|---|
PII_FIREWALL_LANG | en or ja (default: en) | |
PII_FIREWALL_BASE_URL | Override API endpoint (reserved for future use) |
No API key required
The MCP Server runs @pii-firewall/core locally — no API key or internet connection needed. Zero cloud data transmission.