phiguard
Installs a Git pre-commit hook that runs phiguard scan --staged on staged clinical fixtures (JSON, HL7 v2, XML) and blocks commits containing high/critical unredacted PHI.
Ships a GitHub Action (tranhoangtu-it/phiguard@v1) that runs PHI compliance scans inside GitHub Actions workflows with configurable target, profile, fail-on threshold and SARIF report output.
Provides .[pre-commit](/mcp/integrations/pre-commit)-hooks.yaml hooks (phiguard, phiguard-hipaa) so the pre-commit framework can automatically audit and block unredacted PHI in staged files.
Generates a dynamic Shields.io compliance badge reflecting the scan result for embedding in project README files.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
phiguard
Zero-dependency PHI de-identification, pseudonymization, and compliance guardrails for HL7 FHIR R4/R5, HL7 v2.x, Vietnam MOH QĐ 130/4750 BHYT XML, Japan APPI / JP-Core, and US HIPAA Safe Harbor — 100% offline.
npx phiguard scan ./clinical-fixturesTry the 100% Offline Browser Playground — inspect, de-identify, validate, and re-hydrate FHIR R4 Bundles, HL7v2 messages, and Vietnam QĐ 4750 XML directly in your browser with zero uploads and zero network calls.
Why phiguard?
Healthcare engineering teams adopting AI agents and building EHR/HIS pipelines hit four immediate failure modes when using generic regex redactors or heavy Python NLP servers:
Broken Clinical Structure — Naive
[REDACTED]replacement corrupts FHIRBundlecross-resourceReferencelinks (Patient/123), shifts pipe positions in HL7 v2PID/PV1/OBX, and misses Base64-encoded XML inside<NOIDUNGFILE>in Vietnam QĐ 4750GIAMDINHHSclaims.Narrative & Edge-Case Leakage — Stripping
Patient.namewhile leavingPatient.text.divXHTML narratives, 5-digit ZIP codes in the 17 restricted HIPAA Safe Harbor ZIP-3 areas (830xx->00000), or birth years revealing age >89 fails compliance audits.Lost Context for Downstream AI — Replacing every person with
[NAME]destroys co-reference ([PATIENT_01]vs[PRACTITIONER_01]), and stripping every date destroys length-of-stay intervals unless dates are shifted deterministically per subject.Zero Cloud Trust for Clinical Data — Security teams cannot send real or borderline clinical fixtures to commercial APIs or install 40-package dependency trees just to audit prompts, tests, or MCP payloads.
Related MCP server: Payment Intelligence
Key Capabilities
Capability | US HIPAA Safe Harbor | Vietnam MOH QĐ 130/4750 | Japan APPI / JP-Core |
Checksums & Formats | SSN, NPI ( | 15-char BHYT (42 prefixes), 12-digit CCCD ( | 12-digit MyNumber ( |
FHIR R4/R5 AST & Bulk NDJSON | Consistent | BHYT/CCCD identifiers, localized clinic labels & narrative scrubbing |
|
HL7 v2.x ( | Preserves | Free-text Vietnamese PHI inside | Free-text Japanese PHI inside |
De-identification Modes |
| Same + round-trip Base64 XML preservation | Same + consistent entity tokens |
CI/CD & AI Agent Integration | SARIF 2.1.0, Markdown, JUnit XML, JSON, | Same | Same |
Quick Start
# Audit files or directories across all profiles (exit 1 if >= high severity)
npx phiguard scan ./fixtures --profile all --fail-on high
# Export SARIF 2.1.0 or Markdown compliance reports
npx phiguard scan ./fixtures --sarif -o phiguard.sarif
npx phiguard scan ./fixtures --markdown --summary-only -o COMPLIANCE.md
# De-identify FHIR R4 Bundle with deterministic date shifting & HMAC-signed TokenVault
npx phiguard clean patient-bundle.json \
--profile hipaa \
--mode date-shift \
--secret "$VAULT_SECRET" \
--vault-out vault.json \
-o patient-bundle.safe.json
# Restore authorized records using the HMAC-verified TokenVault
npx phiguard reidentify patient-bundle.safe.json --vault vault.json --secret "$VAULT_SECRET"
# Clean FHIR Bulk Data ($export .ndjson) preserving cross-line Patient/Encounter references
npx phiguard clean bulk-export.ndjson --profile hipaa --mode pseudonymize -o bulk-export.safe.ndjson
# Clean clinical EHR CSV/TSV exports while preserving numeric vitals/labs & per-patient date intervals
npx phiguard clean patient-cohort.csv --profile hipaa --mode date-shift -o patient-cohort.safe.csv
# Batch-deidentify an entire directory of clinical files sharing a single TokenVault
npx phiguard clean-dir ./clinical-fixtures -o ./clinical-safe --vault-out vault.json
# Validate FHIR R4 structural referential integrity + HIPAA Safe Harbor compliance
npx phiguard validate patient-bundle.safe.json --profile hipaa
# Clean Vietnam MOH QD 4750 BHYT XML (including Base64 NOIDUNGFILE payloads)
npx phiguard clean claim-4750.xml --profile vn-byt --mode pseudonymize -o claim-4750.safe.xml
# Install Git pre-commit (--staged) + Claude Code PreToolUse PHI blocker + .mcp.json
npx phiguard guard install
# Generate a dynamic Shields.io compliance badge for your README
npx phiguard scan ./fixtures --badgePreventative Hooks (phiguard guard & .pre-commit-hooks.yaml)
Stop unredacted PHI before it enters git history or an AI coding assistant transcript:
Pre-commit Framework (
.pre-commit-hooks.yaml) — supportsrepo: https://github.com/tranhoangtu-it/phiguard(phiguardandphiguard-hipaahooks).Git
pre-commitHook — runsnpx --no-install phiguard scan --staged --fail-on highautomatically on staged clinical fixtures, JSON, HL7, and XML files.Claude Code
PreToolUseHook (phiguard guard-check) — evaluatesRead|Edit|Write|MultiEdit|Bashpayloads on stdin and exits with code2if high/critical unredacted PHI is present..mcp.jsonRegistration — configures the stdiophiguardMCP server alongside existing servers without overwriting them.
MCP Server (Claude Desktop, Cursor, VS Code, Codex, Gemini CLI)
Expose all 5 local-first guardrails (phiguard_scan, phiguard_deidentify, phiguard_reidentify, phiguard_validate_fhir, phiguard_rules) over stdio JSON-RPC 2.0:
{
"mcpServers": {
"phiguard": {
"command": "npx",
"args": ["-y", "phiguard", "mcp"]
}
}
}Or manage/install alongside your existing stack via mcphub and mcpman.
GitHub Action (@v1)
- name: PHI Compliance Gate
uses: tranhoangtu-it/phiguard@v1
with:
target: "./src"
profile: "hipaa"
fail-on: "high"
sarif-file: "phiguard.sarif"TypeScript / JavaScript SDK (Node & Browser)
import { deidentify, reidentify, scan, validateFhirHipaa } from "phiguard";
const audit = scan(fhirBundleJson, { profile: "hipaa" });
const { output, vault } = deidentify(fhirBundleJson, {
profile: "hipaa",
mode: "pseudonymize",
secret: "clinic-hmac-key",
});
const validation = validateFhirHipaa(output, "hipaa");
console.log(validation.hipaaCompliant, validation.score); // true, 100
const restored = reidentify(output, vault, "clinic-hmac-key");Related Open-Source Security & Healthcare Tools
dicomguard— Zero-dependency binary DICOM Part 10 inspector, NEMA PS3.15 de-identifier, burned-in PHI risk detector & MCP server (Live Playground).clawleak— Find, losslessly redact, and block plaintext API keys/secrets leaked into AI coding agents (0deps, 100% offline).mcphub— Curated hub & CLI for verified MCP servers.mcpman— Universal package manager & security auditor for MCP servers.
License
MIT. See LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Privacy-preserving synthetic health data generation. FHIR R4/R5 compliant.
Guardrailed FHIR access for AI agents: PHI redaction, audit trail, step-up auth, tenant isolation
HealthGuard - 12-tool health/medical AI safety MCP: PII redaction, HIPAA, GDPR Art.9.
Hybrid Edge AI firewall (Llama Guard 3 + heuristics) for prompt injection & PII via x402 USDC.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables coding assistants to check code for common health-data mistakes locally without an account, and, with a configured core service, de-identify clinical text, restore placeholders, and append tamper-evident audit log entries.16 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to explain, scrub and check ISO 20022 payment messages and SSI files entirely on the local machine, including CBPR+ readiness hints, lifecycle triage, IBAN/BIC validation and payment-vs-SSI checks against the user's own licensed reference data. Runs as a local stdio MCP server with no network calls, telemetry or bundled vendor data.MIT
- AlicenseAqualityBmaintenanceExposes 24 evidence-grounded medical skills as JSON-RPC tools over stdio, letting agents run deterministic clinical calculators, PHI de-identification, negation-preserving multilingual parsing, and drug interaction checks locally with no token cost. It also enforces provenance and safety gates so high-risk dosing or prescribing decisions require documented clinical records rather than model inference.10847 npm1Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables AI clients to perform sandboxed file-system operations, read-only SQLite querying and schema inspection, environment diagnostics, and cryptographic hashing over Stdio or HTTP using JSON-RPC.2MIT