MSCC-MCP安全指挥中心
   
MCP安全之谜 -在MCP服务器成为漏洞之前扫描其漏洞
模型上下文协议(MCP)服务器的安全扫描程序。检测MCP实现中的快速注入、工具中毒、秘密暴露和其他漏洞。
特性
- 63种检测模式 覆盖OWASP MCP Top 10
- 支持6种语言 -Python、JavaScript/Node.js、Go、Rust、Java、C#
- YARA规则引擎 用于自定义检测规则
- 多种导出格式 -JSON、SARIF、Markdown、HTML、PDF、SVG徽章
- MCP协议客户端 用于实时服务器扫描
- CI/CD就绪 与GitHub Actions集成
安装
# Core SDK
pip install mscc
# With API server
pip install mscc[api]
# With PDF export support
pip install mscc[pdf]
# Development
pip install mscc[dev]快速开始
开发包
from mscc import MSCCClient, scan_local
# Quick local scan
result = scan_local("./my-mcp-server")
print(f"Risk Score: {result.risk_score}/100")
print(f"Found {len(result.findings)} issues")
# Full client usage
client = MSCCClient()
result = client.scan("./path/to/mcp-server", profile="ci-standard")
# Check findings
for finding in result.findings:
print(f"[{finding.severity.value}] {finding.title}")
print(f" Location: {finding.file_path}:{finding.line_number}")
# Export reports
result.to_pdf("report.pdf")
result.to_sarif() # Returns SARIF dict
result.to_html() # Returns HTML string命令行接口
# Scan a local directory
mscc scan ./my-mcp-server
# Scan with specific profile
mscc scan ./src --profile dev-fast
# Scan a Git repository
mscc scan-repo https://github.com/org/mcp-server
# Export to different formats
mscc scan ./src -o report.json
mscc scan ./src -o report.sarif
mscc scan ./src -o report.html
# Fail on high risk score (for CI)
mscc scan ./src --max-risk 70
# Show version
mscc versionGitHub操作集成
name: Security Scan
on: [push, pull_request]
jobs:
mscc-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install mscc
- run: mscc scan . --max-risk 70 -o results.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: results.sarif检测能力
OWASP MCP十大覆盖范围
| 类别 | 图案 | OWASP ID |
|---|---|---|
| 提示注入 | 忽略指令、系统标记、角色操纵、越狱、unicode技巧 | MCP-03 |
| 工具中毒 | 隐藏的HTML注释、编码内容、XSS有效载荷 | MCP-02 |
| 权限过多 | 无限制的shell/文件系统/网络,调试模式 | MCP-01 |
| 秘密曝光 | API密钥、密码、令牌、私钥、连接字符串 | MCP-01 |
| 命令注入 | Shell执行、eval、不安全的反序列化 | MCP-04 |
语言支持
| 语言 | 检测模式 |
|---|---|
| python | 子进程、os.system、eval/exec、pickle、yaml.load |
| JavaScript | eval、child_process、innerHTML、原型污染 |
| 去 | 执行官。命令、不安全、SQL注入、路径遍历 |
| 锈 | 不安全块,命令::new,原始指针,转换 |
| Java | Runtime.exec、ObjectInputStream、XXE、JNDI注入 |
| C | 过程。开始,BinaryFormatter,SQL注入,XXE |
扫描配置文件
| 简介 | 用例 |
|---|---|
dev-fast | 快速本地开发检查 |
ci-standard | CI/CD管道集成(默认) |
full-enterprise | 全面的安全审计 |
API服务器
# Start the API server
uvicorn mscc.api.app:app --host 0.0.0.0 --port 8000
# Or with Docker
docker build -t mscc .
docker run -p 8000:8000 mscc端点
| 方法 | 端点 | 描述 |
|---|---|---|
| 得到 | /health | 健康检查 |
| 得到 | /ready | 准备就绪检查 |
| 得到 | /docs | OpenAPI文档 |
| 职位 | /api/v1/scans | 运行安全扫描 |
示例请求
curl -X POST http://localhost:8000/api/v1/scans \
-H "Content-Type: application/json" \
-d '{"path": "./my-mcp-server", "profile": "ci-standard"}'项目结构
src/mscc/
├── __init__.py # Package exports
├── cli.py # Command line interface
├── client.py # MSCCClient SDK
├── models/ # Data models
├── scanner/
│ ├── engine.py # Scan orchestration
│ ├── static.py # Pattern detection (63 patterns)
│ └── yara_scanner.py # YARA rules engine
├── mcp/
│ ├── client.py # MCP Protocol Client
│ └── scanner.py # Live server scanner
├── api/
│ ├── app.py # FastAPI application
│ ├── db/ # Database models (PostgreSQL)
│ └── cache.py # Redis caching
└── worker/
└── tasks.py # Celery background tasks
rules/ # YARA detection rules
├── core/
│ ├── owasp-mcp/ # OWASP MCP Top 10 rules
│ └── secrets/ # Secret detection rules
└── community/ # Community-contributed rules发展
# Clone and install
git clone https://github.com/gensecaihq/mcpscc.git
cd mcpscc
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,api,pdf]"
# Run tests
pytest tests/ -v
# Run linting
ruff check src/
black --check src/贡献
欢迎投稿!请阅读 贡献.md 作为指导方针。
安全
有关安全问题,请参阅 安全.md.
许可证
Apache-2.0-见 许可证 了解详情。
