sensitive-info-mcp
The sensitive-info-mcp server detects and masks sensitive information in text and files using regular expressions, validation algorithms, and optional AI-based semantic detection. It supports 14+ types of sensitive data (phone numbers, ID cards, bank cards, emails, API keys, JWTs, private keys, AWS keys, GitHub tokens, passwords, etc.).
Scan text (
scan_text): Detect sensitive data in a string, returning JSON results.Mask text (
mask_text): Detect and redact sensitive info using configurable strategies:mask,replace,hash,keep_format, orredact.Generate report (
scan_report): Produce a Markdown-formatted report of all findings in a given text.Scan file (
scan_file): Analyze a file for sensitive information and return JSON-formatted results.Mask file (
mask_file): De-identify sensitive content in a file, saving to a new path or overwriting in place.List rules (
list_rules): Retrieve all built-in detection rules currently configured.AI semantic detection: Optionally enable LLM-based detection (via
OPENAI_API_KEY) to catch obfuscated or context-dependent sensitive info.Batch scan & unified reporting: Prescreen code/config snippets and combine rule-based and LLM-based findings into a single report.
Integration options: Python SDK, CLI, and GitHub Action support.
Leverages OpenAI's LLM for AI-enhanced semantic detection of sensitive information, identifying context-based privacy risks.
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., "@sensitive-info-mcpmask my phone number 13812345678"
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.
🔒 Sensitive Info MCP
规则驱动的敏感信息检测与数据脱敏 MCP 服务器 + LLM Skill 协同
一个 Model Context Protocol (MCP) 服务器,用于检测和脱敏文本/文件/代码中的敏感信息。支持 14+ 类敏感信息识别,结合正则规则 + 校验算法做基础检测,并提供掩码、替换、哈希等多种脱敏策略。LLM 语义检测通过 Skill 编排 AI 助手完成(MCP 不内置 LLM 调用)。
✨ 特性
全面检测:手机号、身份证、银行卡、邮箱、API Key、JWT、私钥、AWS Key、GitHub Token 等 14+ 类
智能校验:身份证校验位算法、银行卡 Luhn 校验,降低误报
MCP/Skill 分工:基础检测在 MCP(快、确定性),LLM 语义检测在 Skill(识别变形/拆分/上下文隐私),职责清晰
灵活脱敏:5 种策略(掩码/替换/哈希/保留格式/删除),支持按类型自定义
中文友好:所有正则使用 lookaround 断言,完美兼容中文环境
多形态使用:MCP Server(Claude/Cursor/CodeBuddy)、CLI 命令行、Python SDK、GitHub Action
Related MCP server: MCP Presidio
📦 安装
pip install -e .🚀 快速开始
1. CLI 命令行
# 检测敏感信息
sensitive-info-mcp "我的手机号是13812345678"
# 脱敏输出
sensitive-info-mcp "我的手机号是13812345678" --mask
# 生成 Markdown 报告
sensitive-info-mcp "身份证:110101199003071233" --report
# 扫描文件
sensitive-info-mcp --file ./config.yaml --mask2. MCP Server(Claude Desktop / Cursor / CodeBuddy)
在客户端配置文件中添加:
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"sensitive-info": {
"command": "sensitive-info-mcp",
"args": []
}
}
}Cursor / CodeBuddy (.codebuddy/mcp.json 或对应配置):
{
"mcpServers": {
"sensitive-info": {
"command": "python3",
"args": ["-m", "sensitive_info_mcp.server"]
}
}
}配置后,AI 助手即可调用以下工具:
工具 | 功能 |
| 检测文本中的敏感信息(基础规则) |
| 检测并脱敏文本 |
| 生成单文本 Markdown 扫描报告 |
| 扫描文件 |
| 脱敏文件并保存 |
| 列出所有检测规则 |
| 批量对多个代码/配置片段做基础初筛(配合 Skill) |
| 汇总 rule + llm 来源检测结果生成统一报告(配合 Skill) |
3. Python SDK
from sensitive_info_mcp.scanner import Scanner
scanner = Scanner()
# 检测
findings = scanner.detect("联系我:13812345678 或 test@qq.com")
for f in findings:
print(f"[{f.type.value}] {f.value} → 风险:{f.risk_level.value}")
# 脱敏
masked, findings = scanner.mask("手机号13812345678")
print(masked) # 手机号138****5678
# 完整报告
report = scanner.report("身份证:110101199003071233")
print(report.to_markdown())🔧 配置
脱敏策略
策略 | 说明 | 示例 |
| 使用各类型默认策略 | 手机号→掩码,API Key→替换 |
| 部分掩码 |
|
| 完全替换 |
|
| SHA256 哈希 |
|
| 保留格式 |
|
| 完全删除 |
|
from sensitive_info_mcp.types import MaskConfig, MaskStrategy
from sensitive_info_mcp.scanner import Scanner
# 全局强制使用替换策略
scanner = Scanner(mask_config=MaskConfig(strategy=MaskStrategy.REPLACE))
# 按类型自定义
scanner = Scanner(mask_config=MaskConfig(
type_overrides={
"phone": {"strategy": "hash"},
"email": {"strategy": "keep_format"},
}
))🤝 结合 Skill 做 LLM 语义检测
本 MCP 仅做基础检测(正则 + 校验算法),不内置 LLM 调用。LLM 语义检测(识别变形/拆分敏感信息、非标准命名的硬编码凭据、内网信息、上下文隐私等)通过 Skill 编排 AI 助手完成 —— 因为 AI 助手本身就在执行 LLM,无需 MCP 再调外部 API。
工作流
代码 / 配置片段
│
├─ codegraph 取常量/变量定义 + Glob/Read 取配置文件
▼
┌───────────────────────┐
│ MCP scan_snippets │ ── rule 初筛 ──┐
│ (正则 + 校验算法) │ │
└───────────────────────┘ │
│ 初筛未命中片段 │
▼ │
┌───────────────────────┐ │
│ AI 助手 LLM 二次筛选 │ ── llm findings│
│ (Skill 识别规则) │ ──────────────►│
└───────────────────────┘ │
▼ ▼
┌───────────────────────┐
│ MCP build_report │ → 统一 Markdown 报告(区分 rule/llm 来源)
└───────────────────────┘安装 Skill
将 skills/sensitive-info-scan/SKILL.md 复制到 CodeBuddy / Cursor 的 skills 目录:
# CodeBuddy
mkdir -p ~/.codebuddy/skills/sensitive-info-scan
cp skills/sensitive-info-scan/SKILL.md ~/.codebuddy/skills/sensitive-info-scan/SKILL.md
# 或 Cursor / Claude Code 对应 skills 目录重启会话后,对用户说"扫描代码中的敏感信息",AI 助手会自动按 Skill 工作流执行:codegraph 取片段 → MCP 初筛 → LLM 二筛 → build_report 生成报告。
Skill 也可在无 codegraph 环境下工作(回退为 Grep 赋值行收集片段),详见 SKILL.md。
📋 支持的敏感信息类型
类型 | 标识 | 风险等级 | 校验 |
手机号 |
| 高 | - |
身份证号 |
| 严重 | ✅ 校验位 |
银行卡号 |
| 严重 | ✅ Luhn |
邮箱 |
| 中 | - |
API Key |
| 高 | - |
AWS Key |
| 严重 | - |
GitHub Token |
| 严重 | - |
JWT |
| 严重 | - |
私钥 |
| 严重 | - |
密码 |
| 高 | - |
URL 凭据 |
| 高 | - |
IP 地址 |
| 低 | - |
社会保障号 |
| 高 | - |
LLM 检测 |
| 中-严重 | - (Skill 二次筛选产生) |
添加自定义规则
from sensitive_info_mcp.detectors.rules import Rule, RuleDetector
from sensitive_info_mcp.types import SensitiveType, RiskLevel
import re
custom = Rule(
type=SensitiveType.CUSTOM,
pattern=re.compile(r"(?<!\d)EMP\d{6}(?!\d)"), # 员工号 EMP123456
risk_level=RiskLevel.MEDIUM,
confidence=0.9,
description="内部员工编号",
)
scanner = Scanner(extra_rules=[custom])🏗️ 架构
输入文本 / 文件 / 代码片段
│
▼
┌───────────────────┐
│ 规则检测器 │ 正则 + 校验算法(身份证校验位 / 银行卡 Luhn)
│ (RuleDetector) │ → 14+ 类已知格式敏感信息
└────────┬──────────┘
│
▼
┌───────────────────┐
│ 脱敏处理器 │ 掩码 / 替换 / 哈希 / 保留格式 / 删除
│ (Masker) │
└────────┬──────────┘
▼
脱敏文本 + 检测报告
┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
LLM 语义检测(在 Skill 层,不在 MCP 内):
codegraph 取片段 → scan_snippets 初筛 → AI 助手 LLM 二筛 → build_report📁 项目结构
sensitive-info-mcp/
├── src/sensitive_info_mcp/
│ ├── server.py # MCP Server + CLI 入口(8 个工具)
│ ├── scanner.py # 扫描器(基础规则检测 + 脱敏)
│ ├── types.py # 类型定义
│ ├── detectors/
│ │ ├── base.py # 检测器基类
│ │ └── rules.py # 规则检测引擎(14+ 类)
│ └── maskers/
│ └── processor.py # 脱敏处理器
├── skills/
│ └── sensitive-info-scan/
│ └── SKILL.md # LLM 语义检测 Skill(codegraph + MCP + AI 助手协同)
├── action.yml # GitHub Action
├── examples/ # 使用示例
├── tests/ # 测试用例
└── pyproject.toml🧪 测试
python tests/test_core.py📄 License
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- 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/hawklithm/sensitive-info-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server