Skip to main content
Glama

npm version npm downloads License: MIT IETF Draft MCP Registry PyPI: protect-mcp-adk

protect-mcp

用于 MCP 服务器和 Claude Code 钩子的企业级安全网关。提供签名回执、Cedar 策略和支持集群的审计追踪。

已集成至 Microsoft Agent Governance Toolkit | IETF 互联网草案 | 在线演示: acta.today/wiki

快速入门 — Claude Code

两条命令。每个工具调用都会生成回执。

# 1. Generate hooks, keys, Cedar policy, and /verify-receipt skill
npx protect-mcp init-hooks

# 2. Start the hook server
npx protect-mcp serve

在同一项目中打开 Claude Code。现在,每个工具调用都会被拦截、评估并签名。

init-hooks 创建的内容

文件

用途

.claude/settings.json

钩子配置 (PreToolUse, PostToolUse, 以及 9 个生命周期事件)

keys/gateway.json

Ed25519 签名密钥对 (自动被 git 忽略)

policies/agent.cedar

Cedar 策略入门示例 — 可根据需要自定义

protect-mcp.json

包含签名和速率限制的 JSON 策略

.claude/skills/verify-receipt/SKILL.md

用于 Claude Code 的 /verify-receipt 技能

架构

Claude Code  →  POST /hook  →  protect-mcp (Cedar + sign)  →  response
                                    ↓
                            .protect-mcp-log.jsonl
                            .protect-mcp-receipts.jsonl
  • PreToolUse: 同步 Cedar 策略检查 → 拒绝则阻止工具执行

  • PostToolUse: 异步回执签名 → 对延迟无影响

  • 拒绝在架构上是最终决定 — 模型或其他钩子无法覆盖它

端点

方法

路径

描述

POST

/hook

Claude Code 钩子端点

GET

/health

服务器状态、策略信息、签名者信息

GET

/receipts

最近的签名回执

GET

/receipts/latest

最新的回执

GET

/suggestions

自动生成的 Cedar 策略修复建议

GET

/alerts

配置篡改检测警报

验证回执

# Inside Claude Code:
/verify-receipt

# From terminal:
curl http://127.0.0.1:9377/receipts/latest | jq .
npx protect-mcp receipts

# Check policy suggestions:
curl http://127.0.0.1:9377/suggestions | jq .

Related MCP server: verify-mcp

快速入门 — MCP 服务器封装

将任何 stdio MCP 服务器封装为透明代理:

# Shadow mode — log every tool call, enforce nothing
npx protect-mcp -- node my-server.js

# Enforce mode with policy
npx protect-mcp --policy protect-mcp.json --enforce -- node my-server.js

# Generate keys + config template
npx protect-mcp init

工作原理

protect-mcp 根据策略(JSON、Cedar 或外部 PDP)评估每个工具调用,将决策作为 Ed25519 回执进行签名,并记录结果。

两种集成模式:

模式

传输

使用场景

钩子服务器

HTTP (npx protect-mcp serve)

Claude Code, 智能体集群

Stdio 代理

stdin/stdout (npx protect-mcp -- ...)

Claude Desktop, Cursor, 任何 MCP 客户端

三种策略引擎:

引擎

配置

说明

JSON

--policy policy.json

简单的工具级规则

Cedar

--cedar ./policies/

通过 @cedar-policy/cedar-wasm 进行本地 WASM 评估

外部 PDP

policy_engine: "external"

OPA, Cerbos 或任何 HTTP PDP

集群追踪

在多智能体对话中,protect-mcp 会自动追踪集群拓扑。

处理 11 个钩子事件:

事件

类型

描述

PreToolUse

同步

工具执行前的 Cedar/策略评估

PostToolUse

异步

工具执行后的回执签名

SubagentStart / SubagentStop

生命周期

工作智能体生成/完成

TaskCreated / TaskCompleted

生命周期

协调器任务分配

SessionStart / SessionEnd

生命周期

包含沙箱检测的会话生命周期

TeammateIdle

生命周期

智能体利用率监控

ConfigChange

安全

.claude/settings.json 的篡改检测

Stop

生命周期

完成 + 策略建议摘要

每个回执包含:

  • swarm.agent_id, swarm.agent_type, swarm.team_name

  • timing.tool_duration_ms, timing.hook_latency_ms

  • payload_digest (针对 >1KB 有效载荷的 SHA-256 哈希)

  • deny_iteration (被拒绝后的重试次数)

  • sandbox_state (启用/禁用/不可用)

  • OpenTelemetry otel_trace_idotel_span_id

策略文件

{
  "default_tier": "unknown",
  "tools": {
    "dangerous_tool": { "block": true },
    "admin_tool": { "min_tier": "signed-known", "rate_limit": "5/hour" },
    "read_tool": { "require": "any", "rate_limit": "100/hour" },
    "*": { "rate_limit": "500/hour" }
  },
  "signing": {
    "key_path": "./keys/gateway.json",
    "issuer": "protect-mcp",
    "enabled": true
  }
}

Cedar 策略

Cedar 的拒绝决定是权威的 — 无法被覆盖。

// Allow read-only tools
permit(
  principal,
  action == Action::"MCP::Tool::call",
  resource == Tool::"Read"
);

// Block destructive tools
forbid(
  principal,
  action == Action::"MCP::Tool::call",
  resource == Tool::"delete_file"
);

当工具被拒绝时,protect-mcp 会通过 GET /suggestions 自动建议最小化的 Cedar permit() 规则。

基于 CVE 的策略包

每个策略都能预防真实攻击:

策略

