How to redact sensitive data from documents with AI agents
Leave feedback
On this page
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
Put the document in the storage folder the server can see.
Ask: “Redact every email address in case-file.pdf and tell me which file you saved.”
The agent calls redact_text with a regular expression.
A redacted copy appears in your output folder; the original is untouched.
“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.
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.