MCP屏蔽动作
GitHub Action扫描MCP服务器的安全问题、合规漏洞和风险因素。
用途 mcp屏蔽cli --跨合规性、安全性和咨询套件的自动检查。
快速开始
name: MCP Shield
on: [push, pull_request]
permissions:
contents: read
pull-requests: write
security-events: write
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: thuggeelya/mcp-shield-action@v1
with:
server: 'node dist/index.js'输入
| 输入 | 必填 | 默认 | 说明 |
|---|---|---|---|
server | yes | -- | 服务器命令(例如。, node dist/index.js, npx -y @foo/bar) |
fail-on | 没有 | high | 失败CI的最低严重性: critical, high, medium, low, any |
comment | 没有 | true | 将扫描结果作为PR评论 |
badge | 没有 | true | 在输出中生成徽章URL |
ml | 没有 | false | 启用基于ML的快速注射检测 |
sarif | 没有 | true | 生成SARIF报告并上传到GitHub代码扫描 |
version | 没有 | latest | 要安装的mcp-shield-cli版本 |
输出
| 输出 | 描述 |
|---|---|
score | 数字分数(0-100) |
grade | 字母等级(A+至F) |
badge-url | shields.io徽章URL |
report-json | JSON报告文件的路径 |
report-sarif | SARIF报告文件的路径 |
徽章
扫描成功后,在README中添加一个徽章:
[-brightgreen)](https://github.com/thuggeelya/mcp-shield)行动输出a badge-url 您可以直接使用:
- uses: thuggeelya/mcp-shield-action@v1
id: shield
with:
server: 'node dist/index.js'
- run: echo "Badge: ${{ steps.shield.outputs.badge-url }}"公关评论
当 comment: true (默认)并由拉取请求触发,Action会发布一份详细报告,其中包含具体发现、受影响的工具/字段和可操作的建议:
## MCP屏蔽报告 分数:57/100(D级) 检查:22 |通过:13 |失败:1 |警告:7 ### 研究结果 #### :x: SEC-004 失败——发现5项危险操作(CWE-78、CWE-250) -[high] Destructive operation: delete_pod-[high] Destructive operation: delete_deployment-[high] Exec operation: exec_command#### :警告: SEC-002 警告——发现3个潜在的注射载体(CWE-78、CWE-89) -[high] Potential injection vector: run_query.sql-[medium] Unconstrained path field: read_file.path### 建议 :red_circle:阻止危险操作(找到5个) > 检查并限制破坏性/执行工具,或使用带有--deny的mcp-shield代理 > 影响:delete_pod,delete_deployment,exec_command
GitHub代码扫描(SARIF)
默认情况下(sarif: true),Action生成 沙林2.1.0 通过以下方式报告并上传到GitHub的“安全”选项卡 codeql-action/upload-sarif.结果显示在下 安全→ 代码扫描警报 具有CWE参考和严重程度评分。
不需要额外的配置——它开箱即用。
要禁用SARIF上传:
- uses: thuggeelya/mcp-shield-action@v1
with:
server: 'node dist/index.js'
sarif: false例子
严格模式(任何警告都失败)
- uses: thuggeelya/mcp-shield-action@v1
with:
server: 'node dist/index.js'
fail-on: medium使用ML检测
- uses: thuggeelya/mcp-shield-action@v1
with:
server: 'node dist/index.js'
ml: true基于npx的服务器
- uses: thuggeelya/mcp-shield-action@v1
with:
server: 'npx -y @modelcontextprotocol/server-memory'在后续步骤中使用输出
- uses: thuggeelya/mcp-shield-action@v1
id: shield
with:
server: 'node dist/index.js'
fail-on: critical
- run: |
echo "Score: ${{ steps.shield.outputs.score }}"
echo "Grade: ${{ steps.shield.outputs.grade }}"
if [ "${{ steps.shield.outputs.score }}" -lt 50 ]; then
echo "::warning::Low security score"
fi许可证
Apache 2.0
