doc-redactor
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@doc-redactor Redact all names, phones and emails in the contract.docx and audit it"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
doc-redactor
本地优先的多格式文档脱敏工具:检测 → 真删除 → 取证审计,全程零网络调用。 支持 PDF(文字型 + 扫描件)、DOCX、XLSX、PPTX、TXT/MD/CSV/JSON 等。 可作为 MCP server 接入 AgenticX 等任意支持 MCP 的 Agent 框架,或作为 Python 库直接使用。
格式路由采纳 AgenticX KB 的扩展名分类; 检测层格式无关(一份检测代码服务全部格式),执行层逐格式真删除。
能力矩阵
泄露面 | PDF 文字型 | PDF 扫描件 | DOCX | XLSX | PPTX | TXT/MD |
正文本体 | 内容流物理移除 | OCR 定位 + 图像像素真删除 | 段落/表格 run 级替换(跨 run 重建) | 全 sheet 单元格(含隐藏 sheet) | shape/表格/组合形状递归 | 直接替换 |
Logo / 嵌入图 | SIFT 模板匹配(宽高比 + NCC 双校验) | 同左 | — | — | — | — |
扫描页 | 自动识别(文本量阈值)→ RapidOCR | ✓ | — | — | — | — |
元数据 | docinfo + XMP 全清 | 同左 | core.xml 属性 | 属性 + 透视缓存天然清除 | core.xml 属性 | 无 |
修订记录 | — | — | w:del/w:ins 全接受 | — | — | — |
批注 | 注释/表单 | — | comments.xml 替换 | 单元格批注 | — | — |
页眉页脚/备注 | — | — | 页眉页脚(含首页/偶数页) | — | 备注页 | — |
取证审计 | 对象流/隐藏文本/增量保存/logo 回扫 | OCR 回扫 | 解压逐部件搜词 + 修订残留检查 | 同左 + 隐藏 sheet | 同左 | 重读全文 |
检测层(全格式共享):关键词词典 + 正则(手机/身份证/邮箱/银行卡)+ spaCy 中文 NER(可选)。 OCR 文本经 NFKC 归一化后再检测(OCR 常把数字识别成全角),命中区域按字符占比切分,宁大勿漏。
Related MCP server: phi-redact-mcp
MCP 工具(两阶段安全设计)
redact_scan— 非破坏性扫描(自动识别格式),返回候选清单 + 元数据泄露 + 格式相关清单redact_apply— 只执行确认过的词条清单(不吃自动判断)redact_audit— 取证审计,交付前必须 PASSextract_image— 提取 PDF 嵌入图像作为 logo 脱敏模板glossary_list / add / remove— 敏感词词典闭环(~/.doc-redactor/glossary.json)
安全原则:Agent 永远不能静默决定"什么算敏感"——scan 出候选、用户确认、apply 只吃确认清单、audit 兜底。
安装
git clone https://github.com/agxhub/doc-redactor && cd doc-redactor
uv venv .venv --python 3.11
uv pip install --python .venv/bin/python -e ".[ner]"
.venv/bin/python -m spacy download zh_core_web_trf # 可选:NER 检测注册到 AgenticX
在 ~/.agenticx/mcp.json 添加:
{
"mcpServers": {
"doc-redactor": {
"command": "/path/to/doc-redactor/.venv/bin/python",
"args": ["mcp_server.py"],
"cwd": "/path/to/doc-redactor",
"timeout": 300.0
}
}
}Python 库直接使用
from docredactor import scan_document, apply_redaction, audit_document
scan = scan_document("合同.docx", keywords=["张伟"], enable_ner=True)
# 用户确认候选后
apply_redaction("合同.docx", "合同_脱敏.docx", terms=["张伟", "13800138000"])
report = audit_document("合同_脱敏.docx", terms=["张伟", "13800138000"])
assert report["verdict"] == "PASS"Roadmap
旧版二进制 Office(.doc/.ppt/.xls):需 LibreOffice 预转换,评估中
图像文件(PNG/JPG)直接脱敏:OCR + 像素涂黑管线已具备,待封装
.docx 内嵌对象(OLE)与图表 XML 泄露面深化
License
AGPL-3.0-or-later(PyMuPDF 执行层传染)。检测层与审计思路可参考实现。
Available Tools
7 toolsextract_imageA
从 PDF 提取指定嵌入图像保存为 PNG(用于制作 logo 脱敏模板:先 redact_scan 拿到图像 xref 清单,再提取可疑 logo 作为模板)。
Inputs: xref (required), pdf_path (required), output_path (required).
glossary_addA
把确认过的敏感词沉淀进词典,后续 scan 自动生效。
Inputs: terms (required).
glossary_listA
查看持久化敏感词词典(scan 时自动并入候选)。
Inputs: no named parameters. Returns: result
glossary_removeC
从词典移除词条。
Inputs: terms (required).
redact_applyA
执行脱敏(真删除,不可恢复)。terms 必须是已确认的敏感词清单——请先调用 redact_scan 并经用户确认后再调用本工具。logo_templates 仅支持 PDF。
Inputs: terms (required), input_path (required), output_path (required), logo_templates.
redact_auditA
取证级审计:对象流/文本层/元数据/修订记录/批注/OCR 逐面检查,判定敏感词 是否彻底移除。交付脱敏文件前必须通过本审计。
Inputs: terms (required), doc_path (required), logo_templates.
redact_scanA
非破坏性扫描文档(不改文件),发现候选敏感项。支持 PDF(文字/扫描件自动 OCR)、DOCX、XLSX、PPTX、TXT/MD/CSV 等。返回候选清单(词条/来源/位置/次数)、 元数据泄露、格式相关清单。enable_ner 需 zh_core_web_trf 模型;标准/公文类 文档建议关闭(噪声大)。
Inputs: input_path (required), keywords, enable_ner, ner_labels, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a clearly distinct role: scanning, applying, auditing, glossary management, and image extraction. Even redact_scan and redact_audit are sharply differentiated as pre-redaction candidate discovery versus post-redaction forensic verification.
Most tools follow a clear domain-prefix pattern: redact_* for document operations and glossary_* for dictionary operations. The exception is extract_image, which uses verb+noun ordering rather than prefix+operation, creating a minor but noticeable inconsistency.
Seven tools is well-scoped for a document redaction server. Each tool fills a necessary role in the workflow without redundancy or bloat, and the count supports a complete redaction pipeline.
The toolkit covers the full redaction lifecycle: scan for candidates, apply redaction, audit the result, and persist confirmed terms in a glossary. Supporting image extraction and glossary management fills the surrounding workflow needs, leaving no obvious dead ends.
Maintenance
Related MCP Connectors
MCP server for detecting and redacting PII (Personally Identifiable Information) in PDF documents.
Stateless PII redaction over MCP/REST. Free ≤1000 words or $0.01/call; file upload supported.
Document-to-Markdown MCP server — convert PDF, Office and HTML into LLM-ready Markdown.
Mask, restore and black out personal data in text and files, processed in the EU.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceLocal-first CLI and MCP server for redacting sensitive text before sharing logs, configs, and errors with AI tools.MIT
- AlicenseAqualityCmaintenanceAn MCP server that redacts PII/PHI from text before it ever reaches an LLM — self-hosted, fail-closed, and HIPAA-aware.321 PyPIMIT
- AlicenseNot gradedqualityBmaintenanceMCP server that enables AI agents to redact text, metadata, annotations, and image areas in documents using GroupDocs.Redaction, with support for various document formats and easy integration with Claude, Cursor, and GitHub Copilot.MIT

omitly-mcpofficial
FlicenseAqualityBmaintenanceMCP server for local, verifiable PDF redaction. Enables AI agents to find sensitive regions, locate text, redact PDFs on-device, verify redaction and tamper-evidence seals, and generate PDFs—without uploading confidential documents.8365 npm-