使用说明
mcp扫描仪
MCP(模型上下文协议)服务器的安全扫描程序和代理。
mcp-scanner发现、扫描和代理跨您的AI工具(Claude Desktop、Cursor、Windsurf、VS Code等)配置的mcp服务器,检测工具描述中的提示注入、过于宽泛的权限和可疑更改等安全漏洞。
特性
- 自动发现:查找在Claude Desktop、Cursor、Windsurf、Zed、Cline、Continue、VS Code、Roo Code和Claude Code中配置的MCP服务器
- 安全扫描:检测提示注入、权限范围问题、缺少身份验证、工具阴影和描述漂移
- STDIO代理:通过基于规则的过滤拦截客户端和服务器之间的工具调用
- Web仪表板:htmx驱动的UI,用于查看扫描结果和管理代理规则
- 审核日志记录:SQLite支持的所有代理工具调用的日志记录
安装
自制(macOS/Linux)
brew install oabraham1/tap/mcp-scanner
外壳安装程序
curl -fsSL https://raw.githubusercontent.com/oabraham1/mcp-scanner/main/install.sh | sh
下载二进制文件
从下载预构建的二进制文件 GitHub发布.
货物(需要防锈)
cargo install mcp-scanner
从源代码构建
git clone https://github.com/oabraham1/mcp-scanner
cd mcp-scanner
cargo build --release
快速开始
# Scan all discovered MCP servers
mcp-scanner scan
# List discovered servers
mcp-scanner list
# Start the web dashboard
mcp-scanner serve
# Proxy a specific server
mcp-scanner proxy --server "npx -y @modelcontextprotocol/server-filesystem /"
CLI参考
mcp-scanner scan
扫描MCP服务器是否存在安全漏洞。
mcp-scanner scan # Scan all discovered servers
mcp-scanner scan --client claude # Scan only Claude Desktop servers
mcp-scanner scan --server "npx server.js" # Scan a specific server command
mcp-scanner scan --config ./mcp.json # Scan servers from config file
mcp-scanner scan --output json # Output as JSON
mcp-scanner scan --output sarif # Output as SARIF (for CI integration)
mcp-scanner list
列出发现的MCP服务器。
mcp-scanner list # List all servers
mcp-scanner list --client cursor # List only Cursor servers
mcp-scanner serve
启动web仪表板和API服务器。
mcp-scanner serve # Start on localhost:9191
mcp-scanner serve --port 8080 # Use custom port
mcp-scanner serve --headless # Don't open browser
mcp-scanner proxy
使用过滤和审计日志代理MCP服务器。
mcp-scanner proxy --server "npx -y @modelcontextprotocol/server-filesystem /"
要使用代理,请更新客户端配置以指向mcp-scanner:
{
"mcpServers": {
"filesystem": {
"command": "mcp-scanner",
"args": ["proxy", "--server", "npx -y @modelcontextprotocol/server-filesystem /"]
}
}
}
mcp-scanner init
创建默认配置。
mcp-scanner init # Create ~/.mcp-scanner/config.toml
mcp-scanner init --force # Overwrite existing config
mcp-scanner completions
生成外壳完成。
mcp-scanner completions --shell bash >> ~/.bashrc
mcp-scanner completions --shell zsh >> ~/.zshrc
mcp-scanner completions --shell fish >> ~/.config/fish/completions/mcp-scanner.fish
威胁类别
mcp扫描程序检测到以下安全问题:
说明注射(临界/高)
工具描述中的提示注射模式,包括:
- “忽略前面的指令”模式
- 隐藏的Unicode字符
- Base64编码有效载荷
- 系统提示注射尝试
许可范围(高/中)
能力过于宽泛:
- 任意代码执行
- 根文件系统访问
- 无限制的网络访问
- 数据库查询访问
无身份验证(远程关键,本地信息)
没有身份验证的服务器:
- 没有身份验证令牌的远程服务器(严重)
- 没有基于环境的身份验证的本地服务器(信息)
工具阴影(高/中)
服务器之间的名称冲突:
- 精确名称冲突
- 相似名称(可能拼写错误)
描述漂移(高/中)
自上次扫描以来的更改:
- 修改了工具描述
- 添加/删除工具
配置
配置文件位置: ~/.mcp-scanner/config.toml
[scan]
timeout = 30 # seconds per server
[output]
format = "table" # table, json, sarif
API终点
web服务器公开JSON API:
GET /api/health-健康检查GET /api/servers-列出已发现的服务器POST /api/scan-运行扫描GET /api/audit-列出审核日志条目GET /api/rules-列出代理规则POST /api/rules-创建代理规则PUT /api/rules/:id-更新代理规则DELETE /api/rules/:id-删除代理规则
数据存储
mcp扫描仪将数据存储在 ~/.mcp-scanner/:
mcp-scanner.db-SQLite数据库(审计日志、扫描结果、规则)snapshots/-漂移检测工具描述快照config.toml-配置文件
支持的客户
| 客户端 | 配置路径 |
|---|---|
| 克劳德桌面 | ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) |
| 光标 | ~/.cursor/mcp.json |
| 风帆冲浪 | ~/.codeium/windsurf/mcp_config.json |
| Zed | ~/.config/zed/settings.json |
| 克莱恩 | ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json |
| 继续 | ~/.continue/config.json |
| VS代码 | .vscode/mcp.json |
| Roo代码 | ~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json |
| 克劳德代码 | ~/.claude/settings.json 或 .mcp.json |
许可证
根据以下任一方式获得许可:
- Apache许可证,版本2.0(特许通行证 或http://www.apache.org/licenses/LICENSE-2.0)
- MIT许可证(许可证-麻省理工学院 或http://opensource.org/licenses/MIT)
由您选择。
