Skip to main content
Glama
fairquery-llm-data-guard

fairquery-llm-data-guard

Official

Detect / redact PII and secrets before LLM use (paid run)

guard_text
Read-onlyIdempotent

Scan text or document URLs for PII and secrets before sharing with an LLM, then redact findings into placeholders, masks, or hashes.

Instructions

WHAT: The only tool in this server that inspects content. Scans text documents (or public document URLs: txt/md/json/csv/HTML/PDF) for PII (emails, phones, US SSNs, Luhn-valid cards, IBANs, UK NINOs, IPs, optional person names/addresses) and secrets (AWS/GitHub/Slack/Stripe/OpenAI/... keys, JWTs, private keys, URL credentials, high-entropy key=value). mode="detect" reports findings; mode="redact" (default) also returns sanitized text and, on request, the placeholder map that restore_placeholders needs later. WHEN TO USE: before sending prompts, tickets, logs or files to an LLM or third party; to audit text for leaked credentials. Step 2 of the round trip (list_detectors -> guard_text -> [get_run_results] -> LLM -> restore_placeholders). WHEN NOT TO USE: to put originals back into an LLM answer, use restore_placeholders (free, local; mode="restore" here gives the same output but starts a paid run and is only kept for Actor pipelines outside MCP). To see entity types, list_detectors (free). To fetch rows of a run you already started, get_run_results (free; calling guard_text again starts and bills a new run). Not for images/scanned PDFs (text layer only, no OCR) or email deliverability. COST: paid. Runs Apify Actor fairquery/llm-data-guard-pii-secrets with your APIFY_TOKEN; pay-per-event: $0.0015 per document processed + $0.0002 per finding (error rows free). Example: 10 documents with 20 findings ~ $0.02. RETURNS: findings[] hold masked previews only, never raw values; placeholder_map (ORIGINAL values) only with returnPlaceholderMap=true. With waitForFinish=false: items is empty and run.run_id is the input for get_run_results. EXAMPLE: {"texts":["Mail jane@acme.com, key AKIAIOSFODNN7EXAMPLE"],"mode":"redact","redactionStyle":"placeholder"} -> output_text with the email replaced by [EMAIL_1] and the key by a placeholder; findings lists EMAIL and AWS_ACCESS_KEY. PARAMETERS: texts and/or documentUrls: at least one is required although the schema marks both optional (neither -> a free INPUT_EMPTY error row); both may be combined, and every text or URL is one billed document (max 1000 per run; extras get a free MAX_DOCUMENTS_EXCEEDED row). mode decides which other fields apply: "detect" ignores redactionStyle / returnPlaceholderMap; "redact" uses them; "restore" ignores all detector options and only replaces placeholders found in texts with values from placeholderMap (a placeholder missing from the map stays unchanged; restore rows have 0 findings, so they cost the per-document fee only). returnPlaceholderMap only works with mode="redact" + redactionStyle="placeholder" and is what restore_placeholders consumes; placeholders are consistent across all documents of one call ([EMAIL_1] is the same address everywhere) but numbering restarts on every call, so keep each call's map. detectNames / detectAddresses must be true before PERSON / LOCATION / STREET_ADDRESS can be found or used in entityTypes. entityTypes filters findings after detection (unknown names match nothing, no error) and is the main lever to cut per-finding cost. waitForFinish=false returns at once with run.run_id while the run continues in your Apify account (same price, billed once); use it for big batches or many URLs/PDFs that may not finish within this call's 280 s wait, then poll get_run_results with that run_id.

Input Schema

