Redact MCP

io.github.r3352由 GitHub 账号 r3352 发布v2.0.4更新于 Oct 24, 2026

Auto-detects and obfuscates PII (IPs, emails, API keys, names) so Claude never sees real client data

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

在本地对文本、文件和 HTTP 响应中的个人隐私与密钥做混淆,让助手只看到虚假替换值。

可以做什么
通过 19 类正则模式和 AI 命名实体识别模型检测敏感数据,覆盖 IP、主机名、邮箱、API 密钥、令牌、私钥、连接字符串、卡号、地址以及人名、组织名和地名。每个唯一值都会获得确定性的虚假替换值,并保存在双向映射表中,因此混淆可以无损还原。共提供八个工具,包括混淆、还原、读取文件并混淆、映射的添加/删除/查看、审计日志查看,以及一个 HTTP 代理工具:先还原请求、发出真实调用,再对响应做混淆。
适用场景
适合助手需要分析敏感材料(例如渗透测试数据或客户记录),又不希望真实值暴露给模型或第三方时使用。也适用于最终报告在交付前需要还原为真实值的工作流。
运行要求
以 stdio 方式在本地运行,通常通过 npx 从 npm 包启动,需要 Node.js。命名实体识别模型(约 110MB)首次使用时下载并缓存;若不可用则退回到仅正则模式。可选环境变量:REDACT_DATA_DIR 指定映射与审计存储目录,REDACT_AUDIT_LOG 启用 JSONL 日志。未声明任何身份验证。
安装前请注意
审计日志会记录完整输入与输出文本以及每个检测到的真实值,因此按设计就包含敏感数据,必须妥善保护;日志写入 REDACT_DATA_DIR。映射也会持久化到该目录。代理工具会向目标发出真实的外部 HTTP 请求,插件钩子还会检查原始工具输出。使用前请确认数据与日志的存放位置。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Redact MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Redact MCP — Automatic PII Obfuscation for Claude Code

An MCP server (and Claude Code plugin) that automatically detects and obfuscates sensitive data before Claude ever sees it. Uses regex pattern matching and AI-powered Named Entity Recognition (NER) to catch IPs, hostnames, emails, API keys, person names, organization names, locations, private keys, connection strings, and more.

Built for penetration testers who need Claude's analysis capabilities without exposing client data to a third party.

How It Works

Raw data with real PII ──► Regex + NER detection ──► Claude sees only fake values                                                              │Final report for client ◄── Real values restored ◄── /redact:export

The server maintains a bidirectional mapping table. Every sensitive value gets a consistent, deterministic fake replacement that persists across the entire session:

Real ValueObfuscated AsDetection
10.50.1.100198.51.100.1regex
api.clientcorp.comtarget-1.example.comregex
[email protected][email protected]regex
AKIA3EXAMPLE...[REDACTED_AWS_KEY_1]regex
James WilsonPerson_A Person_BNER
MicrosoftOrg_ANER
SeattleCity_ANER
postgres://admin:pw@host/db[REDACTED_CONN_STRING_1]regex
-----BEGIN RSA PRIVATE KEY...[REDACTED_PRIVATE_KEY_1]regex

Same real value always maps to the same fake value. obfuscate(text) -> deobfuscate(result) === text is guaranteed.

Install

Quick install via npx (recommended)

bash
claude mcp add @mattzam/redact-mcp -- npx @mattzam/redact-mcp

That's it. Claude Code will launch the server via npx on each session. The NER model (~110MB) downloads automatically on first use and is cached for subsequent runs.

To enable audit logging:

bash
claude mcp add @mattzam/redact-mcp -e REDACT_AUDIT_LOG=true -- npx @mattzam/redact-mcp

As a Claude Code plugin (full features: hooks + skills)

bash
git clone https://github.com/r3352/redact-mcp.git redactcd redact/servernpm installnpm run buildcd ../..
# Load as a plugin (includes hooks for leak detection + slash commands)claude --plugin-dir ./redact

The plugin mode adds hooks (automatic leak detection on raw tool output) and skills (/redact:status, /redact:add, /redact:export) on top of the MCP server.

Manual MCP configuration

Add to your Claude Code MCP config (~/.claude/mcp.json or project .mcp.json):

json
{  "mcpServers": {    "redact-server": {      "command": "npx",      "args": ["redact-mcp"],      "env": {        "REDACT_DATA_DIR": "/path/to/data/directory",        "REDACT_AUDIT_LOG": "true"      }    }  }}

