协议检查工具

mcp-sheriff是一款用于检查MCP服务器协议正确性、安全性和可靠性的工具,适用于开发流程中的本地CLI运行和GitHub Actions集成。

  • by JamCatAI
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 JamCatAI/mcp-sheriff

使用说明

mcp警长

mcp-sheriff 在MCP服务器作者发货之前,为他们提供快速的信任评分。它lint检查协议形状,标记有风险的安全态势,记录可靠性信号,并将相同的报告插入到本地CLI运行和GitHub操作中。

30秒快速入门

npm install
npm run build
node dist/cli.js check --config ./mcp.json --format console,json,md,sarif

示例 mcp.json

{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["server.js"],
      "cwd": "."
    }
  }
}

示例 mcp-sheriff.json

{
  "defaultServer": "my-server",
  "fixtures": {
    "echo": [
      { "text": "hello sheriff" }
    ]
  },
  "benchmark": {
    "iterations": 5
  }
}

CLI使用情况

mcp-sheriff check [target] \
  --config ./mcp.json \
  --server my-server \
  --format console,json,md,sarif \
  --output-dir reports/mcp-sheriff \
  --fail-on high \
  --experimental fuzz,bench \
  --invoke-fixtures

GitHub行动

name: sheriff

on:
  pull_request:
  push:

jobs:
  sheriff:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      security-events: write
      actions: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npm ci
      - uses: JamCatAI/mcp-sheriff@v0.1.0
        with:
          config-path: ./mcp.json
          format: json,md,sarif
          fail-on: high
          upload-sarif: true

示例输出

健康的服务器:

mcp-sheriff WARN · score 95/100 · good-stdio
critical 0 · high 0 · medium 1 · low 0
transport stdio · tools yes · prompts yes · resources yes
- [medium] Environment is implicitly inherited: No explicit env map is set, so the SDK will inherit its default safe env set.

服务器损坏:

mcp-sheriff FAIL · score 61/100 · bad-stdio
critical 0 · high 2 · medium 2 · low 3
transport stdio · tools yes · prompts yes · resources no
- [high] Possible inline secret found in environment config: Env var "OPENAI_API_KEY" contains a literal value that looks secret-like.
- [high] Shell-wrapped stdio command detected: bash is being used as a shell wrapper for the server command.

评分标准

  • 协议正确性:40
  • 安全态势:35
  • 可靠性和时间:15
  • 可发现性和文档质量:10

实验性模糊测试和基准测试是可选的,并在报告中单独列出。