Token导航 LogoToken导航TokenDH.com
MCP Shield Pii logo
安全风控stdio官方级别未说明来源级核验

MCP Shield Pii

MCP Server

mcp-shield-pii是一款实时PII脱敏代理,用于在MCP客户端和服务器之间拦截并屏蔽个人身份信息,确保GDPR/HIPAA合规性。

工具数

6

提示词数

0

GitHub Stars

0

资源数

0
PythonClaude安全Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

adwantg

提供方

adwantg

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install mcp-shield-pii

详细介绍

mcp盾牌

🛡️ MCP客户端和服务器的实时PII编辑代理——Python 3.12+的零延迟隐私,可选Python 3.14子解释器加速。

mcp盾牌 是位于MCP客户端(例如Claude Desktop)和任何下游MCP服务器之间的拦截网关代理。它在个人身份信息到达LLM的上下文窗口之前实时检测和屏蔽个人身份信息,确保GDPR/HIPAA符合单一 pip install.

为什么是mcp盾皮?

当AI代理从MCP服务器请求数据时,原始有效载荷(可能包含SSN、医疗记录或信用卡)直接流入LLM。组织可能面临超过数亿美元的GDPR/HIPAA罚款。 mcp盾牌 消除了协议层的这种风险。

┌──────────────┐     ┌─────────────────┐     ┌──────────────────┐
│ Claude       │────▶│ mcp-shield-pii  │────▶│ Downstream MCP   │
│ Desktop      │◀────│ (PII Redaction)  │◀────│ Server           │
└──────────────┘     └─────────────────┘     └──────────────────┘
                         ▲                           
                    PII masked before               
                    reaching the LLM                

安装

pip install mcp-shield-pii

对于基于NLP的检测(姓名、组织、地址):

pip install mcp-shield-pii[nlp]
python -m spacy download en_core_web_sm

快速开始

1.扫描文本以查找PII

# Simple scan
mcp-shield-pii scan "Contact john@example.com, SSN 123-45-6789"

# JSON output
mcp-shield-pii scan --json "Patient MRN-123456 at 192.168.1.1"

# Different masking strategies
mcp-shield-pii scan --strategy partial "Card: 4111-1111-1111-1111"
mcp-shield-pii scan --strategy hash "Email: secret@corp.com"
mcp-shield-pii scan --strategy pseudo "Call 555-123-4567"

2.启动代理

# Basic proxy (stdio transport)
mcp-shield-pii proxy --downstream "npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb"

# With config file
mcp-shield-pii proxy --downstream "python my_server.py" --config shield.toml

# Dry-run mode (log detections, don't modify payloads)
mcp-shield-pii proxy --downstream "npx my-mcp-server" --dry-run

3.克劳德桌面集成

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "my-server-shielded": {
      "command": "mcp-shield-pii",
      "args": [
        "proxy",
        "--downstream", "npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb",
        "--config", "/path/to/shield.toml"
      ]
    }
  }
}

4.生成配置文件

mcp-shield-pii generate-config --output shield.toml

5.生成合规报告

mcp-shield-pii report --format markdown --output compliance_report.md

6.启动仪表板

mcp-shield-pii dashboard --port 8765
# Open http://127.0.0.1:8765

特性

v1.0--核心

