MCP-Audit/MCPAudit
GitHub: MCP-Audit/MCPAudit
MCPAudit:MCP服务器安全扫描工具,助力安全团队提前发现潜在漏洞。
Stars: 6 | Forks: 1
# MCPAudit -> MCPAudit




**模型上下文协议(MCP)服务器的攻击性安全测试框架。**
让MCP安全测试像运行代码检查器一样简单。
```
mcpaudit scan ./server.py
```
## 演示
扫描包含的易受攻击的MCP服务器:
```
uv run mcpaudit scan examples/vulnerable-mcp-server/server.py
```
```
$ mcpaudit scan examples/vulnerable-mcp-server/server.py
[✓] Discovering tools...
[✓] Mapping permissions...
[✓] Detecting attack chains...
[✓] Generating report...
==================== MCPAudit Security Report ====================
Overall Score: 5/100 (CRITICAL)
Risk Index: 100/100
Scoring basis: 3 Critical, 7 High, 2 Medium (12 scorable findings)
Formula: 3×25 + 7×10 + 2×3 = 151 → round(100 × e^(-151/50)) = 5
Severity Summary Top Findings
● Critical 4 [1] CRITICAL Destructive tool: delete_all_users
● High 7 [2] CRITICAL Read → exfiltration attack chain possible
● Medium 2 ...
```
## 问题
MCP服务器将数据库、API、文件系统、云资源和SaaS工具暴露给AI代理——通常没有经过严格的安全审查。MCPAudit帮助团队在攻击者之前发现问题。
## 功能
| 模块 | 状态 | 描述 |
|--------|--------|-------------|
| 权限分析器 | ✅ Alpha | 标记破坏性和过度授权的工具 |
| 提示注入模拟器 | ✅ Alpha | 测试已知的注入攻击模式 |
| 工具滥用测试 | ✅ Alpha | 检测路径遍历和滥用表面 |
| 数据泄露检测 | ✅ Alpha | 扫描机密和敏感引用 |
| 代理越狱测试 | 🚧 计划中 | 对越狱套件的抵抗评分 |
| 多步骤攻击链 | ✅ Alpha | 识别危险的工具组合 |
| 风险评分引擎 | ✅ Alpha | 安全评分 + 风险指数(指数衰减) |
| 终端UI | ✅ Alpha | 丰富的仪表板,主题(`cyber`,`minimal`,`github`) |
| 合规性检查 | ✅ Alpha | OWASP LLM Top 10 & MCP最佳实践 |
| CI/CD集成 | 🚧 计划中 | GitHub Action用于管道门 |
| HTML报告 | ✅ Alpha | `mcpaudit report` → `security-report.html` |
| MCP模糊测试 | 🔮 路线图 | `mcpaudit fuzz` |
| MCPAudit代理 | 🔮 路线图 | `mcpaudit pentest` |
## 快速开始
### 先决条件
- Python 3.11+
- [uv](https://docs.astral.sh/uv/)(推荐)
### 安装
```
git clone https://github.com/MCP-Audit/MCPAudit.git
cd MCPAudit
uv sync --all-extras
```
### 扫描MCP服务器
```
uv run mcpaudit scan examples/vulnerable-mcp-server/server.py
```
保存JSON结果并生成HTML:
```
uv run mcpaudit scan examples/vulnerable-mcp-server/server.py -o report.json
uv run mcpaudit report report.json -o security-report.html
```
### CI门(在关键时失败)
```
uv run mcpaudit scan ./server.py --fail-on-critical
```
### 主题
```
uv run mcpaudit scan ./server.py --theme cyber # default
uv run mcpaudit scan ./server.py --theme minimal --no-progress
```
## 架构
```
┌──────────────┐
│ MCP Server │
└──────┬───────┘
│
▼
┌─────────────────┐
│ MCPAudit Scanner │
└─────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
Permission Injection Leakage
Analyzer Engine Scanner
▼ ▼ ▼
Risk Scoring Engine
▼
Security Report
```
## 项目结构
```
MCPAudit/
├── src/mcpaudit/ # Main package (src layout)
│ ├── cli/ # Typer CLI (`scan`, `report`, `fuzz`, `pentest`)
│ ├── core/ # Scanner orchestration
│ ├── analyzers/ # Security analyzers
│ ├── scoring/ # Risk scoring engine
│ ├── compliance/ # OWASP & MCP compliance checks
│ ├── reporting/ # Models & HTML reports
│ └── mcp/ # MCP client & discovery
├── tests/ # pytest suite
├── examples/ # Sample vulnerable MCP servers
├── action/ # GitHub Action (planned)
└── docs/ # Documentation
```
## 开发
```
uv sync --all-extras
uv run pytest
uv run ruff check src tests
uv run ruff format src tests
pre-commit install
```
## 定位
| 工具 | 领域 |
|------|--------|
| SonarQube | 代码质量 |
| OWASP ZAP | 网络安全 |
| Trivy | 容器安全 |
| Semgrep | 静态分析 |
| **MCPAudit** | **MCP安全** |
## 路线图
查看[docs/roadmap.md](docs/roadmap.md)以获取分阶段计划——类别风险评分、GitHub Action、SARIF、攻击模拟等。
## 贡献
查看[CONTRIBUTING.md](CONTRIBUTING.md).
## 许可证
Apache License 2.0 — 查看[LICENSE](LICENSE).
## 安全
要报告漏洞,请参阅[SECURITY.md](SECURITY.md).
标签:AES-256, AI 安全, Alpha 版本, Apache 许可, Atomic Red Team, MCP 服务器安全, Python 开发, 多语言支持, 安全报告, 安全测试框架, 工具滥用检测, 指令注入, 攻击链检测, 数据泄露检测, 权限分析, 模型上下文协议, 漏洞评估, 网络安全, 逆向工具, 隐私保护, 零日漏洞检测