Skip to main content
Glama

Fairquery Agent Trust & Data Safety

Fortress Shield: scan text for PII and secrets (free, on this Worker)

pii_scan_text
Read-onlyIdempotent

WHAT: Fortress Shield (agent I/O PII protection). Detect PII (emails incl. "jane [at] acme [dot] com" and "jane at acme dot com" forms, phones, US SSNs/ITINs, Luhn-valid cards, mod-97 IBANs, UK NINOs, IPv4 and full or compressed IPv6, MAC addresses, labelled dates of birth / passports / driver's licences / MRNs / health-plan ids / ABA routing numbers, Canadian SIN, NPI/DEA/MBI, VIN, Bitcoin/Ethereum wallets, ES DNI/NIE, IT codice fiscale, FR NIR, IN Aadhaar/PAN, ZIP/postcodes in a residence or ZIP context) and credential-shaped strings (common provider token formats, signed web tokens, PEM key blocks incl. a header without its END line, user:pass in URLs, key=value assignments; full list from pii_list_detectors) in text, plus your own customDetectors. Text is normalized first (NFKC, zero-width characters removed, Cyrillic/Greek look-alike letters folded), so hidden characters do not split a match. Detection only: matches are masked in the output and nothing is sent anywhere. WHEN: Before sending prompts, tickets, logs or files to an LLM or third party; to audit text for leaked credentials. Findings are paged across all documents. WHEN NOT: To get sanitized text use pii_redact_text. For unlabelled person names (NER), or to fetch PDFs and remote documents, use pii_guard_documents (paid). http(s) URLs in text you already have are detected here for free. Not for images (no OCR). COST: Free. Regex and validators on this Worker; no APIFY_TOKEN. RETURNS: Paged findings across all documents, each with a masked preview and, when a label raised it, context; raw values are never returned. meta.documents[] has context_lowered (matches kept at low confidence because of a negative context word), context_suppressed (matches left out with contextMode "drop") and typed_placeholders (placeholder-shaped text such as "[EMAIL_1]" already in the input), below_threshold and context_report (which context word lowered or skipped which type; no values). JSON input: findings carry json_path. meta.audit (counts only), meta.secret_guidance (provider + revoke URL per detected credential type), meta.compliance (HIPAA Safe Harbor identifiers seen). Errors: INPUT_TOO_LARGE, INVALID_PATTERN. BEHAVIOR: Runs on this Fairquery-hosted Worker (Cloudflare), not on the caller's machine; inputs leave the client. This Worker's code is designed not to store inputs, results, or an Apify token. No further network call; the text is not forwarded to another service. Milliseconds. PARAMETERS: texts: one array element per document; each finding carries doc_index = the element's 0-based position, and the 500,000-char cap applies to the SUM of all elements (over it -> INPUT_TOO_LARGE; split into several calls). start/end are offsets in your ORIGINAL text. entityTypes: filters built-in findings after detection; names are case-insensitive, unknown names silently match nothing, NER-only types (PERSON, LOCATION) never match here and STREET_ADDRESS needs detectAddresses=true; customDetectors always run. allowList: whole matched value, case-insensitive; allowDomains: email domains incl. subdomains (allow "yourco.com" to exempt support@yourco.com); allowPatterns: regular expressions tested against the value. entropyScan: only adds HIGH_ENTROPY_STRING findings; it never removes others. defaultPhoneRegion: affects only national-format numbers such as "030 1234567" (needs "DE"); "+49 ..." numbers parse with any region. limit/offset page the flat findings list across all documents, while meta.documents always summarises every document; fetch the next page with offset = nextOffset until hasMore is false. EXAMPLE: {"texts":["Mail jane@acme.com, key AKIAIOSFODNN7EXAMPLE"]} -> 2 findings: EMAIL (masked "j***@a***.com"), AWS_ACCESS_KEY; risk_level "critical".

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "texts": "<texts>"
    },
    "name": "pii_scan_text"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoOptional page size: items to return, integer 1-1000 (default 100). Example: 50