Environment Variables

VariableDefaultDescription
REDACT_DATA_DIR./dataDirectory for mapping state and audit logs
REDACT_AUDIT_LOGfalseSet to true to enable JSONL audit logging

What Gets Detected

Regex Patterns (19 types)

Zero configuration required. Detected automatically:

CategoryTypes
NetworkIPv4 (private + public), IPv6, hostnames with valid TLDs, MAC addresses
IdentityEmails, person names (JSON context), phone numbers (US + international), SSNs
SecretsAWS access keys, JWTs, Bearer tokens, API keys (context-aware), generic secrets (password=, secret=), private keys (PEM format), connection strings (postgres/mysql/redis/mongodb/amqp/mssql URIs)
FinancialCredit card numbers (Luhn-validated)
PhysicalStreet addresses (123 Main Street, 456 Oak Ave, etc.)

NER Detection (AI-powered)

When @huggingface/transformers is installed (included by default), the server loads Xenova/bert-base-NER (~110MB ONNX model, downloaded on first use) to detect:

Entity TypeExampleObfuscated As
Person namesJames WilsonPerson_A Person_B
OrganizationsMicrosoft, Acme CorpOrg_A, Org_B
LocationsSeattle, New YorkCity_A, City_B

NER catches entities that regex misses — names and organizations outside of JSON context, arbitrary location names, etc. Regex results always take priority when both detect the same span (regex is more precise for structured patterns).

Graceful fallback: If the model fails to load or the package is missing, the server continues in regex-only mode with no errors.

Smart Passthrough

These values are never obfuscated:

  • Loopback/reserved: localhost, 127.0.0.1, ::1, 0.0.0.0
  • RFC documentation ranges: 192.0.2.x (TEST-NET-1), 198.51.100.x (TEST-NET-2), 203.0.113.x (TEST-NET-3), 2001:db8:: (IPv6 docs)
  • Example domains: example.com, example.org, example.net
  • Dev domains: github.com, npmjs.com, nodejs.org, googleapis.com, etc.
  • Security testing: burpcollaborator.net, oastify.com
  • Code patterns: console.log, process.env, package.json, webpack.config, jest.config, tailwind.config, and 30+ other common false positives
  • Broadcast MACs: FF:FF:FF:FF:FF:FF, 00:00:00:00:00:00

MCP Tools

The server registers 8 tools via MCP:

ToolDescription
redact_obfuscateAuto-detect and replace all PII in text (regex + NER)
redact_deobfuscateReverse all replacements back to real values
redact_proxy_requestHTTP proxy — deobfuscates request, makes real call, obfuscates response
redact_read_fileRead a file and return obfuscated content
redact_add_mappingManually add a real-to-fake mapping
redact_remove_mappingRemove a mapping (fix false positives)
redact_show_mappingsShow all current mappings grouped by type
redact_audit_logView recent audit log entries (requires REDACT_AUDIT_LOG=true)

redact_proxy_request — The Key Tool

For pentest workflows, this is the critical tool. Claude calls it instead of curl/fetch:

  1. Claude provides URL/headers/body (may contain already-obfuscated values)
  2. Server deobfuscates the request (restores real hostnames/IPs/tokens)
  3. Makes the real HTTP request to the target
  4. Obfuscates the entire response (headers + body)
  5. Returns sanitized response to Claude

Claude never sees the real response data. All deobfuscation and obfuscation steps are audit-logged.

redact_audit_log — Compliance Audit Trail

When REDACT_AUDIT_LOG=true, every obfuscation and deobfuscation operation is logged to ${REDACT_DATA_DIR}/audit.jsonl. Each entry records:

  • Timestamp and operation type (obfuscate, deobfuscate, proxy_request, file_read)
  • Full input text (raw data before transformation)
  • All detections with type, real value, fake replacement, and source (regex or ner)
  • Full output text (transformed result)

This provides a complete audit trail: what went in, what was modified, and what came out.

View entries via the redact_audit_log tool or read audit.jsonl directly:

bash
# Last 5 entries, pretty-printedtail -5 data/audit.jsonl | python3 -m json.tool

