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 how many you replaced.”
  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.

Always ask for the match count

“Done” is not a result. “Replaced 14 matches” is, because it can be wrong in a way you can notice: if you expected two and got fourteen, the pattern is too loose; if you expected fourteen and got four, you are probably in evaluation mode with its four-replacement cap.

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