textsYesRequired. 1-50 documents (prompt, chat message, log, file content), each <= 200,000 chars, total <= 500,000 chars. Example: ["Mail jane@acme.com, key AKIAIOSFODNN7EXAMPLE"]
offsetNoOptional zero-based number of items to skip, integer 0-1000000 (default 0); pass nextOffset from the previous response, e.g. 100
allowListNoOptional, default [] (nothing exempt). 0-500 exact values (<= 500 chars each) that are never flagged; whole-value, case-insensitive match, not substring. Example: ["support@yourco.com","192.0.2.1"]
contextModeNoOptional, "lower" | "drop", default "lower". What happens to a match that only a negative context word argues against: "lower" still flags/redacts it with confidence "low" and context "negative:<reason>" (counted in context_lowered); "drop" (strict precision) leaves it untouched (counted in context_suppressed).lower
detectNamesNoOptional. Omit to keep labelled person names (Dear, Patient, sign-off). false turns those labelled hits off. true keeps them; full person-name NER runs only in the Apify Actor (pii_guard_documents).
entityTypesNoOptional, default omitted = every free-tool detector (pii_list_detectors rows with local:true). 0-40 detector type names (<= 40 chars, case-insensitive), e.g. ["EMAIL","CREDIT_CARD","AWS_ACCESS_KEY"]. Valid values: the "type" field of those rows; unknown names match nothing (no error)
entropyScanNoOptional boolean, default false. true also flags unlabeled random-looking tokens of 20-200 chars as HIGH_ENTROPY_STRING (catches unknown key formats; may flag hashes/UUIDs). Example: true
allowDomainsNoOptional, default []. 0-200 email domains whose addresses are never flagged; subdomains included. Example: ["yourco.com"] exempts support@yourco.com and a@eu.yourco.com
allowPatternsNoOptional, default []. 0-50 JavaScript regular expressions (<= 200 chars; no backreferences or nested quantifiers -> INVALID_PATTERN); a finding whose value matches any of them is not flagged. Example: ["^192\.0\.2\.","@example\.(com|org)$"]
minConfidenceNoOptional, "low" | "medium" | "high", default "low" (everything). Findings below this confidence are left in the text and counted per document as below_threshold (types only); combine with failClosed on pii_redact_text to withhold documents that contain them.low
contextScoringNoOptional boolean, default true. true uses the words around a match: labels like "SSN:", "phone:", "my cell", "call me" raise confidence, and a label earlier on the same line wins over a negative word. "version"/"v" before an IPv4 or phone-shaped number and "invoice"/"order"/"ticket"/"ref" before a bare phone-shaped number lower it (see contextMode). Phones with +country code, parentheses or two separators, and IPv4 with a port, CIDR suffix or 3-digit octet are never lowered. false = format-only scoring.
customDetectorsNoOptional, default []. 0-20 of your own detectors (regex pattern and/or terms dictionary) for account IDs, ticket formats or member numbers; findings use your type name with category "custom" and are redacted and restored like built-in types.
detectAddressesNoOptional boolean, default false. true also runs the street-address patterns on this Worker (STREET_ADDRESS: house number + street, PO Box, units, trailing city/state/ZIP or postcode; US/UK/FR/DE-style forms). Pattern-based, medium confidence; place-name NER (LOCATION) and person names stay Actor-only. Example: true
destinationPolicyNoOptional preset for where the text goes: "llm_public" | "llm_private" | "internal" | "logs" | "analytics". It sets minConfidence, contextMode, entropyScan, excludeEntityTypes and (pii_redact_text) failClosed / leakCheck; meta.destination_policy shows what was applied. Omit to use the individual parameters.
defaultPhoneRegionNoOptional, default "US". ISO 3166-1 alpha-2 code (2 letters, pattern ^[A-Za-z]{2}$, case-insensitive) used only for phone numbers written without a +country prefix. Examples: "US", "DE", "GB"US
excludeEntityTypesNoOptional, default []. 0-40 detector type names to switch off (case-insensitive), e.g. ["IP_ADDRESS","POSTAL_CODE"]; applied after entityTypes. customDetectors always run.

Output Schema

