# How to redact sensitive data from documents with AI agents Redact sensitive data from documents with an AI agent over MCP: pattern-based text redaction, area redaction, annotations, and metadata — all locally. Redaction with an agent works because the division of labour is clear: the **agent** helps you express *"every email address and the client's name"* as patterns and drives the calls; the **engine** applies them exactly, locally, in the document. {{< alert style="info" >}} The commands and config snippets on this page are for the **.NET** build of the server — the only platform available today. Installation and client setup: [MCP server for .NET]({{< ref "redaction/net/mcp/_index.md" >}}). Other platforms will expose the same tools with their own launch command; everything else on this page applies unchanged. {{< /alert >}} ## The pattern 1. Put the document in the storage folder the server can see. 2. Ask: *"Redact every email address in case-file.pdf and tell me which file you saved."* 3. The agent calls [`redact_text`]({{< ref "redaction/mcp/tools-reference/redact-text.md" >}}) with a regular expression. 4. A redacted copy appears in your output folder; the original is untouched. 5. You verify — see [Verify a redaction]({{< ref "redaction/mcp/use-cases/verify-a-redaction.md" >}}). ## Ask for the file, then check it *"Done"* is not a result. The redaction tools return the path of the saved file, not a match count, so ask the agent to name the file it produced and then [verify]({{< ref "redaction/mcp/use-cases/verify-a-redaction.md" >}}) that file. A number in the agent's reply is its own reading of the text, not tool output. In [evaluation mode]({{< ref "redaction/mcp/getting-started/licensing.md" >}}) a redaction is capped at four replacements, so an unlicensed run can leave matches in place. ## Platform limit On Linux, including the Docker image (a Linux container), `redact_image_area` and `erase_metadata` currently fail on PDF files because the PDF engine's image handling depends on `System.Drawing`, which .NET supports only on Windows; both work on Word documents, and `redact_text` works on PDF. Run PDF area redaction and metadata erasure on Windows with `dnx`. ## The four places data hides A complete pass is four calls, not one: | Where | Tool | |---|---| | Body text | [`redact_text`]({{< ref "redaction/mcp/tools-reference/redact-text.md" >}}) | | Scans, photos, signatures | [`redact_image_area`]({{< ref "redaction/mcp/tools-reference/redact-image-area.md" >}}) | | Comments and sticky notes | [`redact_annotations`]({{< ref "redaction/mcp/tools-reference/redact-annotations.md" >}}) | | Author, company, properties | [`erase_metadata`]({{< ref "redaction/mcp/tools-reference/erase-metadata.md" >}}) | Chain them on the **produced file** each time — every call writes a new document, and applying the second redaction to the original throws away the first. ## Patterns worth keeping > Redact anything matching `[\w.+-]+@[\w-]+\.[\w.]+` — email addresses. > Redact `\b\d{3}-\d{2}-\d{4}\b` — US social security numbers. > Redact the literal string "Acme Holdings" everywhere, including in comments. Ask the agent to show you the pattern before it runs. A regex you have read is a redaction you can defend. ## Setup ```bash dnx GroupDocs.Redaction.Mcp --yes ``` with `GROUPDOCS_MCP_STORAGE_PATH` pointing at the folder — [per-client config]({{< ref "redaction/net/mcp/install-in-ai-clients.md" >}}) or the [installer]({{< ref "redaction/mcp/getting-started/_index.md" >}}). ## Where to go next * [Prepare documents for disclosure]({{< ref "redaction/mcp/use-cases/prepare-documents-for-disclosure.md" >}}) — the full four-tool pass, in order. * [Redact scanned documents and images]({{< ref "redaction/mcp/use-cases/redact-scanned-documents.md" >}}) — when there is no text layer. * [Verify a redaction]({{< ref "redaction/mcp/use-cases/verify-a-redaction.md" >}}) — proving it, not assuming it. * [On-premise architecture]({{< ref "redaction/mcp/use-cases/on-premise-redaction.md" >}}) — what leaves the machine, honestly. ## Read more * [3 ways to redact sensitive data with AI agents and MCP](https://blog.groupdocs.com/redaction/3-ways-redact-sensitive-data-ai-agents-mcp/) — the same scenario on the GroupDocs blog, with worked examples and the trade-offs.