Skip to main content
Glama
andreolf
by andreolf

mcp-audit

针对 MCP 服务器的 npm audit。 将其指向一个 MCP 服务器,即可获得安全等级(A–F),涵盖缺失认证、SSRF 攻击面、高权限工具、易受提示注入的工具描述以及泄露的密钥。

为什么存在这个工具(2026 年数据):在约 7,000 个公共 MCP 服务器中,41% 无需认证,36.7% 暴露了 SSRF 攻击面,仅 8.5% 使用 OAuth,并且在短短 60 天内提交了 30 多个 CVE。服务器数量已饱和(22k+ 个服务器);安全态势则不然。其他工具(例如 Invariant 的 mcp-scan)深入检查单个服务器——mcpaudit 增加了注册表级批量审计:将其指向官方 MCP 注册表,即可一次性评估整个生态系统的安全等级。

npm i -g @andreolf/mcpaudit    # then: mcpaudit <url>
# or zero-install:  npx @andreolf/mcpaudit <url>

运行它安全吗? 设计上是安全的:mcpaudit 仅发送只读的 initialize + tools/list 握手,并检查声明的工具。它从不执行被扫描服务器的代码,除非你显式传递 --allow-exec 来启动本地/npm 服务器。

⚠️ 启发式扫描器。发现结果描述的是攻击面(例如“无认证”、“暴露了 URL 获取工具”),而非已证实的漏洞——一份干净的报告并非安全保证。仅扫描你被授权测试的服务器,并负责任地披露发现。请参阅 SECURITY.md

用法

扫描一个远程服务器(Streamable HTTP):

node bin/mcp-audit.js https://example.com/mcp
node bin/mcp-audit.js https://example.com/mcp --header "Authorization: Bearer $TOKEN" --json

扫描一个已发布的服务器(通过 npx -y <package> 启动):

node bin/mcp-audit.js --npm @modelcontextprotocol/server-filesystem --timeout 20000

扫描一个通过命令启动的本地服务器(stdio):

node bin/mcp-audit.js --cmd "node my-server.js"

需要 Node 18+(使用全局 fetch)。零依赖。安装:npm i -g @andreolf/mcpaudit 然后 mcpaudit <url>——或者 npx @andreolf/mcpaudit <url>

退出码:0 干净 · 1 严重/高危发现 · 2 无法扫描/用法错误。CI 友好。

Related MCP server: mcp-security-audit

批量模式(启动审计)

扫描多个服务器,获取最差优先排行榜以及用于启动帖子的汇总统计:

node bin/mcp-audit-batch.js targets.txt --out audit.md

