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 分