Safe4

ai.safe4由 safe4.ai 发布官方发布者v1.0.0更新于 Oct 24, 2026

Tests an AI agent's purchase against the task it was given. Paid per call in USDC via x402.

已验证Streamable HTTP可网页运行金融安全与监控

概览

AI 生成的概览

一个托管型 MCP 服务器,用于检验 AI 代理拟进行的付款是否符合其被赋予的任务,并返回允许或拒绝的决定。

可以做什么
免费查询一次 Safe4 决策的价格与可接受的支付网络,便于在付费调用前了解成本。提交拟议购买及其任务、用途、金额、交易对手和类别,获得带原因代码和匹配概念的 ALLOW 或 DENY 决定。按预算上限、允许的服务类别、允许的交易对手以及任务与购买是否匹配进行检验。将每次决定写入哈希链式审计日志。
适用场景
适用于代理可自主花钱、且需要确认某笔购买确实服务于所分配任务(而不只是未超预算、收款方已批准)的场景。当交易对手被调换或购买偏离任务构成实际风险时尤其有用。
运行要求
远程 streamable HTTP 端点,无需安装。连接和列出工具免费。付费决策按次以 USDC 通过 x402 结算,真实决策需要支持 x402 的客户端和已充值钱包;免费部分无需密钥或钱包即可试用。
安装前请注意
仅价格工具免费,每次授权调用都需支付 USDC。任务和允许清单本应由委托方提供,代理自行填写任务等于自己给自己打分,不过 Safe4 会在审计条目中将任务上下文标记为请求方提供。示例客户端需在 SAFE4_BUYER_PRIVATE_KEY 中提供买方私钥以完成支付;服务方声明不持有钱包密钥、不托管资金。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Safe4,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/ai.safe4%2Fsafe4/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。

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

README

Safe4 — the payment firewall for AI agents, as an MCP server

Safe4 decides whether an AI agent's proposed payment should be allowed, by testing the purchase against the task the agent was actually given.

The case it exists for is the one budget limits miss: a payment that is inside every budget, in an allowed category, and to an approved counterparty — and is still the wrong purchase, because it does not serve the task.

This repository is the public manifest and client example for the hosted MCP server. The service itself runs at api.safe4.ai; there is no server to install.

Connect

Streamable HTTP, no installation:

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

Connecting and listing tools are free. Only safe4_authorize is paid.

Tools

safe4_price — free

Returns the current price and the payment networks the endpoint accepts, so an agent can see the cost before committing to a paid call.

safe4_authorize — paid, settled per call in USDC over x402

Returns an ALLOW or DENY decision for a proposed payment, with a reason code, the concepts it matched, and a hash-chained audit entry.

Called without a payment it returns the x402 challenge instead of a decision. An x402-aware client pays and calls again with the resulting payload in the payment argument.

Arguments:

ArgumentMeaning
taskThe task the agent was given, as stated by its principal
purchaseWhat is being bought
purchase_purposeWhy this purchase serves the task
amount, currencyThe proposed payment
counterpartyWho would receive it
service_categoryCategory of the thing being bought
allowed_service_categoriesCategories the principal permits
allowed_counterpartiesOptional. Payees the principal permits
task_idOptional. Echoed into the audit entry
paymentAn x402 payment payload. Omit to receive the price list

The task and the two allow-lists are the principal's constraints, not the agent's — they are what the purchase is tested against, so an agent that writes its own task is grading its own homework. Safe4 records every field it was given and marks the task context as request-supplied, so a substituted constraint is visible in the audit entry afterwards.

Try it without paying

The example runs the entire free surface — connect, list tools, read the price, fetch the challenge — and stops before signing anything. It needs only httpx: no key, no funded wallet.

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

Drop --dry-run and set SAFE4_BUYER_PRIVATE_KEY to buy a real decision. That signs an EIP-3009 authorisation for exactly the amount and payee the server advertised, and nothing else; the script holds no custody and Safe4 never sees the key.

What a decision rests on

Four checks, in order, and a purchase must clear all of them:

  1. Budget and caps — per-transaction, daily, and agent-scoped limits.
  2. Service category — the purchase's category must be one the principal permitted.
  3. Counterparty — when the task declares allowed_counterparties, payment to anyone else is refused. This is the only check that sees a swapped payee; task text and category are identical in that attack.
  4. Task-to-purchase match — the task must account for what the purchase says it is buying, not merely share a word or two with it.

Every decision is appended to a hash-chained audit log. Each entry carries the previous entry's hash, so the record is tamper-evident and continuous across restarts and redeploys.

Payment

Priced per call in USDC over x402. The endpoint advertises its terms in the 402 challenge; buyers pay on whichever advertised network suits them. Safe4 holds no wallet key and takes no custody of buyer funds.

Links

Security

Reporting instructions are in SECURITY.md. Please do not open a public issue containing exploit details.

License

The manifest and client examples in this repository are MIT licensed. The hosted service they describe is a separate commercial product.

来源:README.md,提交 21c0542

工具

2

safe4_price

Safe4 price

Price and accepted payment networks for one Safe4 decision. Free to call. Returns the same x402 terms the HTTP endpoint advertises, so an agent can see the cost before committing to a paid call.

无需输入参数。

safe4_authorize

Safe4 authorize

Decide whether a proposed agent payment should proceed. Settled per call in USDC over x402. Called without ``payment`` it returns the price list rather than a decision; call it again with the signed payload to receive one. The task and the two allow-lists are the principal's constraints, not the agent's: they are what the purchase is tested against, so an agent that writes its own ``task`` is grading its own homework. Safe4 records every field it was given in the audit entry and marks the task context as request-supplied, so a substituted constraint is visible afterwards. Args: task: The task the agent was given, as stated by its principal. purchase: What is being bought. purchase_purpose: Why this purchase serves the task. amount: Decimal amount as a string, for example "25.00". currency: Currency of the proposed payment, for example "USDC". counterparty: Who would receive the payment. service_category: Category of the thing being bought. allowed_service_categories: Categories the principal permits. allowed_counterparties: Optional payees the principal permits. When supplied, payment to anyone else is denied. task_id: Optional caller-side task identifier, echoed into the audit. payment: An x402 payment payload for this call. Omit to receive the price list instead of a decision.

输入参数task必填amount必填paymenttask_idcurrency必填purchase必填counterparty必填purchase_purpose必填service_category必填allowed_counterpartiesallowed_service_categories必填

版本历史

1
  1. v1.0.0最新Sep 16, 2026

评分

已满足适用检查项的 100%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通必需25 分
  • 已声明认证方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分