Skip to main content
Glama
scrubguard

scrubguard

Official

ScrubGuard - Deterministic PII & Secret Scrubber + Reversible LLM Tokenizer

Sub-millisecond, zero-dependency PII & secret redaction with mathematical checksum verification (Luhn Credit Cards, ISO 7064 Mod-97 IBANs, SSA US SSN rules) and Reversible LLM Tokenization.

Strip sensitive data before sending prompts to OpenAI, Anthropic, or logs, and rehydrate [EMAIL_1] / [CREDIT_CARD_1] placeholders in the LLM's response automatically.


Features

  • Mathematical Checksum Validation: Cuts false positives on order IDs and random numbers using Luhn (Credit Cards), ISO 7064 Mod-97 (IBANs), and SSA Area/Group/Serial validation (US SSNs).

  • Secret & API Key Detection: Scrubs leaked OpenAI (sk-proj-...), Anthropic (sk-ant-...), Stripe (sk_live_..., sk_test_..., whsec_...), AWS (AKIA...), GitHub PAT (ghp_..., github_pat_...), Slack, Google API, JWT, and PEM Private Keys.

  • Reversible LLM Tokenization: Replaces PII with consistent placeholders ([EMAIL_1], [US_SSN_1]) and returns a vault map so LLM outputs can be restored via rehydrateText or POST /v1/rehydrate.

  • Deep JSON Sanitizer: Recursively scrubs strings and sensitive keys (password, secret, api_key, ssn) up to 32 levels deep without breaking JSON schemas.

  • Linear-Time Regex Engine: Disjoint character classes and bounded repetitions prevent catastrophic backtracking (ReDoS).


Related MCP server: mcp-secret-scrub

Quick Start (Hosted Edge API)

1. Scrub & Tokenize Prompt Before Sending to an LLM (POST /v1/scrub)

curl -X POST https://scrubguard-api.scrubguard.workers.dev/v1/scrub \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Refund customer sarah@acme.io on card 4532 0151 1283 0366 (SSN 412-55-9821)",
    "mode": "tokenize"
  }'

Response:

{
  "output": "Refund customer [EMAIL_1] on card [CREDIT_CARD_1] (SSN [US_SSN_1])",
  "findings_count": 3,
  "findings_by_type": {
    "CREDIT_CARD": 1,
    "US_SSN": 1,
    "EMAIL": 1
  },
  "vault": {
    "[CREDIT_CARD_1]": "4532 0151 1283 0366",
    "[US_SSN_1]": "412-55-9821",
    "[EMAIL_1]": "sarah@acme.io"
  }
}

2. Rehydrate LLM Output (POST /v1/rehydrate)

curl -X POST https://scrubguard-api.scrubguard.workers.dev/v1/rehydrate \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Processed refund for [EMAIL_1] ending in [CREDIT_CARD_1].",
    "vault": {
      "[CREDIT_CARD_1]": "4532 0151 1283 0366",
      "[EMAIL_1]": "sarah@acme.io"
    }
  }'

Node.js / Edge SDK (ScrubGuardClient)

import { ScrubGuardClient } from 'scrubguard-mcp'; // npm install scrubguard-mcp

const guard = new ScrubGuardClient({
  apiKey: process.env.SCRUBGUARD_API_KEY, // Optional: uses hosted Pro Edge API (100k req/mo)
});

// 1. Scrub user prompt
const { output: safePrompt, vault } = await guard.scrub(
  'Email alice@company.com with key AKIAIOSFODNN7EXAMPLE'
);

// 2. Send `safePrompt` to OpenAI / Anthropic...
const llmResponse = `Sent confirmation to ${safePrompt.match(/\[EMAIL_\d+\]/)[0]}.`;

// 3. Restore original values
const { output: finalReply } = await guard.rehydrate(llmResponse, vault);

Model Context Protocol (MCP) Server for Claude Desktop & Cursor

ScrubGuard runs locally by default with no network calls. Add it to your claude_desktop_config.json or .cursor/mcp.json:

{
  "mcpServers": {
    "scrubguard": {
      "command": "npx",
      "args": ["-y", "scrubguard-mcp"]
    }
  }
}

To use the optional hosted Pro API, or to run from a local clone:

{
  "mcpServers": {
    "scrubguard": {
      "command": "node",
      "args": ["/path/to/scrubguard/mcp/index.js"],
      "env": {
        "SCRUBGUARD_API_KEY": "sg_live_optional_pro_key"
      }
    }
  }
}

Exposes three MCP tools to your AI assistant:

  • scrub_text: Scrub or reversibly tokenize PII & secrets in text.

  • rehydrate_text: Restore [TOKEN_1] placeholders using the vault map.

  • scrub_json: Recursively sanitize nested JSON objects and logs.


Support & Contact

Questions, bug reports, or higher volume plans: scrubguard@fastmail.com

Available Tools

3 tools
rehydrate_textA

Restore tokenized placeholders (e.g., [EMAIL_1], [CREDIT_CARD_1]) in LLM responses using the vault map returned by scrub_text.

Inputs: text (required), vault (required).

scrub_jsonB

Recursively scrub PII and sensitive keys (password, secret, api_key, ssn) in a JSON object or array while preserving schema types.

Inputs: data (required), mode.

scrub_textB

Scrub or reversibly tokenize PII (emails, SSNs, Luhn-verified credit cards, IBANs, phones, IPv4) and leaked API keys/secrets from text.

Inputs: text (required), mode, types.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool targets a distinct operation and input type: scrubbing free text, rehydrating tokenized text, and scrubbing structured JSON. The descriptions make the text-vs-JSON and forward-vs-reverse boundaries unambiguous, so misselection is unlikely.

    Naming Consistency5/5

    All three tools follow a strict verb_noun snake_case pattern (scrub_text, rehydrate_text, scrub_json), with the verb signaling direction (scrub vs rehydrate) and the noun signaling the target (text vs json). Fully predictable.

    Tool Count4/5

    Three tools is lean but each earns its place for a focused PII-scrubbing utility; there is no filler. The surface is on the small side, but the scoping is deliberate rather than thin.

    Completeness4/5

    The core scrub/rehydrate lifecycle is covered for text and scrubbing is covered for JSON, so primary workflows are complete. Minor gaps remain: there is no rehydrate_json counterpart for restoring tokens in structured data, and no way to inspect or manage the vault map.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      Zero-Trust local PII & secrets masking MCP (ZTDS RFC v1.0). Zero server logs. Features: 23 zero-trust tools, 30 industry profiles, offline OCR, RAM-only masking. Run: npx -y @privacyscrubber/mcp-server. Website: https://privacyscrubber.com SDK: https://www.npmjs.com/package/@privacyscrubber/sdk
      4
      23
      794 npm
      274 PyPI
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables deterministic, no-LLM scrubbing of secrets from text or logs before they enter agent context, supporting redaction, masking, and hashing without ever leaking the original value.
      51 PyPI
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables local zero-knowledge encryption of a personal vault and sanitization of PII such as credentials, credit cards, and addresses before dispatch to cloud LLMs, with client-side rehydration of masked data.
      7
      -
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables agents to encrypt and sanitize sensitive data such as credentials, credit card numbers, and addresses locally before dispatching prompts to cloud LLMs, then rehydrate the masked values client-side. It runs deterministically with zero external dependencies over MCP JSON-RPC stdio, so no plaintext PII leaves the user's machine.
      -