Security note: The audit log contains real sensitive data by design (that's its purpose — proving what was redacted). Protect it accordingly.

Skills (Slash Commands)

CommandDescription
/redact:statusShow current redaction mappings grouped by type
/redact:add <real> <fake>Manually add a mapping (e.g., /redact:add clientcorp.com target.example.com)
/redact:export <file> [output]Deobfuscate a file for client delivery (defaults to ~/Desktop/)

Hooks

The plugin uses two hooks (automatic, no user interaction):

  • SessionStart — Injects instructions telling Claude to route all data through redact tools
  • PostToolUse — Warns if Claude uses raw Bash/Read/Grep/WebFetch and the output contains known sensitive values (leak detection)

How the Pipeline Works

Detection

  1. Regex pass — 19 pattern types scanned synchronously via compiled RegExp
  2. NER pass — Xenova/bert-base-NER runs in parallel (async), catches person/org/location entities
  3. Merge — Results combined; regex matches win on overlapping spans (more precise for structured data)
  4. Deduplication — Overlapping NER results that cover the same span as a regex match are dropped

Mapping

  1. Each unique real value gets a deterministic fake via counter-based generation
  2. Fake values use safe ranges: TEST-NET-2 for IPv4, RFC 3849 for IPv6, example.com for domains, 555 prefix for phones, locally-administered range for MACs
  3. Mappings persist to ${REDACT_DATA_DIR}/mappings.json with debounced writes (500ms)
  4. Longest-first replacement prevents partial match corruption (e.g., 10.50.1.100 before 10.50.1.10)

Round-trip Guarantee

deobfuscate(obfuscate(text)) === text for all inputs. The bidirectional mapping table ensures lossless restoration.

Architecture

redact/├── .claude-plugin/plugin.json     # Plugin manifest├── .mcp.json                      # MCP server config (stdio transport)├── hooks/│   ├── hooks.json                 # Hook definitions│   └── scripts/│       ├── session-start.sh       # Injects redaction context on session start│       └── post-tool-scan.py      # Leak detection on raw tool output├── skills/│   ├── status/SKILL.md            # /redact:status│   ├── add/SKILL.md               # /redact:add│   └── export/SKILL.md            # /redact:export└── server/    ├── package.json               # v2.0.0, deps: @modelcontextprotocol/sdk, @huggingface/transformers    ├── tsconfig.json              # ES2022, Node16 modules, strict    └── src/        ├── index.ts               # MCP server — 8 tools, server instructions        ├── mapping-engine.ts      # Bidirectional mapping, async obfuscate/deobfuscate, audit integration        ├── pattern-detector.ts    # 19 regex patterns + async NER merge        ├── fake-generator.ts      # Deterministic counter-based fake value generation        ├── ner-detector.ts        # Lazy-loaded HuggingFace NER with graceful fallback        ├── audit-logger.ts        # JSONL append logger, serialized write queue        └── persistence.ts         # JSON state file with debounced writes

Runtime Flow

Claude Code ──stdio──► MCP Server (index.ts)                            │                     CallToolRequest                            │                    ┌───────┴───────┐                    │ MappingEngine │                    └───────┬───────┘                            │              ┌─────────────┼─────────────┐              │             │             │        detectPatterns   NER detect   AuditLogger        (regex, sync)   (async)      (JSONL, async)              │             │             │              └─────────────┼─────────────┘                            │                     merge + dedupe                            │                     apply mappings                     (longest-first)                            │                     return to Claude

Development

bash
cd server
# Install dependencies (~110MB for NER model on first run)npm install
# Build TypeScriptnpm run build
# Test MCP server starts and lists toolsecho '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | node dist/index.js
# Quick obfuscation testnode -e 'const { MappingEngine } = await import("./dist/mapping-engine.js");const engine = new MappingEngine("/tmp/redact-dev");await engine.init();console.log(await engine.obfuscate("Email [email protected] from 10.0.0.1"));'

Changelog

v2.0.0

  • NER detection — AI-powered entity recognition via @huggingface/transformers + Xenova/bert-base-NER. Catches person names, organizations, and locations outside structured JSON context.
  • Audit logging — Opt-in JSONL audit trail (REDACT_AUDIT_LOG=true) records full input/output text, all detections with sources, and timestamps for every obfuscation and deobfuscation operation.
  • 7 new pattern types — organization, location, private_key, connection_string, generic_secret, mac_address, street_address
  • 8th tool — redact_audit_log for viewing audit entries
  • Improved phone detection — International format support (+CC-XXXX-XXXX)
  • Expanded false positive list — webpack.config, jest.config, tailwind.config, and 9 other config file patterns

v1.0.0

  • Initial release with regex-only detection (12 pattern types), 7 MCP tools, bidirectional mapping, persistence, hooks, and skills.

License

MIT

来源:README.md,提交 36b0fe8

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v2.0.4最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。