Building phi-guard-mcp: Catching PHI Leaks in AI-Generated Code
说明与用途
phi-guard-mcp 是一个本地工具,可检测并替换代码中的 PHI,防止泄露到 LLM、日志和分析中。
问题
AI coding agents can inadvertently leak protected health information (PHI) into LLM calls, logs, or analytics without any monitoring, leading to potential privacy violations.
结果
phi-guard-mcp detected all planted PHI leaks across multiple sinks with zero false positives, covering .ts, .js, .tsx, .jsx, .py, .go files and skipping node_modules and build directories.
工作流
- Install phi-guard-mcp globally via npm
- Add .mcp.json configuration to project root specifying the phi-guard server command
- Run phi-guard-mcp to scan the repository for PHI leaks
- Review flagged lines and use redact_suggest to replace PHI with placeholders
- Integrate the tool into AI agent prompts: "Scan this repo for PHI leaks" or "Redact this text"
证据
6/6 planted leaks detected across 5 different sinks (OpenAI, Anthropic, Sentry, Winston, PostHog/analytics)
0 false positives across 5 clean-code fixtures
Not a HIPAA certification or legal compliance guarantee — it's a linter-grade signal, not an audit
- 记录日期: 2026-09-05T18:00:30.047Z