targets.txt 每行一个目标(https://…npm:<package>cmd:<command>;允许 # 注释)。

⚠️ 安全性: 扫描 npm:/cmd: 服务器会在你的机器上运行该服务器的代码。批量模式默认仅 HTTP,并跳过本地/npm 目标,除非你传递 --allow-exec——请仅在受信任的沙箱/容器内执行此操作。大规模运行不受信任的包会暴露远程代码执行风险。

输出包含标题数字(“X% 的可达 HTTP 服务器接受无认证的 initialize”),这些数字将成为启动帖子的内容。

完整的启动流程

官方 MCP 注册表拉取目标(仅发现——从不执行服务器),然后审计它们:

node bin/mcp-audit-fetch.js --max 300 --out targets.txt   # HTTP remotes = safe to scan
node bin/mcp-audit-batch.js targets.txt --concurrency 8 --out audit.md

mcpaudit-fetch 将注册表的 HTTP 端点输出为可扫描的行,将 npm 包输出为注释行(使用 --include-npm 选择加入,然后在沙箱中使用 --allow-exec)。对前 30 个注册表服务器的实际运行发现,50% 接受无认证的 initialize——这正是启动帖子所依赖的那种数字。

在 CI 中使用(GitHub Action)

在每个 PR 上对你的 MCP 服务器进行安全门控。启动你的服务器,然后将 action 指向它:

- name: Start my MCP server
  run: node my-server.js &   # or docker run ..., then wait for it to be ready

- name: Security-audit the MCP server
  uses: andreolf/mcp-audit@v1
  with:
    url: http://localhost:3000/mcp
    fail-on: D                      # fail the job on grade D or worse (default: F)
    # header: "Authorization: Bearer ${{ secrets.MCP_TOKEN }}"   # optional

该任务会打印 A–F 等级和发现结果,如果等级低于或等于 fail-on,则任务失败。不会在被扫描的服务器上执行任何操作——它仅发送只读握手。

测试

npm test   # spawns the mock insecure server (stdio + batch) and asserts findings — 12 checks

它检查什么(初始启发式规则——可扩展)

  • no-auth——服务器接受无凭据的 initialize(严重)

  • ssrf-surface——接受 URL / 发出出站请求的工具(高危)

  • high-privilege-tool——exec/shell/delete/write-file 风格的工具(高危)

  • injection-in-description——工具描述中的覆盖/注入措辞(中危)

  • leaked-secret——工具元数据中的令牌/密钥形状字符串(严重)

架构

bin/mcp-audit.js   CLI entry (arg parsing, exit codes for CI)
src/scan.js        orchestrator
src/mcpClient.js   MCP Streamable-HTTP transport: initialize + tools/list
src/checks.js      heuristic security checks -> findings
src/report.js      grading (A–F), badge, Markdown/JSON output

路线图(将这个骨架变成病毒式传播的东西)

  1. stdio + npm 传输——扫描本地(--cmd)和已发布(--npm,通过 npx)的服务器,而不仅仅是远程 URL。这为启动审计解锁了扫描注册表顶级服务器的能力。(PyPI/uvx 等效功能是一个小的后续步骤。)

  2. 静态密钥与 OAuth 检测——检查认证挑战/令牌格式。

  3. 更深入的 SSRF 探测——在沙箱中实际调用 fetch 风格的工具,针对一个金丝雀内部 URL。

  4. 批量模式 + 排行榜——mcpaudit-batch targets.txt → 排名报告 + 标题统计。该排名报告就是启动产物:“我们审计了 200 个安装最多的 MCP 服务器。”

  5. 注册表获取器mcpaudit-fetch)——从官方 MCP 注册表拉取 HTTP 目标(仅发现,从不执行)。npm 包以注释形式输出。使用 --include-npm 选择加入。

  6. 可嵌入徽章——MCP Security: A shields.io 风格的徽章,服务器可添加到其 README(2026 年排名信号,并为你提供免费分发)。

  7. 注册表存在——列在 mcp.so、smithery.ai、glama.ai、PulseMCP、官方 MCP 注册表,并向 punkpeye/awesome-mcp-servers 提交 PR。准备一个元数据包,提交给所有平台。

许可证

MIT

A
license - permissive license
-
quality - not tested
A
maintenance

Maintenance

Maintainers
Response time
0dRelease cycle
2Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    C
    maintenance
    Security scanner for MCP servers. Detects prompt injection, command injection, auth bypass, and excessive permissions across tools, resources, and prompts.
    48
    2
    MIT
  • A
    license
    -
    quality
    C
    maintenance
    Security auditor for MCP servers that enumerates tools, resources, and prompts, scans for injection patterns, classifies risk levels, and produces a scored report (0-100, grades A-F).
    2
    MIT
  • A
    license
    -
    quality
    A
    maintenance
    Security scanner for MCP servers — vet an MCP before you wire it into an agent. Detects prompt-injection, credential exfiltration (via taint analysis), RCE, and supply-chain risks, and catches cross-server exfil chains no single server reveals. Zero-dependency local CLI, SARIF output, CI-gateable, no account.
    43
    MIT
  • A
    license
    C
    quality
    B
    maintenance
    Security scanner and MCP server that catches dangerous patterns in MCP servers and AI agent projects, such as leaked secrets, shell execution, and prompt-injection text. Runs as both a CLI and MCP server with CI-friendly severity gates.
    2
    1
    MIT

View all related MCP servers

Related MCP Connectors

  • Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.

  • Scans MCP servers for tool poisoning, prompt injection and supply chain risks.

  • Grade MCP servers A to F with the open behavioral litmus. npm: full toolset; hosted: lookups only.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/andreolf/mcp-audit'

If you have feedback or need assistance with the MCP directory API, please join our Discord server