Skip to main content
Glama

MCPKernel — AI 代理的安全内核

开源 MCP/A2A 安全网关,可阻止工具投毒、数据外泄、提示词注入和“拉地毯”(rug-pull)攻击 — 具备策略强制执行、污染跟踪、沙箱化执行、确定性信封、技能审计以及针对每个 AI 代理工具调用的 Sigstore 审计功能。适用于 Claude Desktop、Cursor、VS Code、Windsurf、OpenClaw 以及任何 MCP 客户端。符合 OWASP ASI 2026 标准。

CI PyPI version Tests Coverage License: Apache 2.0 Python 3.12+ Downloads Docs

阅读完整文档 →


快速入门

选项 A:安全网关(代理模式)

pip install "mcpkernel[all]"
mcpkernel serve --host 127.0.0.1 --port 8000

将您的 MCP 客户端指向 http://localhost:8000/mcp,而不是直接指向工具服务器。现在,每个工具调用都经过策略检查、污染扫描、沙箱化和审计记录。

选项 B:MCP 服务器(工具模式 — 一条命令)

pip install mcpkernel
mcpkernel install claude    # or: cursor, vscode, windsurf, zed, openclaw, goose

这会将 MCPKernel 作为 MCP 服务器添加到您的 IDE 中。您的代理现在可以原生调用 mcpkernel_scan_toolmcpkernel_check_taintmcpkernel_validate_policy 等功能。

选项 C:Python API

from mcpkernel import MCPKernelProxy

async with MCPKernelProxy(
    upstream=["http://localhost:3000/mcp"],
    policy="strict",
    taint=True,
) as proxy:
    result = await proxy.call_tool("read_file", {"path": "data.csv"})

或者使用一个装饰器保护任何函数:

from mcpkernel import protect

@protect(policy="strict", taint=True)
async def read_data(path: str) -> str:
    return Path(path).read_text()

Related MCP server: mcp-guardian

为什么选择 MCPKernel?

AI 代理(LangChain、CrewAI、AutoGen、Copilot、OpenClaw)会自主调用工具 — 读取文件、执行代码、发起 HTTP 请求。仅在 OpenClaw 等项目中就有 344+ 个已报告的安全公告,其中包含严重的漏洞,包括工具投毒攻击、权限提升、数据外泄和“拉地毯”漏洞。

MCPKernel 是缺失的安全瓶颈。 它位于您的代理和 MCP 工具服务器之间,对每一个调用强制执行安全策略:

┌─────────────┐     ┌──────────────────────────┐     ┌─────────────┐
│  AI Agent    │────▶│       MCPKernel           │────▶│  MCP Tool   │
│ (LangChain,  │◀────│  Security Gateway        │◀────│  Server     │
│ CrewAI,      │     └──────────────────────────┘     └─────────────┘
│ OpenClaw,    │      │ Policy │ Taint │ Sandbox │
│ Cursor, etc) │      │  DEE   │ Audit │ eBPF    │
└─────────────┘      │ Skills │ DLP   │ Doctor  │

每个工具调用会发生什么:

步骤

MCPKernel 的操作

1. 策略检查

根据带有 OWASP ASI 2026 映射的 YAML 规则进行评估 — 阻止或允许

2. 污染扫描

检测参数中的机密信息(AWS 密钥、JWT)、PII(社保号、信用卡)和用户输入

3. DLP 防护

防止跨工具边界的多跳数据泄露(PII 输入 → HTTP 输出 = 阻止)

4. 沙箱执行

在 Docker、Firecracker、WASM 或微沙箱中运行代码 — 绝不在裸机上运行

5. 确定性信封

对输入/输出进行哈希处理,并对跟踪记录进行 Sigstore 签名 — 完全可重放

6. 审计日志

写入防篡改的仅追加日志,支持 SIEM 导出(CEF、JSONL、CSV、SARIF)



MCP 安全问题

MCP 生态系统发展迅速,但安全性并未跟上。以下是 MCPKernel 防御的现实威胁:

威胁

工作原理

现实影响

MCPKernel 防御

工具投毒

工具描述中隐藏的 <IMPORTANT> 指令诱导代理读取 SSH 密钥、.env 文件、凭据

Cursor、Claude Desktop、任何 MCP 客户端 — 凭据被静默窃取

投毒扫描器检测隐藏指令、Unicode 混淆、<IMPORTANT>

工具劫持

恶意 MCP 服务器注入覆盖受信任服务器行为的指令(例如,将所有邮件重定向到攻击者)

