Skip to main content
Glama

Safe4 — 面向 AI 智能体的支付防火墙,以 MCP 服务器形式提供

Safe4 通过将购买行为与智能体实际被赋予的任务进行比对,来决定是否应允许该 AI 智能体提议的支付。

它存在的意义,正是预算限额会遗漏的那种情形:一笔支付处于各项预算之内、属于允许的类别、且付款对象是经批准的对手方——但它仍然是错误的购买,因为它并不服务于任务。

本仓库是托管 MCP 服务器的公开清单和客户端示例。服务本身运行在 api.safe4.ai;无需安装任何服务器。

连接

Streamable HTTP,无需安装:

{
  "mcpServers": {
    "safe4": {
      "type": "http",
      "url": "https://api.safe4.ai/mcp/"
    }
  }
}

连接和列出工具都是免费的。只有 safe4_authorize 是付费的。

Related MCP server: EVIDIQ Aegis

工具

safe4_price — 免费

返回当前价格以及该端点接受的支付网络,以便智能体在决定发起付费调用之前了解费用。

safe4_authorize — 付费,每次调用通过 x402 以 USDC 结算

针对提议的支付返回 ALLOWDENY 决策,并附有原因代码、匹配到的概念以及一条哈希链审计条目。

在未附带支付的情况下调用时,它返回的是 x402 质询而非决策。支持 x402 的客户端完成支付后,将得到的 payload 放入 payment 参数再次调用。

参数:

Argument

Meaning

task

智能体被赋予的任务,按其委托人的表述

purchase

正在购买的内容

purchase_purpose

此次购买为何服务于该任务

amount, currency

提议的支付

counterparty

谁会收到这笔款项

service_category

所购物品的类别

allowed_service_categories

委托人允许的类别

allowed_counterparties

可选。委托人允许的收款方

task_id

可选。回显至审计条目

payment

x402 支付 payload。省略以获取价格列表

任务和两个允许列表都是委托人的约束,而非智能体自己的约束——购买行为正是依据这些约束来检验的,因此一个自行编写 task 的智能体等于是给自己的作业打分。Safe4 会记录其收到的每一个字段,并将任务上下文标记为请求方提供,所以被替换的约束之后会在审计条目中显现出来。

无需付费即可试用

该示例运行了全部免费功能——连接、列出工具、读取价格、获取质询——并在签署任何内容之前停止。它只需要 httpx:无需密钥,也无需有钱包资金。

python examples/mcp_buyer_demo.py https://api.safe4.ai --dry-run

去掉 --dry-run 并设置 SAFE4_BUYER_PRIVATE_KEY,即可购买一个真实的决策。它会签署一份 EIP-3009 授权,金额和收款方与服务器公布的分毫不差,而且仅此而已;脚本不托管任何资金,Safe4 也永远不会看到该密钥。

决策的依据

按顺序共有四项检查,一笔购买必须全部通过:

  1. 预算与上限 — 单笔交易、每日及智能体维度的限额。

  2. 服务类别 — 购买内容的类别必须是委托人允许的类别之一。

  3. 对手方 — 当任务声明了 allowed_counterparties 时,向任何其他人的支付都会被拒绝。这是唯一能识别收款人被调换的检查;在这种攻击中,任务文本和类别完全相同。

  4. 任务与购买匹配 — 任务必须能够解释所购内容,而不只是与它有一两个词重合。

每条决策都会被追加到哈希链审计日志中。每个条目都携带前一个条目的哈希,因此记录防篡改,并在重启与重新部署之间保持连续。

支付

按次调用通过 x402 以 USDC 计价。端点会在 402 质询中公布其条款;买家可以选择公布的网络中适合自己的任意一种进行支付。Safe4 不持有钱包密钥,也不托管买家资金。

链接

安全

漏洞报告说明见 SECURITY.md。请不要创建包含漏洞利用细节的公开 issue。

许可

本仓库中的清单和客户端示例均以 MIT 许可授权。它们所描述的托管服务是另一个独立的商业产品。

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (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
    Not graded
    quality
    D
    maintenance
    Enables verification of AI agent identity, authority, and integrity at transaction time, returning signed verdicts for allow, step-up, review, or block.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Autonomous financial policy engine and budget guard for AI agent fleets. It verifies payment payloads, velocity caps, escrow release terms, and slippage inflation, returning risk verdicts and signed attestations.
    1
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Provides a three-layer payment firewall for AI agents, enabling identity verification, risk screening, and execution authorization with on-chain policy enforcement for secure and auditable transactions.
    484
    2
    MIT

View all related MCP servers

Related MCP Connectors

  • Runtime permission, approval, and audit layer for AI agent tool execution.

  • Verify x402 payment endpoints before an AI agent pays: scam scan, on-chain checks, trust scores.

  • See, price, and control every tool call your AI agents make: policy checks, cost, and audit tools.

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/Safe4AI/safe4-mcp'

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