Skip to content

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

ToolCategoryDescription
detect_piiDetectionDetect PII types and locations in text
mask_piiMaskingMask PII and return a token map
restore_piiRestoreRestore a single masked token
restore_allRestoreRestore all tokens in a response
detect_injectionSecurityDetect prompt injection attempts
detect_all_injectionsSecurityDetect SQL injection + prompt injection simultaneously (composite attack detection)
rag_ingestSecure RAGTokenize PII in documents and split into RAG chunks safely
rag_resolveSecure RAGRestore PII tokens in RAG search results
store_statusManagementCheck session and credit status

API Key Detection — All Major AI Providers

mask_pii automatically detects and masks API keys from all major AI providers.

ProviderKey Format
Anthropic (Claude)sk-ant-api03-...
OpenAI (ChatGPT)sk-proj-... / sk-...
Google AI (Gemini)AIzaSy...
Hugging Facehf_...
Groqgsk_...
Perplexitypplx-...
Replicater8_...
AWS BedrockAKIA...
GitHubghp_... / ghs_...
Stripesk_live_... / sk_test_...

No matter which AI you use, your API keys stay protected.

Installation

Claude Desktop

  1. Install the MCP Server globally:
bash
npm install -g @pii-firewall/mcp-server
  1. Open your Claude Desktop config file:
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  1. Add the PII Firewall server:
json
{
  "mcpServers": {
    "pii-firewall": {
      "command": "npx",
      "args": ["-y", "@pii-firewall/mcp-server"],
      "env": {
        "PII_FIREWALL_LANG": "en"
      }
    }
  }
}
  1. Restart Claude Desktop

  2. 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

typescript
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 text

Use 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.


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.

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.

markdown
## 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:

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 AMethod B
Setup difficulty✅ Simple🔧 Advanced
Automation reliability🟡 Depends on Claude's judgment✅ Fully automatic
Works withClaude CodeClaude Code
Recommended⭐⭐⭐ Start here⭐⭐ If Method A is insufficient
PageDescription
Secure RAGUse internal documents safely in RAG without cloud exposure
Composite Attack DetectionSQL + prompt injection composite defense

Environment Variables

VariableRequiredDescription
PII_FIREWALL_LANGen or ja (default: en)
PII_FIREWALL_BASE_URLOverride 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.

Privacy by Design.