NameRequiredDescriptionDefault
metaNoTool-specific context (summary counts, cost notes, ...)
countYesNumber of items in this page
itemsYesResult rows for this page
totalYesTotal items before paging
offsetYesOffset of the first item in this page
hasMoreYesTrue if more items exist after this page
nextOffsetYesOffset to pass for the next page, or null

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / detectNames
      Added value: +{
      +  "description": "Optional. Omit to keep labelled person names (Dear, Patient, sign-off). false turns those labelled hits off. true keeps them; full person-name NER runs only in the Apify Actor (pii_guard_documents).",
      +  "type": "boolean"
      +}
  2. Changed3 schema fields changed
    • addedInput schema / properties / destinationPolicy
      Added value: +{
      +  "description": "Optional preset for where the text goes: \"llm_public\" | \"llm_private\" | \"internal\" | \"logs\" | \"analytics\". It sets minConfidence, contextMode, entropyScan, excludeEntityTypes and (pii_redact_text) failClosed / leakCheck; meta.destination_policy shows what was applied. Omit to use the individual parameters.",
      +  "enum": [
      +    "llm_public",
      +    "llm_private",
      +    "internal",
      +    "logs",
      +    "analytics"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / excludeEntityTypes
      Added value: +{
      +  "description": "Optional, default []. 0-40 detector type names to switch off (case-insensitive), e.g. [\"IP_ADDRESS\",\"POSTAL_CODE\"]; applied after entityTypes. customDetectors always run.",
      +  "items": {
      +    "maxLength": 40,
      +    "type": "string"
      +  },
      +  "maxItems": 40,
      +  "type": "array"
      +}
    • addedInput schema / properties / minConfidence
      Added value: +{
      +  "default": "low",
      +  "description": "Optional, \"low\" | \"medium\" | \"high\", default \"low\" (everything). Findings below this confidence are left in the text and counted per document as below_threshold (types only); combine with failClosed on pii_redact_text to withhold documents that contain them.",
      +  "enum": [
      +    "low",
      +    "medium",
      +    "high"
      +  ],
      +  "type": "string"
      +}
  3. Changed1 schema field changed
    • addedInput schema / properties / detectAddresses
      Added value: +{
      +  "default": false,
      +  "description": "Optional boolean, default false. true also runs the street-address patterns on this Worker (STREET_ADDRESS: house number + street, PO Box, units, trailing city/state/ZIP or postcode; US/UK/FR/DE-style forms). Pattern-based, medium confidence; place-name NER (LOCATION) and person names stay Actor-only. Example: true",
      +  "type": "boolean"
      +}
  4. Changed2 schema fields changed
    • addedInput schema / properties / contextMode
      Added value: +{
      +  "default": "lower",
      +  "description": "Optional, \"lower\" | \"drop\", default \"lower\". What happens to a match that only a negative context word argues against: \"lower\" still flags/redacts it with confidence \"low\" and context \"negative:<reason>\" (counted in context_lowered); \"drop\" (strict precision) leaves it untouched (counted in context_suppressed).",
      +  "enum": [
      +    "lower",
      +    "drop"
      +  ],
      +  "type": "string"
      +}
    • changedInput schema / properties / contextScoring / description
      Previous value: -"Optional boolean, default true. true uses the words just before a match: labels like \"SSN:\", \"phone:\", \"call me\" raise confidence; \"version\"/\"v\" before an IPv4 or phone-shaped number and \"invoice\"/\"order\"/\"ticket\"/\"zip\" before a phone-shaped number drop it (meta.documents[].context_suppressed counts them). false = format-only scoring."New value: +"Optional boolean, default true. true uses the words around a match: labels like \"SSN:\", \"phone:\", \"my cell\", \"call me\" raise confidence, and a label earlier on the same line wins over a negative word. \"version\"/\"v\" before an IPv4 or phone-shaped number and \"invoice\"/\"order\"/\"ticket\"/\"ref\" before a bare phone-shaped number lower it (see contextMode). Phones with +country code, parentheses or two separators, and IPv4 with a port, CIDR suffix or 3-digit octet are never lowered. false = format-only scoring."
  5. Changed4 schema fields changed
    • addedInput schema / properties / allowDomains
      Added value: +{
      +  "description": "Optional, default []. 0-200 email domains whose addresses are never flagged; subdomains included. Example: [\"yourco.com\"] exempts support@yourco.com and a@eu.yourco.com",
      +  "items": {
      +    "maxLength": 253,
      +    "minLength": 1,
      +    "pattern": "^@?(?:\\*\\.)?[A-Za-z0-9.-]+$",
      +    "type": "string"
      +  },
      +  "maxItems": 200,
      +  "type": "array"
      +}
    • addedInput schema / properties / allowPatterns
      Added value: +{
      +  "description": "Optional, default []. 0-50 JavaScript regular expressions (<= 200 chars; no backreferences or nested quantifiers -> INVALID_PATTERN); a finding whose value matches any of them is not flagged. Example: [\"^192\\.0\\.2\\.\",\"@example\\.(com|org)$\"]",
      +  "items": {
      +    "maxLength": 200,
      +    "minLength": 1,
      +    "type": "string"
      +  },
      +  "maxItems": 50,
      +  "type": "array"
      +}
    • addedInput schema / properties / contextScoring
      Added value: +{
      +  "default": true,
      +  "description": "Optional boolean, default true. true uses the words just before a match: labels like \"SSN:\", \"phone:\", \"call me\" raise confidence; \"version\"/\"v\" before an IPv4 or phone-shaped number and \"invoice\"/\"order\"/\"ticket\"/\"zip\" before a phone-shaped number drop it (meta.documents[].context_suppressed counts them). false = format-only scoring.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / customDetectors
      Added value: +{
      +  "description": "Optional, default []. 0-20 of your own detectors (regex pattern and/or terms dictionary) for account IDs, ticket formats or member numbers; findings use your type name with category \"custom\" and are redacted and restored like built-in types.",
      +  "items": {
      +    "properties": {
      +      "caseSensitive": {
      +        "default": false,
      +        "description": "Optional boolean, default false.",
      +        "type": "boolean"
      +      },
      +      "confidence": {
      +        "default": "high",
      +        "description": "Optional, default \"high\".",
      +        "enum": [
      +          "high",
      +          "medium",
      +          "low"
      +        ],
      +        "type": "string"
      +      },
      +      "pattern": {
      +        "description": "Optional JavaScript regular expression (<= 200 chars; no backreferences or nested quantifiers). Example: \"\\bMBR-\\d{8}\\b\"",
      +        "maxLength": 200,
      +        "minLength": 1,
      +        "type": "string"
      +      },
      +      "terms": {
      +        "description": "Optional dictionary: 0-500 literal terms matched as whole words. Example: [\"Project Bluebird\"]",
      +        "items": {
      +          "maxLength": 100,
      +          "minLength": 1,
      +          "type": "string"
      +        },
      +        "maxItems": 500,
      +        "type": "array"
      +      },
      +      "type": {
      +        "description": "Type name for this detector, 2-40 chars, letters/digits/_ (uppercased in output). Example: \"MEMBER_ID\"",
      +        "pattern": "^[A-Za-z][A-Za-z0-9_]{1,39}$",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "type"
      +    ],
      +    "type": "object"
      +  },
      +  "maxItems": 20,
      +  "type": "array"
      +}
  6. First observed

TDQS

A4.3/5.0
Behavior3/5

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

Annotations already establish readOnly, idempotent, non-destructive, closed-world, so the description's 'detection only, nothing is sent' partially restates them. It does add genuinely new behavioral context: execution on a Cloudflare-hosted Worker rather than the caller's machine, no storage of inputs, no downstream network call, millisecond latency, and error codes INPUT_TOO_LARGE/INVALID_PATTERN. However, the REQUIRES/output shape and paging behavior are largely covered by the output schema, so this is additive but not maximal.

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?

Uses front-loaded WHAT/WHEN/WHEN NOT/COST/RETURNS/BEHAVIOR/PARAMETERS/EXAMPLE headings, so an agent can skim to the relevant block, and the worked example with expected masks is high value. It is dense and slightly repetitive (free/Worker/local execution is restated in WHAT, COST and BEHAVIOR), costing some tightness.

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

Completeness3/5

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

For a 17-parameter tool this covers normalization behavior, paging protocol (offset = nextOffset until hasMore is false), error codes, and meta fields, with return details partly delegated to the output schema. It omits concrete guidance on when destinationPolicy presets should be preferred over individual parameters and does not explain what the 200,000-char per-item maxLength means relative to the stated 500,000 total beyond the SUM note.

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?

Schema coverage is 100%, yet the description adds meaning the schema cannot express: the 500,000-char cap applies to the SUM of texts elements, start/end are offsets into the ORIGINAL (pre-normalization) text, doc_index is the 0-based element position, unknown entityTypes silently match nothing, customDetectors always run despite entityTypes/excludeEntityTypes, and limit/offset page findings while meta.documents always summarizes all documents. Cross-parameter interactions like destinationPolicy overriding others are also stated.

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?

Opens with a specific verb+resource ('Detect PII ... and credential-shaped strings in text') and enumerates concrete detector families, including obfuscated email forms. It also names the sibling tools it is not (pii_redact_text, pii_guard_documents), so the agent can separate it from the four other pii_* tools without opening schemas.

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?

Has an explicit WHEN section ('before sending prompts, tickets, logs or files to an LLM') and a WHEN NOT section that routes to pii_redact_text for sanitized output and pii_guard_documents for NER/PDFs. It even clarifies a boundary case (http(s) URLs in text you already have are handled here for free).

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources