trustboost-pii-sanitizer
PII sanitization layer for autonomous AI agent pipelines. Detects and redacts emails, phone numbers, national IDs, private keys, and financial data before text reaches LLMs. Supports EN, ES (LATAM), PT (BR/PT), DE, JA.
README
TrustBoost PII Sanitizer
A precision PII redaction layer for autonomous AI agent pipelines. Detects and redacts personally identifiable information before it reaches LLM providers, across English, Spanish (LATAM), Portuguese (BR/PT), German, and Japanese.
- Endpoint:
https://api.trustboost.dev/sanitize - Stack: FastAPI · OpenAI
gpt-4o-mini(temperature 0) · Supabase · Solana payments via Helius
Try it in 10 seconds — no wallet needed
curl -X POST https://api.trustboost.dev/sanitize/preview \
-H "Content-Type: application/json" \
-d '{"text": "My name is John Doe, email john@gmail.com, SSN 123-45-6789"}'
{
"sanitized_content": "My name is [REDACTED], email [REDACTED], SSN [REDACTED]",
"safety_score": 0.6,
"risk_category": "PRIVATE",
"demo": true,
"requests_remaining": 2,
"next": "https://github.com/teodorofodocrispin-cmyk/TrustBoost-PII-Sanitizer#trial"
}
3 free previews per IP · no account · no wallet · no setup. Ready for more? See Trial mode below — 50 free sanitizations with a Solana wallet.
MCP Server — Claude, Cursor & Windsurf native integration
TrustBoost is available as an MCP (Model Context Protocol) server. Add it to any MCP-compatible agent in one line:
{
"mcpServers": {
"trustboost": {
"url": "https://api.trustboost.dev/mcp"
}
}
}
Once connected, your agent can call sanitize_pii automatically
before sending any text to an LLM:
# Manifest
curl https://api.trustboost.dev/mcp
# Execute
curl -X POST https://api.trustboost.dev/mcp \
-H "Content-Type: application/json" \
-d '{"tool": "sanitize_pii", "input": {"text": "My email is john@gmail.com"}}'
Compatible with: Claude Code · Cursor · Windsurf · Any MCP-compatible agent
Quick start
curl -X POST https://api.trustboost.dev/sanitize \
-H 'Content-Type: application/json' \
-d '{
"text": "My email is jane@example.com and my AWS key is AKIAIOSFODNN7EXAMPLE",
"tx_hash": "TRIAL",
"wallet_address": "your-agent-id"
}'
Trial mode (tx_hash="TRIAL") gives 50 free sanitizations per wallet_address.
Paid mode requires 149 USDC on Solana to the configured payment wallet, which
unlocks 10,000 sanitizations per transaction signature.
Response schema (v2.2)
{
"status": "success",
"request_id": "TRIAL",
"data": {
"message": "Content successfully sanitized and logged.",
"sanitized_content": "My email is [REDACTED] and my AWS key is [REDACTED]",
"safety_score": 0.6,
"risk_category": "CRITICAL",
"entities_removed": true,
"entities": [
{ "type": "email", "category": "PRIVATE", "redacted_text": "jane@example.com" },
{ "type": "aws_access_key", "category": "CRITICAL", "redacted_text": "AKIAIOSFODNN7EXAMPLE" }
],
"redaction_source": "server",
"timestamp": "2026-05-03T23:48:14.500705+00:00",
"usage_metrics": { "quota_remaining": 48, "quota_limit": 50 }
},
"billing": { "license_type": "TRIAL", "status": "active" }
}
Field guide
| Field | Type | Notes |
|---|---|---|
sanitized_content |
string |
Same language and structure as input, with PII replaced by [REDACTED]. |
entities |
Entity[] |
One element per [REDACTED] tag. Stable, machine-friendly. |
safety_score |
float 0.0 – 1.0 |
Server-side, deterministic. Computed from entities, not the model. |
risk_category |
CRITICAL/PRIVATE/SENSITIVE/CLEAN |
Highest tier present in entities. |
entities_removed |
bool |
Convenience: true iff entities is non-empty. |
redaction_source |
"model" | "server" | "fallback_full_redaction" |
Telemetry: who actually performed the redaction (see below). |
unmatched_entities |
Entity[] (optional) |
Entities the model reported but whose redacted_text wasn't found verbatim in the input. Omitted when empty. |
Risk weights
safety_score is the sum of per-entity weights, capped at 1.0:
CRITICAL→ 0.40 (API keys, private keys, seed phrases, credentials, card numbers, …)PRIVATE→ 0.20 (emails, phone numbers, national IDs, addresses, names, …)SENSITIVE→ 0.05 (handles, partial identifiers, DOB, …)
risk_category is the highest-severity tier with at least one entity, or
"CLEAN" if entities is empty.
Server-side redaction enforcement (v2.2)
The model returns two things that have to agree: cleaned_text and
entities. In practice they sometimes disagree — the model can correctly
identify an entity in entities but fail to actually replace it in
cleaned_text. That produces a sanitized_content that still leaks PII
while the audit trail says everything is fine, which is worse than no audit
trail.
v2.2 fixes this structurally. The model is now treated purely as a
detector: it returns the entity list. The server is the redactor: for
every entity whose redacted_text is a non-empty substring of the original
input, the server replaces all occurrences with [REDACTED]. Long
entities are processed before short ones to avoid partial overlap.
Conservative redaction by design: if the same value (e.g. 田中太郎)
appears twice in the input, both occurrences are scrubbed.
The redaction_source field tells you what happened:
"model"— the model'scleaned_textalready matched the entity list, so server-side enforcement was a no-op (the model did its job)."server"— the server-side enforcer replaced one or more entities the model failed to remove. Track this metric over time as a model-reliability signal: a risingserverrate means the prompt or model is drifting."fallback_full_redaction"— the model returned malformed JSON; the failsafe parser triggered and the entire input was redacted as a singleCRITICALentity. Should be near-zero in steady state.
When the model's redacted_text does not appear verbatim in the input
(paraphrasing, normalization, or hallucination), the entity is preserved in
entities (and counts toward safety_score) but is also returned in
unmatched_entities so callers can audit it.
Failure mode: fail-safe, not fail-open
If the upstream model returns malformed JSON, the response degrades to a
single CRITICAL entity covering the entire input rather than risking a
silent leak. Over-redaction is always preferred over under-redaction.
Languages and patterns
The system prompt covers, among others:
- English (global): emails, phones, SSN, credit cards, IBAN, IPs, addresses, and provider-specific API keys (OpenAI, Anthropic, GitHub, AWS, Google, Slack, HuggingFace, Stripe), private keys, crypto wallets, seed phrases.
- Spanish (LATAM): RFC, CURP, CUIT/CUIL, RUT, DNI, RUC, NIT, Cédula, country phones.
- Portuguese (BR/PT): CPF, CNPJ, RG, NIF, NUS, CEP, country phones.
- German (DE/AT/CH): Personalausweis, Steuer-IDs, Sozialversicherungsnummer, IBAN DE, addresses.
- Japanese: マイナンバー, 法人番号, 運転免許証, パスポート, 健康保険証, 電話番号, 住所, and 氏名 (full names in kanji, mixed scripts, katakana, or hiragana).
Running locally
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # then fill in real keys
uvicorn main:app --reload
Required environment variables:
OPENAI_API_KEYSUPABASE_URL,SUPABASE_KEYHELIUS_API_KEY,PAYMENT_WALLET- Optional:
TRIAL_QUOTA(default 50),PAID_QUOTA(default 10000),REQUIRED_PAYMENT_USDC(default 149)
Tests
pip install pytest
python -m pytest tests/test_sanitize.py -v # unit tests, no creds needed
TRUSTBOOST_LIVE=1 python -m pytest tests/test_live.py -v # hits real /sanitize
The live tests consume TRIAL quota; set TRUSTBOOST_WALLET to a CI-specific
identifier so they don't share quota with developer wallets.
Versioning
- 2.2 — server-side redaction enforcer,
redaction_sourcetelemetry,unmatched_entitiesaudit field. Conservative replace-all-occurrences. Fixes the v2.1 class of bug where an entity could appear inentities[]without being removed fromsanitized_content. - 2.1 — structured
entitiesarray, server-side deterministic scoring, hardened JSON parsing, improved Japanese 氏名 detection. - 2.0 — multilingual prompt rewrite.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。