代理在看似使用受信任工具的同时将数据发送给攻击者

跨服务器策略隔离 + 污染标签阻止数据流向不受信任的接收端

MCP 拉地毯

用户批准安装后,服务器更改工具描述

受信任工具一夜之间变恶意 — 无检测

DEE 信封哈希锁定工具描述;漂移检测捕获更改

权限提升

身份验证重新连接自称 operator.admin;插件继承完全主机信任

OpenClaw 中的 2 个严重 CVE (GHSA-9hjh, GHSA-fqw4) — 通过扩大范围实现 RCE

策略引擎强制执行最小权限;无隐式管理员提升

数据外泄

代理读取机密后将其作为隐藏参数传递给外部工具

PII、API 密钥、SSH 密钥通过工具参数中的侧信道泄露

污染跟踪 + DLP 链检测阻止受污染数据到达接收端

技能供应链

恶意 OpenClaw/ClawHub 技能包含 `curl

bashrm -rf`、外泄端点

用户安装了后门程序

技能扫描器在安装前审计 SKILL.md 中的 25+ 种危险模式

沙箱逃逸

沙箱关闭时执行在主机上运行 (OpenClaw 默认: sandbox.mode=off)

代理代码以完全 OS 权限运行

4 种沙箱后端 (Docker, Firecracker, WASM, 微沙箱) — 设计上优先考虑沙箱

无审计追踪

没有代理做了什么、何时做、为什么做的防篡改记录

无法调查事件或证明合规性

Sigstore 签名仅追加日志,支持 SIEM 导出 (CEF, JSONL, CSV, SARIF)

OpenClaw 有 344+ 个安全公告,包括 2 个严重的 RCE 漏洞、范围绕过问题和 Webhook 身份验证漏洞。MCPKernel 是 OpenClaw 等平台需要但未内置的安全层。


功能

核心安全流水线

  • YAML 策略引擎 — 为每个工具、参数模式或污染标签定义允许/拒绝/审计/沙箱规则

  • 污染跟踪 — 自动检测工具调用参数中的机密、PII、API 密钥、JWT

  • DLP 链检测 — 防止跨工具边界的多跳数据泄露(数据库 → HTTP 被阻止)

  • 4 种沙箱后端 — Docker、Firecracker 微型虚拟机、WASM、微沙箱

  • 确定性执行信封 (DEE) — 每次执行都经过哈希处理并进行 Sigstore 签名以供重放

  • OWASP ASI 2026 合规性 — 内置策略集,映射到 ASI-01 至 ASI-08

  • 仅追加审计日志 — 基于 SQLite,内容哈希,支持 CEF/JSONL/CSV/SARIF SIEM 导出

威胁检测与扫描

  • 工具投毒扫描器 — 检测 MCP 工具描述中的隐藏指令、Unicode 混淆和提示词注入

  • 技能扫描器 — 审计 OpenClaw/ClawHub SKILL.md 文件中的危险 Shell 命令、外泄模式和隐藏指令

  • MCP 配置发现 — 自动发现 Claude、Cursor、VS Code、Windsurf、Zed、OpenClaw、Goose 中的 MCP 配置

  • Snyk 代理扫描桥 — 运行 Snyk 的 agent-scan CLI 并根据发现结果自动生成策略规则

多客户端集成

  • 一键安装mcpkernel install claude 为任何受支持的 IDE 添加安全工具

  • MCPKernel 作为 MCP 服务器 — 将扫描、验证、污染检查和诊断作为原生代理工具公开

  • 7 个受支持的客户端 — Claude Desktop、Cursor、VS Code、Windsurf、Zed、OpenClaw、Goose

  • OpenClaw 安全技能 — 适用于 OpenClaw/ClawHub 生态系统的可安装技能包

开发者体验

  • Python APIMCPKernelProxy 类和 @protect 装饰器,用于编程使用

  • 策略预设 — 内置 permissive(宽松)、standard(标准)和 strict(严格)预设 — 零配置安全

  • Doctor 诊断mcpkernel doctor 检查 Python、依赖项、配置、暴露的机密、权限

  • VS Code 扩展 — 用于已发现服务器的树状视图、安全发现面板、集成命令