NameRequiredDescriptionDefault
modeNoOptional, one of "detect" | "redact" | "restore", default "redact". "detect" = report findings only; "redact" = also return output_text with values replaced; "restore" = replace placeholders in texts with originals from placeholderMap (paid run; restore_placeholders does the same for free). Example: "detect"
textsNoOptional if documentUrls is given (at least one of the two is required). One string per document (prompt, chat message, ticket, log, file content), <= 1,000,000 chars each (longer is truncated); one billed document each. Example: ["Hi, I am Jane (jane.doe@acme.com)"]
allowListNoOptional, default []. Exact values that are never flagged (whole value, case-insensitive; not substrings). Example: ["support@yourcompany.com"]
detectNamesNoOptional boolean, default false. true detects person names (type PERSON) with English NER (lower precision, slightly slower; each finding billed).
entityTypesNoOptional, default omitted/[] = all enabled detectors. Entity type names (case-insensitive) from list_detectors, without the "(opt-in)" notes. Example: ["EMAIL","CREDIT_CARD","AWS_ACCESS_KEY"]
entropyScanNoOptional boolean, default false. true also flags unlabeled random-looking tokens of 20+ chars as HIGH_ENTROPY_STRING (catches unknown key formats; may flag hashes/IDs).
documentUrlsNoOptional if texts is given. Absolute public http(s) URLs of txt, md, json, csv, HTML or PDF files (max 10 MB each; PDFs text layer only, no OCR), fetched by the Actor; unreachable URLs give free DOCUMENT_FETCH_FAILED rows. Example: ["https://example.com/report.pdf"]
waitForFinishNoOptional boolean, default true. true waits up to 280 s and returns the rows; false starts the run and returns immediately with run.run_id (poll get_run_results). Same price either way. Example: false
placeholderMapNoOptional, default {}; used only with mode="restore". Object mapping placeholder -> original value, as returned in placeholder_map by a previous redact call. Example: {"[EMAIL_1]":"jane@acme.com"}
redactionStyleNoOptional, one of "placeholder" | "mask" | "hash", default "placeholder"; used in mode="redact" only. "placeholder" = [EMAIL_1], reversible via placeholder map; "mask" = j***@a***.com / **** 1111; "hash" = [EMAIL:3f2a9c0d1b7e] salted sha256 prefix (random salt per run).
detectAddressesNoOptional boolean, default false. true detects street addresses (STREET_ADDRESS, English formats) and NER place names (LOCATION).
defaultPhoneRegionNoOptional, default "US". ISO 3166-1 alpha-2 country code (exactly 2 letters, case-insensitive) used to parse phone numbers written without a +country prefix. Examples: "US", "DE", "GB"
returnPlaceholderMapNoOptional boolean, default false. true (mode="redact" + redactionStyle="placeholder" only) adds placeholder_map {"[EMAIL_1]":"jane@acme.com"} to each row; pass it to restore_placeholders after the LLM step. Contains the ORIGINAL sensitive values.

Output Schema

