phi-guard-mcp
This server is a local-first MCP tool that catches PHI in source code before it reaches LLMs, logs, or analytics.
redact_suggest: Detect PHI-shaped values (SSN, MRN, DOB, name, phone, email) in a raw text snippet and get a redacted version plus detected items with confidence scores.
scan_code: Scan a local source directory for sensitive identifiers (patient, diagnosis, dob, ssn, mrn, etc.) appearing on the same line as risky sinks like OpenAI/Anthropic calls, console.log, logger, winston, pino, .track(), or Sentry capture calls.
Run locally over stdio: No code or detected values are sent anywhere; works entirely on your machine.
Works across languages: Scans TypeScript, JavaScript, TSX/JSX, Python, and Go files, while skipping build/output directories and dotfiles.
Quiet by design: Ignores whole-line comments and only flags same-line identifier+sink combinations, keeping false positives low.
Supports verification: Run fixture tests, typecheck, smoke test, or drive the tools via the MCP Inspector.
Detects potential PHI leakage in source code that passes sensitive-looking identifiers into OpenAI API calls, and helps redact such text via the redact_suggest tool.
Detects potential PHI leakage in source code that passes sensitive-looking identifiers into pino logger calls, flagging risky log statements before they ship.
Detects potential PHI leakage in source code that passes sensitive-looking identifiers into PostHog analytics tracking calls such as .track().
Detects potential PHI leakage in source code that passes sensitive-looking identifiers into Sentry error-reporting calls such as captureException, captureMessage, and capture.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@phi-guard-mcpscan my codebase for PHI leaks before I push"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
phi-guard-mcp
A local-first MCP server that catches PHI (protected health information) flowing into LLM prompts, log statements, and analytics calls — in your source code, before it ships.
It runs entirely on your machine over stdio. No code, no snippets, and no detected values are ever sent anywhere.
Why
The risky moment in a healthcare codebase is rarely the database. It's the line
where a patient record gets interpolated into a prompt, a console.log, or an
analytics event. Those lines look harmless in review and never show up in
infrastructure scanning, because nothing is misconfigured — the code is just
doing what it says.
Related MCP server: phi-guard-mcp
Tools
redact_suggest
Takes a raw text snippet — a log line, a prompt, an error message — detects PHI-shaped values, and returns a redacted version alongside what it found.
Input
{ "text": "Patient John Doe (MRN-12345), DOB: 01/01/1980" }Output
{
"original": "Patient John Doe (MRN-12345), DOB: 01/01/1980",
"redacted": "Patient [NAME] ([MRN]), [DOB]",
"detected": [
{ "type": "mrn", "value": "MRN-12345", "confidence": 0.9 },
{ "type": "dob", "value": "DOB: 01/01/1980", "confidence": 0.85 },
{ "type": "name", "value": "John Doe", "confidence": 0.8 }
]
}Patterns and their confidence scores:
Type | Confidence | Matches |
| 0.95 |
|
| 0.90 |
|
| 0.85 |
|
| 0.80 |
|
| 0.75 |
|
| 0.70 |
|
The patterns start deliberately narrow. A false positive that trains someone to ignore the tool is worse than a missed match.
scan_code
Walks a directory and flags lines where a sensitive-looking identifier
(patient, diagnosis, dob, ssn, mrn, birthdate, medicalrecord)
appears on the same line as a risky sink (openai, anthropic, bedrock,
console.log/error/warn, logger., winston, pino, .track(, and
capture( / captureException( / captureMessage().
Whole-line // and # comments are skipped, so a file that discusses PHI
handling in prose doesn't trip the scanner on its own documentation.
Given the operative lines of
test/fixtures/leaky-example.ts:
const prompt = await openai.responses.create({ input: `Patient: ${patient.name}, diagnosis: ${patient.diagnosis}` });
console.log("Sending patient prompt to LLM:", prompt);Input
{ "path": "/abs/path/to/repo/test/fixtures" }Output — excerpt. The full fixtures directory returns 8 findings, because it also holds the positive fixtures described under Tested against.
[
{
"file": "test/fixtures/leaky-example.ts",
"line": 7,
"severity": "high",
"issue": "Sensitive-looking identifier passed to a risky sink (LLM call, logger, or analytics)",
"snippet": "const prompt = await openai.responses.create({ input: `Patient: ${patient.name}, diagnosis: ${patient.diagnosis}` });"
},
{
"file": "test/fixtures/leaky-example.ts",
"line": 8,
"severity": "high",
"issue": "Sensitive-looking identifier passed to a risky sink (LLM call, logger, or analytics)",
"snippet": "console.log(\"Sending patient prompt to LLM:\", prompt);"
}
]Scans .ts, .js, .tsx, .jsx, .py, .go. Skips node_modules, dist,
build, coverage, out, .next, .turbo, and dotfiles.
Both conditions must hold on the same line. That is what keeps it quiet: on
this repo's own source — which is dense with the words patient, diagnosis,
mrn, and ssn inside its pattern definitions — it reports zero findings.
Tested against
6 out of 6 real leak patterns detected, across 5 different sinks (OpenAI,
Anthropic, Sentry, Winston, PostHog/analytics) and 2 languages (TypeScript,
Python) — including snake_case identifiers (patient_name,
patient_diagnosis), which a naive word-boundary regex misses and which is the
dominant naming convention in Python and Go.
0 false positives across 5 clean-code fixtures, including code that discusses PHI policy in comments and prose without ever leaking it, and code that legitimately handles patient records without sending them anywhere risky.
1 documented limitation: detection is line-based, so a sensitive value assigned on one line and used in a risky call several lines later isn't currently caught. This is a known scope boundary, not a bug — see What this is NOT below.
Full test fixtures live in test/fixtures/ if you want to
verify any of this yourself rather than take it on faith:
npm testThe suite asserts both directions: every file under positive/ must produce at
least one finding, and negative/ must produce exactly zero. A miss on either
side fails the run.
What this is NOT
Not a hosted service. It is a local stdio process. There is no backend, no account, and no telemetry. Your code never leaves your machine.
Not a HIPAA certification, audit, or compliance attestation. Passing a
scan_coderun proves nothing to a regulator. It is a linter for a specific class of mistake, not evidence of compliance. Treat a clean result as "these particular patterns didn't fire", never as "this codebase is HIPAA-safe".Not a competitor to Prowler, AWS Config, or cloud posture tools. Those scan infrastructure and configuration. This reads source code and finds a different class of problem. They are complementary; this replaces neither.
Not exhaustive. Regex-based detection has a real false-negative rate. It will not catch PHI in a variable it can't name-match, or values arriving from an external call.
Not able to follow a value across lines. The identifier and the sink have to appear on the same line. Assigning
patient.diagnosisto a local variable and logging that variable three lines later produces no finding — there is a worked example intest/fixtures/known-limitations/. Real dataflow analysis is out of scope for v1; this is a deliberate boundary, and the fixture exists so the gap stays visible rather than forgotten.Not fully comment-aware. Only whole-line
//and#comments are skipped. Block comments (/* ... */) and trailing end-of-line comments are still scanned, so a sink keyword sitting inside one of those can produce a finding even though nothing executes.
Setup
Requires Node.js 18+.
git clone https://github.com/Abidit/phi-guard-mcp.git
cd phi-guard-mcp
npm install
npm run builddist/ is gitignored, so npm run build is required after cloning — the MCP
config below points at the compiled output.
Claude Code
Add .mcp.json to your project root, using the absolute path to your clone:
{
"mcpServers": {
"phi-guard": {
"command": "node",
"args": ["/absolute/path/to/phi-guard-mcp/dist/index.js"]
}
}
}Restart Claude Code, or run /mcp and reconnect phi-guard. A rebuild alone
will not reach an already-running stdio process.
Verifying
npm test # fixture suite: positive, negative, known limitations
npm run typecheck # src/ and test/ under strict mode
npx tsx test/smoke.tsOr drive it through the official Inspector without a browser:
npx @modelcontextprotocol/inspector --cli node dist/index.js --method tools/list
npx @modelcontextprotocol/inspector --cli node dist/index.js \
--method tools/call --tool-name redact_suggest \
--tool-arg text="Patient John Doe (MRN-12345)"The server declares only the tools capability, so resources/list and
prompts/list correctly return -32601 Method not found. The Inspector UI
probes all three regardless and shows those two in red — expected, not a fault.
License
MIT — see LICENSE.
Mcp Server Approved
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- AlicenseAqualityDmaintenanceScans prompts for PII and masks or redacts sensitive data locally before sending to an LLM, supporting multiple anonymization modes.1MIT
- AlicenseAqualityAmaintenanceMCP server and CLI for detecting, redacting, and auditing PHI in medical text before it reaches AI agents.4MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI coding tools to scan projects for security vulnerabilities, hardcoded secrets, injection flaws, and privacy violations with 699 rules and 76 MCP tools, all running locally with zero telemetry.526MIT
- AlicenseNot gradedqualityAmaintenanceScans text and files for common secrets (AWS, GitHub, etc.) and redacts them to prevent credential leakage in AI-assisted development. Runs entirely locally with no telemetry.MIT
Related MCP Connectors
Compliance & security scan for your app: secrets, exposed files, headers, privacy, AI-disclosure.
Zero-config MCP security scanner for AI-generated apps. 25K+ vulnerability patterns.
Screens public GitHub repos and PRs to generate risk maps, findings, and merge-readiness signals.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Abidit/phi-guard-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server