平台与可观测性

  • Kong 风格插件流水线pre_execution → execution → post_execution → log,具有优先级

  • 速率限制 — 基于身份的令牌桶,带有 LRU 驱逐

  • Prometheus 指标 + OpenTelemetry — 开箱即用的完整可观测性

  • 可选 eBPF 探针 — MCP 边界处的内核级系统调用监控

  • 代理清单集成 — 加载 agent.yaml,将合规性(FINRA/SEC)转换为策略规则,阻止未声明的工具

  • Langfuse 可观测性导出 — 异步批量导出到 Langfuse,用于 LLM 级分析

  • Guardrails AI 验证 — 通过 Guardrails 中心验证器增强 PII、机密和毒性检测

  • MCP 服务器注册表 — 从官方注册表发现、搜索和验证上游 MCP 服务器

因果信任图 (CTG) — 创新研究贡献

  • 自适应信任衰减 — 工具/服务器信任呈指数级衰减:T(t) = T₀ · e^{-λ(t-t₀)} · Π w(vᵢ)

  • 追溯性污染失效 — 当源被破坏时,所有下游数据都会被追溯性地标记为污染

  • 行为指纹识别 — 通过图拓扑 Z 分数检测异常的工具调用模式

  • 最小权限计算 — 从观察到的因果链中推导出可证明的最小权限

  • 因果链分析 — 将任何工具输出追溯到其根数据源

安全保护 (MCP 规范 2025-11-25)

  • 混淆代理防御 — 通过工具/服务器允许列表防止跨服务器委托攻击

  • 令牌透传防护 — 阻止参数和结果中的凭据泄露(OpenAI 密钥、GitHub PAT、AWS 密钥、JWT)

  • SSRF 防护 — 阻止私有网络、云元数据 (169.254.169.254),支持域名允许列表

  • 会话劫持防御 — 带有客户端指纹验证和过期的 HMAC 绑定会话

  • 内存投毒防御 — 通过重复评分检测自我强化的注入(僵尸代理)

  • 统一安全流水线 — 在单次 pipeline.check_tool_call() 调用中运行所有检查

合规预设

  • 一行激活apply_preset("hipaa", settings) 配置所有安全控制

  • 5 个内置预设 — HIPAA、SOC 2、PCI DSS v4.0、GDPR 第 25 条、FedRAMP High

  • YAML 可配置 — 在配置文件中设置 compliance.preset: hipaa


入门

# Install with all backends
pip install "mcpkernel[all]"

# Start the security gateway
mcpkernel serve --host 127.0.0.1 --port 8000

将您的 MCP 客户端指向 http://localhost:8000/mcp,而不是直接指向工具服务器。

将 MCPKernel 添加为 MCP 服务器(代理可调用的安全工具)

# Install into your IDE — one command
mcpkernel install claude    # Claude Desktop
mcpkernel install cursor    # Cursor IDE
mcpkernel install vscode    # VS Code + Copilot
mcpkernel install windsurf  # Windsurf
mcpkernel install zed       # Zed
mcpkernel install openclaw  # OpenClaw
mcpkernel install goose     # Goose

安装后,您的代理可以原生调用这些安全工具:

MCP 工具

功能

mcpkernel_scan_tool

扫描工具描述以查找投毒、劫持和提示词注入

mcpkernel_validate_policy

验证 YAML 策略文件的语法和逻辑错误

mcpkernel_discover_configs

查找系统上的所有 MCP 配置

mcpkernel_check_taint

检查文本中泄露的机密、PII 和 API 密钥

mcpkernel_scan_skill

审计 OpenClaw/ClawHub SKILL.md 中的危险模式

mcpkernel_doctor

对 MCPKernel 安装运行健康诊断

运行健康诊断

mcpkernel doctor

检查:Python 版本、依赖项、配置文件有效性、环境中暴露的机密、工具可用性和文件权限。

安装前扫描技能

# Scan a single skill
mcpkernel scan-skill path/to/SKILL.md

# Scan a directory of skills
mcpkernel scan-skill skills/ --json

检测:curl|bash 管道、rm -rf、外泄端点、硬编码 API 密钥、隐藏指令、未声明的环境变量等。


用例 — 指导设置

1. 安全 AI 编码助手 (Copilot, Cursor, Windsurf)

防止您的编码助手外泄机密或覆盖关键文件。

pip install "mcpkernel[all]"
mcpkernel init

添加策略以阻止敏感文件访问:

# .mcpkernel/policies/coding_assistant.yaml
rules:
  - id: CA-001
    name: Block secret file reads
    action: deny
    tool_patterns: ["read_file", "file_read"]
    arg_patterns:
      path: ".*\\.(env|pem|key|credentials)$"

  - id: CA-002
    name: Block outbound HTTP with tainted data
    action: deny
    tool_patterns: ["http_post", "http_request", "fetch"]
    taint_labels: [secret, pii]