特性描述
标准代理拦截客户端和下游服务器之间的MCP stdio传输
正则表达式引擎(18种)检测SSN、信用卡、电子邮件、电话、IBAN、API密钥、JWT等
NLP引擎可选spaCy NER用于人名、组织、地点、地址
掩蔽策略redact (`), partial (*--6789), hash (SHA256:a1b2...), pseudo` (一致的假货)
TOML配置按实体规则、按工具允许/拒绝列表、置信阈值
CallToolResult拦截在传递非敏感RPC时,以JSON-RPC响应为目标
审计跟踪JSONL审计日志,包括时间戳、实体类型、置信度得分
命令行界面proxy, scan, report, dashboard, generate-config, version

v1.1--硬化

特性描述
情境感知评分通过分析周围的文本减少误报
信心阈值每个实体类型可配置的最小置信度
工具允许/拒绝列表跳过受信任的工具,对敏感工具强制执行严格模式
干运行模式记录在不修改有效载荷的情况下会被编辑的内容
热重新加载配置更改规则而不重新启动代理
普罗米修斯指标/metrics 具有延迟百分位数和实体计数器的端点

v2.0--企业版

特性描述
伪匿名化保持语义含义的一致假数据映射
可逆重动作AES-256加密映射——授权密钥持有者可以恢复原始密钥
合规仪表板带有实时事件表和严重性徽章的暗模式web UI
GDPR/HIPAA报告自动生成的合规报告(文本、JSON、markdown)
Webhook警报检测到高严重性PII时通知Slack/Teams
副口译员人才库通过以下方式进行无GIL并行检测 concurrent.interpreters (3.14+)或 ProcessPoolExecutor (3.12+)

检测到的实体类型

基于正则表达式(18种类型)

实体示例验证
电子邮件user@example.com正则表达式
电话+1-555-123-4567正则表达式
SSN123-45-6789正则表达式+格式验证
信用卡4111-1111-1111-1111正则表达式+Luhn校验和
伊班。 DE89370400440532013000正则表达式+国家代码长度
IPv4 的 192.168.1.1正则表达式
IPv6 的 2001:0db8::1正则表达式
MAC地址00:1A:2B:3C:4D:5E正则表达式
AWS API密钥AKIA...正则表达式(前缀)
OpenAI密钥sk-...正则表达式(前缀)
条纹键sk_live_...正则表达式(前缀)
GitHub代币ghp_...正则表达式(前缀)
护照A12345678正则表达式
出生日期: 1990-01-15正则表达式
医疗IDMRN-123456正则表达式
驾驶执照D123-4567-8901正则表达式
带身份验证的URLhttps://user:pass@host正则表达式
JWT代币eyJhbG...正则表达式(前缀)

基于NLP(5种类型,需要 [nlp] 额外)

实体示例
人员姓名John Smith
组织机构Acme Corp
地址123 Main St, Springfield
地点New York City
医疗状况Type 2 diabetes

配置(shield.toml)

[shield]
default_masking_strategy = "redact"
default_confidence_threshold = 0.7
dry_run = false

[detection]
enable_regex = true
enable_nlp = false
enable_context_scoring = true

[entities.SSN]
masking_strategy = "redact"
confidence_threshold = 0.8

[entities.EMAIL]
masking_strategy = "pseudo"
confidence_threshold = 0.7

[tools.trusted_internal_tool]
action = "skip"

[tools.patient_records_api]
action = "strict"
masking_strategy = "redact"

[[webhooks]]
url = "https://hooks.slack.com/services/YOUR/WEBHOOK"
events = ["high_severity"]

[dashboard]
enabled = true
port = 8765

[metrics]
enabled = true
port = 9090

程序化API

from mcp_shield_pii.detection.regex_engine import RegexDetectionEngine
from mcp_shield_pii.masking.strategies import get_strategy
from mcp_shield_pii.pipeline import ShieldPipeline
from mcp_shield_pii.config.loader import ShieldConfig

# Simple detection
engine = RegexDetectionEngine()
results = engine.detect("Email john@corp.com, SSN 123-45-6789")
for r in results:
    print(f"{r.entity_type.value}: '{r.text}' (confidence: {r.confidence:.0%})")

# Full pipeline
config = ShieldConfig(default_masking_strategy="partial")
pipeline = ShieldPipeline(config)
masked, summary = pipeline.process_text("Contact admin@secret.org, card 4111-1111-1111-1111")
print(masked)  # "Contact a***@***.org, card ****-****-****-1111"
pipeline.close()

# Pseudo-anonymization
config = ShieldConfig(default_masking_strategy="pseudo")
pipeline = ShieldPipeline(config)
masked, _ = pipeline.process_text("Email alice@corp.com then alice@corp.com again")
print(masked)  # Same fake email both times (consistent mapping)
pipeline.close()

建筑

src/mcp_shield_pii/
├── __init__.py          # Public API exports
├── cli.py               # Typer CLI (6 commands)
├── pipeline.py          # Orchestration: detect → score → filter → mask → audit
├── compliance.py        # GDPR/HIPAA report generator
├── webhooks.py          # Async webhook alerts
├── detection/
│   ├── base.py          # EntityType enum, DetectionResult, protocols
│   ├── regex_engine.py  # 18 regex patterns + Luhn/IBAN validation
│   ├── nlp_engine.py    # spaCy NER detection (optional)
│   └── context_scorer.py # Context-aware confidence adjustment
├── masking/
│   ├── strategies.py    # Redact, partial, hash, pseudo-anonymization
│   └── reversible.py    # AES-256 Fernet reversible redaction
├── config/
│   ├── loader.py        # TOML config parser
│   └── watcher.py       # Hot-reload file watcher
├── proxy/
│   ├── __init__.py      # MCP JSON-RPC interceptor
│   └── stdio_proxy.py   # Bidirectional stdio transport
├── concurrency/
│   └── __init__.py      # Subinterpreter pool + ProcessPool fallback
├── metrics/
│   └── __init__.py      # Prometheus metrics + HTTP server
├── audit/
│   └── __init__.py      # JSONL audit logger
└── dashboard/
    └── __init__.py      # Web UI + REST API

贡献

贡献.md

许可证

麻省理工学院——见 许可证 了解详情。

目录标签

目录标签

PythonClaude安全PII脱敏本地部署隐私保护合规性实时处理GDPR合规HIPAA合规

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

6

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP