Skip to main content
Glama
mzaid007

Universal Poison Armor

Sanitize Document

sanitize_document

Remove prompt injection phrases, hidden zero-width Unicode steganography, tracking pixels, and high-entropy adversarial suffixes from untrusted text before AI context ingestion.

Instructions

Sanitize an incoming untrusted text document, file content, user input, or RAG retrieval chunk against AI poisoning.

Strips Markdown XSS tracking pixels, neutralizes hidden zero-width Unicode steganography, redacts prompt injection phrases, and replaces high-entropy mathematical adversarial suffixes (GCG attacks).

Usage Guidelines:

  • WHEN TO USE: Use on any individual raw text file, user-supplied prompt, single web page, or RAG chunk before ingesting it into the AI context window.

  • WHEN NOT TO USE: Do NOT use for analyzing batches of documents for statistical dataset anomalies (use scan_dataset_for_anomalies instead) or verifying domain consensus across multiple news/search results (use verify_article_consensus instead).

Behavior & Side Effects:

  • Replaces prompt injection patterns with [REDACTED_INJECTION_ATTEMPT].

  • Replaces high-entropy adversarial suffixes (Shannon entropy > 4.5) with [ADVERSARIAL_SUFFIX_THREAT: REDACTED_HIGH_ENTROPY_BLOCK].

  • Removes ![alt](url) tracking images, <img>, and <iframe> tracking beacons.

  • Appends timestamped threat events to security_audit.json in the root workspace directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_textYesThe raw untrusted string content to sanitize. If empty, returns an empty string.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full disclosure burden and does so thoroughly. It states specific side effects: replacing injection patterns with `[REDACTED_INJECTION_ATTEMPT]`, replacing high-entropy suffixes with a specific placeholder, removing tracking images/beacons, and appending timestamped threat events to `security_audit.json`. This gives agents a clear model of what the tool modifies and what external effects it has.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a one-sentence summary, a scannable list of transformations, and clearly labeled usage and behavior sections. Every sentence contributes meaningful operational information, and the most important purpose is front-loaded. No filler or redundant content is present.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter tool with an output schema and no annotations, the description is complete. It explains what the tool does, when to use it, when not to use it, what transformations it performs, and what audit side effect it has. The output schema covers return values, so the description does not need to restate them.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already describes `document_text` as 'The raw untrusted string content to sanitize' with 100% coverage, so the baseline is 3. The description adds semantic value by enumerating the kinds of inputs accepted — text document, file content, user input, or RAG retrieval chunk — and clarifying the threat context, which helps the agent decide what to pass. It does not add syntax details, but the schema is sufficient for that.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific action and resource: 'Sanitize an incoming untrusted text document, file content, user input, or RAG retrieval chunk against AI poisoning.' It then lists concrete transformations such as stripping tracking pixels, neutralizing zero-width Unicode, redacting prompt injection phrases, and replacing adversarial suffixes. This makes the tool's purpose clear and distinct from its siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit 'WHEN TO USE' and 'WHEN NOT TO USE' guidance. It names the sibling tools `scan_dataset_for_anomalies` and `verify_article_consensus` as alternatives for batch or consensus tasks, leaving no ambiguity about when to choose this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.