启动网关并将您的 MCP 客户端指向它:

mcpkernel serve --port 8000
# In your editor's MCP config: http://localhost:8000/mcp

2. 自主代理框架 (LangChain, CrewAI, AutoGen)

沙箱化代理进行的每一次工具调用 — 没有代码在裸机上运行。

pip install "mcpkernel[docker]"
mcpkernel init

配置 Docker 沙箱:

# .mcpkernel/config.yaml
sandbox:
  backend: docker
  timeout_seconds: 30

policy:
  default_action: audit   # log everything, deny dangerous calls

通过 MCPKernel 路由您的框架:

import httpx

# Instead of calling tools directly, route through MCPKernel
result = httpx.post("http://localhost:8000/mcp", json={
    "method": "tools/call",
    "params": {"name": "execute_code", "arguments": {"code": "print('hello')"}}
})

查看完整示例:LangChain, CrewAI, AutoGen


3. 企业级 MCP 部署 (OWASP ASI 合规性)

将 MCPKernel 部署为带有严格 OWASP ASI 2026 策略的中央瓶颈。

pip install "mcpkernel[all]"
mcpkernel init

# Apply the strict OWASP policy set
cp policies/owasp_asi_2026_strict.yaml .mcpkernel/policies/
# .mcpkernel/config.yaml
policy:
  default_action: deny   # deny-by-default for production
  policy_paths:
    - .mcpkernel/policies/owasp_asi_2026_strict.yaml

observability:
  metrics_enabled: true
  otlp_endpoint: "http://your-otel-collector:4317"

将审计日志导出到您的 SIEM:

mcpkernel audit-query --format cef > siem_export.log
mcpkernel audit-verify  # verify tamper-proof chain

4. 研究可重复性 (确定性执行)

每个工具调用都经过哈希处理并进行 Sigstore 签名 — 精确重放任何执行。

pip install mcpkernel
mcpkernel serve

通过 MCPKernel 运行实验后:

# List all traces
mcpkernel trace-list

# Export a trace for your paper's appendix
mcpkernel trace-export <trace-id> > experiment_trace.json

# Replay and verify — detects any drift
mcpkernel replay <trace-id>

确定性执行信封 (DEE) 确保评审人员可以独立验证您的结果。


5. 多代理工作流 (跨工具污染跟踪)

防止 PII 在多代理流水线中的工具边界之间泄露。

# .mcpkernel/policies/taint_isolation.yaml
rules:
  - id: TAINT-001
    name: Block PII in outbound calls
    action: deny
    tool_patterns: ["http_post", "send_email", "slack_message"]
    taint_labels: [pii, secret]

  - id: TAINT-002
    name: Audit all user input propagation
    action: audit
    taint_labels: [user_input]

MCPKernel 跟踪跨工具调用的污染标签(机密、PII、用户输入) — 如果代理 A 的数据库查询返回了社保号,代理 B 的 HTTP POST 将自动被阻止发送这些信息。


6. 受监管行业 (FINRA, SEC, 美联储)

使用代理清单进行自动合规性强制执行。

# Validate your agent's compliance declarations
mcpkernel manifest-validate /path/to/agent-repo

# Import and generate policy rules from agent.yaml
mcpkernel manifest-import /path/to/agent-repo > compliance_rules.yaml

MCPKernel 读取您的 agent.yaml 并自动生成策略规则

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityInactive
ResponsivenessResponsive

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    A transparent proxy and execution firewall that intercepts and audits AI agent tool calls against configurable security policies before forwarding them to downstream MCP servers. It provides safe execution environments with features like data redaction, anti-loop protection, and unified alert dispatching.
    -
  • A
    license
    Not graded
    quality
    B
    maintenance
    A gateway that enforces permissions, sanitization, approval, and audit for AI agent MCP tool calls, with a policy engine and local proxy CLI.
    22
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A defensive gateway and firewall for AI agents using MCP servers, scanning tool calls, responses, and manifests for prompt injection, secrets, dangerous commands, and drift before allowing execution.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Governed MCP gateway that lets AI agents call tools with policy enforcement, prompt-injection screening, a kill-switch, and tamper-evident signed audit logs.
    Apache 2.0

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/piyushptiwari1/mcpkernel'

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