NameRequiredDescriptionDefault
runNoOnly with waitForFinish=false: run_id, status, dataset_id, console_url
countYesNumber of rows in items
itemsYesDataset rows: type=document (findings, risk_level, output_text) or type=error

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.1.1
    • changedInput schema / properties / mode / description
      Previous value: -"Optional, one of \"detect\" | \"redact\" | \"restore\", default \"redact\". \"detect\" = report findings only; \"redact\" = also return output_text with values replaced; \"restore\" = replace placeholders in texts with originals from placeholderMap. Example: \"detect\""New value: +"Optional, one of \"detect\" | \"redact\" | \"restore\", default \"redact\". \"detect\" = report findings only; \"redact\" = also return output_text with values replaced; \"restore\" = replace placeholders in texts with originals from placeholderMap (paid run; restore_placeholders does the same for free). Example: \"detect\""
    • changedInput schema / properties / returnPlaceholderMap / description
      Previous value: -"Optional boolean, default false. true (mode=\"redact\" + redactionStyle=\"placeholder\" only) adds placeholder_map {\"[EMAIL_1]\":\"jane@acme.com\"} to each row, needed for restore mode. Contains the ORIGINAL sensitive values."New value: +"Optional boolean, default false. true (mode=\"redact\" + redactionStyle=\"placeholder\" only) adds placeholder_map {\"[EMAIL_1]\":\"jane@acme.com\"} to each row; pass it to restore_placeholders after the LLM step. Contains the ORIGINAL sensitive values."
  2. Changed2 schema fields changedv1.1.0
    • addedInput schema / properties / waitForFinish
      Added value: +{
      +  "description": "Optional boolean, default true. true waits up to 280 s and returns the rows; false starts the run and returns immediately with run.run_id (poll get_run_results). Same price either way. Example: false",
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / run
      Added value: +{
      +  "additionalProperties": {},
      +  "description": "Only with waitForFinish=false: run_id, status, dataset_id, console_url",
      +  "type": "object"
      +}
  3. Changed12 schema fields changed
    • changedInput schema / properties / allowList / description
      Previous value: -"Exact values that are never flagged, e.g. [\"support@yourcompany.com\"]. Default []."New value: +"Optional, default []. Exact values that are never flagged (whole value, case-insensitive; not substrings). Example: [\"support@yourcompany.com\"]"
    • changedInput schema / properties / defaultPhoneRegion / description
      Previous value: -"ISO 3166-1 alpha-2 country code used to parse phone numbers written without +country prefix, e.g. \"US\" (default), \"DE\", \"GB\"."New value: +"Optional, default \"US\". ISO 3166-1 alpha-2 country code (exactly 2 letters, case-insensitive) used to parse phone numbers written without a +country prefix. Examples: \"US\", \"DE\", \"GB\""
    • changedInput schema / properties / detectAddresses / description
      Previous value: -"Default false. Detect street addresses (English formats) and NER place names."New value: +"Optional boolean, default false. true detects street addresses (STREET_ADDRESS, English formats) and NER place names (LOCATION)."
    • changedInput schema / properties / detectNames / description
      Previous value: -"Default false. Detect person names with English NER (lower precision, slightly slower)."New value: +"Optional boolean, default false. true detects person names (type PERSON) with English NER (lower precision, slightly slower; each finding billed)."
    • changedInput schema / properties / documentUrls / description
      Previous value: -"Public http(s) URLs of txt, md, json, csv, HTML or PDF files (max 10 MB each; PDFs text layer only). Example: [\"https://example.com/report.pdf\"]. Optional if texts is given."New value: +"Optional if texts is given. Absolute public http(s) URLs of txt, md, json, csv, HTML or PDF files (max 10 MB each; PDFs text layer only, no OCR), fetched by the Actor; unreachable URLs give free DOCUMENT_FETCH_FAILED rows. Example: [\"https://example.com/report.pdf\"]"
    • changedInput schema / properties / entityTypes / description
      Previous value: -"Only report these entity types, e.g. [\"EMAIL\",\"CREDIT_CARD\",\"AWS_ACCESS_KEY\"]. Omit/empty = all enabled detectors. Valid names: see list_detectors."New value: +"Optional, default omitted/[] = all enabled detectors. Entity type names (case-insensitive) from list_detectors, without the \"(opt-in)\" notes. Example: [\"EMAIL\",\"CREDIT_CARD\",\"AWS_ACCESS_KEY\"]"
    • changedInput schema / properties / entropyScan / description
      Previous value: -"Default false. Also flag unlabeled random-looking tokens of 20+ chars (catches unknown key formats; may flag hashes/IDs)."New value: +"Optional boolean, default false. true also flags unlabeled random-looking tokens of 20+ chars as HIGH_ENTROPY_STRING (catches unknown key formats; may flag hashes/IDs)."
    • changedInput schema / properties / mode / description
      Previous value: -"\"detect\" = report findings only; \"redact\" (default) = also return output_text with values replaced; \"restore\" = replace placeholders in texts with originals from placeholderMap."New value: +"Optional, one of \"detect\" | \"redact\" | \"restore\", default \"redact\". \"detect\" = report findings only; \"redact\" = also return output_text with values replaced; \"restore\" = replace placeholders in texts with originals from placeholderMap. Example: \"detect\""
    • changedInput schema / properties / placeholderMap / description
      Previous value: -"Only for mode=\"restore\": map of placeholder -> original value returned by a previous redact call, e.g. {\"[EMAIL_1]\":\"jane@acme.com\"}. Default {}."New value: +"Optional, default {}; used only with mode=\"restore\". Object mapping placeholder -> original value, as returned in placeholder_map by a previous redact call. Example: {\"[EMAIL_1]\":\"jane@acme.com\"}"
    • changedInput schema / properties / redactionStyle / description
      Previous value: -"Used in redact mode. \"placeholder\" (default) = [EMAIL_1], reversible via placeholder map; \"mask\" = j***@a***.com / **** 1111; \"hash\" = [EMAIL:3f2a9c0d1b7e] salted sha256 prefix."New value: +"Optional, one of \"placeholder\" | \"mask\" | \"hash\", default \"placeholder\"; used in mode=\"redact\" only. \"placeholder\" = [EMAIL_1], reversible via placeholder map; \"mask\" = j***@a***.com / **** 1111; \"hash\" = [EMAIL:3f2a9c0d1b7e] salted sha256 prefix (random salt per run)."
    • changedInput schema / properties / returnPlaceholderMap / description
      Previous value: -"Default false. If true, each row includes placeholder_map {\"[EMAIL_1]\":\"jane@acme.com\"} needed for restore mode. Contains the original sensitive values."New value: +"Optional boolean, default false. true (mode=\"redact\" + redactionStyle=\"placeholder\" only) adds placeholder_map {\"[EMAIL_1]\":\"jane@acme.com\"} to each row, needed for restore mode. Contains the ORIGINAL sensitive values."
    • changedInput schema / properties / texts / description
      Previous value: -"Documents to scan, one string per document (prompt, chat message, ticket, log line, file content). Example: [\"Hi, I am Jane (jane.doe@acme.com)\"]. Optional if documentUrls is given."New value: +"Optional if documentUrls is given (at least one of the two is required). One string per document (prompt, chat message, ticket, log, file content), <= 1,000,000 chars each (longer is truncated); one billed document each. Example: [\"Hi, I am Jane (jane.doe@acme.com)\"]"
  4. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already declare readOnlyHint/idempotentHint/destructiveHint=false, and the description adds the operational context that matters: it is a paid Apify Actor run with per-document and per-finding pricing, error rows are free, a 1000-document cap, a 280s wait, and exactly what each call bills. It also discloses that placeholder_map carries ORIGINAL sensitive values and that numbering restarts per call, which is the kind of safety-relevant behavior structured fields cannot express. (Minor tension: 'random salt per run' in hash mode means repeated calls differ, but this concerns return values rather than state mutation, so it does not amount to a contradiction of idempotentHint.)

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

Conciseness4/5

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

Headers (WHAT/WHEN TO USE/WHEN NOT TO USE/COST/RETURNS/EXAMPLE/PARAMETERS) make a long body navigable and front-load the identity of the tool. The length is largely justified by 13 parameters and a paid pipeline, but there is some repetition (the restore 'same output for free' caveat and billing behavior are restated more than once), which keeps it from a 5.

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 13-parameter, nested-object, paid tool with an async path, the description covers everything an agent needs: cost model, batching limits, the waitForFinish=false polling handoff to get_run_results, error-row semantics, and the round-trip contract with restore_placeholders. An output schema exists, yet the RETURNS note still flags the critical distinction between masked findings and the original-value placeholder map.

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

Parameters5/5

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

Although schema description coverage is 100%, the description adds the cross-parameter logic the schema cannot: at least one of texts/documentUrls is required despite both being optional, mode gates which other fields apply, returnPlaceholderMap only functions with redact+placeholder, detectNames/detectAddresses must be true before PERSON/LOCATION/STREET_ADDRESS can appear in entityTypes, and entityTypes filters post-detection (unknown names silently match nothing). This meaningfully exceeds the schema.

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 WHAT section names a specific verb (scans/detects/redacts) and resource (text documents and public URLs) and enumerates the entity classes it covers. It explicitly positions itself against siblings ('the only tool in this server that inspects content') and routes to list_detectors, restore_placeholders, and get_run_results by name, so an agent can distinguish it without opening any schema.

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?

Dedicated WHEN TO USE and WHEN NOT TO USE blocks name the exact scenarios (before sending prompts/tickets/logs to an LLM) and the precise alternatives for each edge case: restore_placeholders for putting originals back, list_detectors for entity types, get_run_results to avoid re-billing. It even calls out non-goals (no OCR, not for email deliverability).

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