事件

OWASP

clinejection.json

CVE-2025-6514: MCP OAuth 代理劫持 (437K 环境)

A01, A03

terraform-destroy.json

自主 Terraform 智能体销毁生产环境

A05, A06

github-mcp-hijack.json

通过精心构造的 GitHub Issue 进行提示词注入

A01, A02, A03

data-exfiltration.json

通过出站工具滥用窃取智能体数据

A02, A04

financial-safe.json

未经授权的金融交易

A05, A06

policies/cedar/ 中提供 Cedar 等效策略。

MCP 客户端配置

Claude Desktop

{
  "mcpServers": {
    "my-protected-server": {
      "command": "npx",
      "args": [
        "-y", "protect-mcp",
        "--policy", "/path/to/protect-mcp.json",
        "--enforce",
        "--", "node", "my-server.js"
      ]
    }
  }
}

Cursor / VS Code

模式相同 — 将服务器命令替换为封装它的 protect-mcp

CLI 命令

Commands:
  serve             Start HTTP hook server for Claude Code (port 9377)
  init-hooks        Generate Claude Code hook config + skill + sample Cedar policy
  quickstart        Zero-config onboarding: init + demo + show receipts
  init              Generate Ed25519 keypair + config template
  demo              Start a demo server wrapped with protect-mcp
  doctor            Check your setup: keys, policies, verifier, connectivity
  trace <id>        Visualize the receipt DAG from a given receipt_id
  status            Show tool call statistics from the decision log
  digest            Generate a human-readable summary of agent activity
  receipts          Show recent persisted signed receipts
  bundle            Export an offline-verifiable audit bundle
  simulate          Dry-run a policy against recorded tool calls
  report            Generate a compliance report from an audit bundle

Options:
  --policy <path>   Policy/config JSON file
  --cedar <dir>     Cedar policy directory
  --enforce         Enable enforcement mode (default: shadow)
  --port <port>     HTTP server port (default: 9377 for serve)
  --verbose         Enable debug logging

决策日志

每个工具调用都会向 stderr 输出结构化的 JSON:

[PROTECT_MCP] {"v":2,"tool":"read_file","decision":"allow","reason_code":"cedar_allow","policy_digest":"a1b2c3...","mode":"enforce","hook_event":"PreToolUse","timing":{"hook_latency_ms":1},"otel_trace_id":"..."}

当配置了签名时,签名的回执会被持久化到 .protect-mcp-receipts.jsonl

审计包

npx protect-mcp bundle --output audit.json

包含回执和签名密钥的自包含、可离线验证的包。使用 npx @veritasacta/verify 进行验证。

验证知识库 (acta.today/wiki)

protect-mcp 的回执签名功能支持了全球首个验证型多模型知识库 acta.today/wiki

每个知识单元 (Knowledge Unit) 均由 4 个前沿模型在 3 轮对抗中审议产生,且每个模型响应都有 Ed25519 回执。当前模型列表:

模型

提供商

来源

Claude Opus 4.6

Anthropic

美国

GPT-5.4

OpenAI

美国

Grok 4.20

xAI

美国

Gemini 3.1 Pro

Google

美国

DeepSeek V3.2

DeepSeek

中国

MiniMax M2.7

MiniMax

中国

Kimi K2.5

Moonshot

中国

Qwen 2.5 72B

Alibaba

中国

每个 KU 均可独立验证:npx @veritasacta/verify receipt.json

生态集成

项目

星标

集成

状态

Microsoft Agent Governance Toolkit

600+

Cedar 策略桥接 + 回执签名

已合并 (PR #667)

Mission Control

3,700+

用于 MCP 审计流水线的 Ed25519 回执签名

已提交 PR #556

Assay

将签名回执作为证据来源

积极讨论中 (#1029)

Hermes Agent

24,500+

技能执行的加密审计追踪

Issue #5041

DeerFlow

57,600+

持久化层的加密完整性

讨论 #1855

Pro-Workflow

1,500+

MCP 配置建议

PR #41

Zeroshot

1,400+

验证器结论的加密回执

Issue #464

标准与知识产权

  • IETF 互联网草案

  • 专利状态:4 项澳大利亚临时专利申请中 (2025-2026),涵盖具有可配置披露的决策回执、工具调用网关、智能体清单和便携式身份

  • 验证:Apache-2.0 — npx @veritasacta/verify --self-test

  • Microsoft AGT 集成PR #667 — 智能体治理工具包的 Cedar 策略桥接

相关仓库

仓库

描述

VeritasActa/Acta

可争议公共记录的开放协议 (Apache-2.0)

VeritasActa/drafts

IETF 互联网草案源文件

ScopeBlind/examples

集成示例:Claude Code 钩子、Express API、MCP 服务器签名

@veritasacta/verify

离线回执验证器 (Apache-2.0)

@scopeblind/passport

智能体身份 SDK (Apache-2.0)

protect-mcp-adk

Google ADK 回执签名插件 (MIT, Python)

贡献

欢迎提交 Issue 和 Pull Request。对于重大变更,请先开启一个 Issue。

  • Bug 报告:包含 protect-mcp 版本、Node.js 版本和复现步骤

  • Cedar 策略:通过 PR 将可重用策略分享到 policies/cedar/ 目录

  • 集成示例:添加到 ScopeBlind/examples

许可证

MIT — 可自由使用、修改、分发和构建,无任何限制。

scopeblind.com · npm · veritasacta.com · IETF 草案

-
security - not tested
A
license - permissive license
-
quality - not tested

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/ScopeBlind/scopeblind-gateway'

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