mcp-compliance-router
Screens text for PHI/PII, classifies it, redacts sensitive content, and routes it to approved model tiers based on a declarative policy, with built-in evaluation metrics.
README
mcp-compliance-router
An MCP server that screens text for PHI/PII, classifies it, redacts it, and routes it to an approved model tier under a declarative policy, with an evaluation harness that measures exactly how well the screening works.
This is a reference implementation of the enterprise AI gateway pattern (screen, classify, redact, route, audit) at the smallest size that still demonstrates the whole loop. It is not a certified compliance product; see Design notes and limitations.
Why this exists
Enterprises in regulated industries cannot send raw text to whichever model is best for the task. Something must sit in the path that answers three questions before any call is made: what is in this text, where is it allowed to go, and what record proves the decision. In large healthcare environments that job belongs to an AI gateway. This repo is that pattern, small enough to read in one sitting and instrumented so its accuracy is measured, not assumed.
Architecture
flowchart LR
A[Incoming text] --> B[Screen: regex entity detectors]
B --> C{Classify}
C -- restricted --> D[Redact] --> E[Restricted tier: private models]
C -- sensitive --> F[Redact] --> G[Standard tier]
C -- clean --> G
D --> H[(Audit log: entity types + SHA-256, never raw text)]
F --> H
Three modules, one policy file:
core.pydetects entities (SSN, MRN, NAME, DOB, ADDRESS, EMAIL, PHONE), classifies the document (clean, sensitive, restricted), redacts spans, and writes containment-friendly audit records that store entity types and a SHA-256 of the text, never the text itself.policy.pyloadspolicy/routing_policy.yamland turns a classification into a routing decision: target tier, allowed models, action, audit flag. Unknown classifications fail closed to the restricted rule.server.pyexposes the loop as three MCP tools:screen_text,route_request, andget_audit_log.
Quickstart
pip install -e ".[mcp,dev]"
pytest # unit tests
python eval/run_eval.py # regenerate eval/report.md
python -m compliance_router.server # run the MCP server on stdio
Use it from Claude
Claude Code:
claude mcp add compliance-router -- python -m compliance_router.server
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"compliance-router": {
"command": "python",
"args": ["-m", "compliance_router.server"]
}
}
}
Then ask, for example: "Screen this support ticket with compliance-router and tell me which tier it routes to and why."
Evaluation
Screening quality is measured, not asserted. eval/dataset.jsonl holds 36
labeled synthetic examples (every identifier is fabricated), and
eval/run_eval.py produces eval/report.md with per-entity precision,
recall, and F1, document classification accuracy, routing tier accuracy, and
a failure analysis listing each miss and false alarm. The current report is
committed so the limits of the regex heuristics are visible in the repo.
Design notes and limitations
- Detection is regex-based on purpose: it keeps the reference readable and makes the evaluation honest. It is not production-grade PHI detection. Bare person names without an honorific or patient-context cue are missed by design of the current NAME heuristic, and the report shows it.
- The detector sits behind a small interface, so swapping in a stronger backend (Presidio, a clinical NER model, or an LLM-based screen with conformal abstention) changes one module and rerunning the harness shows exactly what the upgrade bought.
- The audit log is in-memory for the reference; production would ship the same records to a log platform. The records are designed to be safe to ship: entity types and hashes, never content.
- Fail-closed policy: any classification the policy does not recognize is blocked and audited.
Roadmap
- Pluggable detector backends (Presidio, clinical NER) behind the same interface, compared by the same harness
- Conformal abstention thresholds on the classifier, so uncertain documents escalate instead of guessing
- Policy lint: validate the YAML against tiers at startup
- Per-tenant policies keyed by MCP client identity
License
MIT. All example data is synthetic. Developed with AI-assisted workflows (Claude Code and similar agents) with human architecture and review.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。