How to redact sensitive data from documents with AI agents

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.

Note
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. Other platforms will expose the same tools with their own launch command; everything else on this page applies unchanged.

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 with a regular expression.
  4. A redacted copy appears in your output folder; the original is untouched.
  5. You verify — see Verify a redaction.

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 that file. A number in the agent’s reply is its own reading of the text, not tool output. In evaluation mode 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:

WhereTool
Body textredact_text
Scans, photos, signaturesredact_image_area
Comments and sticky notesredact_annotations
Author, company, propertieserase_metadata

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

dnx GroupDocs.Redaction.Mcp --yes

with GROUPDOCS_MCP_STORAGE_PATH pointing at the folder — per-client config or the installer.

Where to go next

Read more