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