# safe4

A hosted MCP server that decides whether an agent's proposed payment should go through, by testing the purchase against the task it was given.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI
- Author: Safe4AI
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/Safe4AI/safe4-mcp
- Updated: 2026-08-27
- HTML: https://affpapa.org/en/nevibecode/mcp/safe4

## What it does

Safe4 covers the gap budget limits leave open. A payment can sit inside every cap, fall into a permitted category and go to an approved payee, yet still be the wrong buy because it does not serve the task. The server compares the purchase with the task and answers `ALLOW` or `DENY`, with a reason code and the concepts it matched.

Nothing gets installed. The service runs at `api.safe4.ai` and connects over Streamable HTTP. Connecting and listing tools cost nothing; only `safe4_authorize` is paid, settled per call in USDC over x402. The free `safe4_price` tool reports the current price and the networks the endpoint accepts, so an agent sees the cost before committing. Call `safe4_authorize` without a payment payload and you get the x402 challenge back; an x402-aware client pays, then calls again with the result in the `payment` argument.

The task and the two allow-lists belong to the principal, not the agent. An agent that fills in `task` itself is grading its own homework, so the server marks the task context as request-supplied and a swapped constraint shows up in the audit entry. Every decision lands in a hash-chained log: each entry carries the previous one's hash, which keeps the record continuous across restarts and redeploys. The demo `examples/mcp_buyer_demo.py` walks the whole free surface and stops before signing anything; it needs only `httpx`.

## Requirements
- Remote server: `https://api.safe4.ai/mcp/`

## Install

### Claude Code (native platform)

**Platform CLI: remote server**
```bash
claude mcp add --transport http safe4 https://api.safe4.ai/mcp/
```

### Codex

**Platform CLI: remote server**
```bash
codex mcp add safe4 --url https://api.safe4.ai/mcp/
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "safe4": {
            "url": "https://api.safe4.ai/mcp/"
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "safe4": {
            "type": "http",
            "url": "https://api.safe4.ai/mcp/"
        }
    }
}
```

### Gemini CLI

**Platform CLI: remote server**
```bash
gemini mcp add -t http safe4 https://api.safe4.ai/mcp/
```

## When to use it
- refuse a payment that does not serve the assigned task
- catch a swapped payee when task text and category look identical
- read the call price before paying for a decision
- keep a decision log that cannot be quietly rewritten
- block a purchase outside the categories the principal permits

## Example prompts
- Check with safe4 whether this purchase is allowed for the task
- What does a safe4_authorize call cost and which networks are accepted?
- Send the payment to safe4 for authorisation and show me the reason code

## Similar
- [agentcash](https://affpapa.org/en/nevibecode/skills/agentcash.md) — skill · 2000 installs
- [x402 Universal Payer](https://affpapa.org/en/nevibecode/mcp/x402-universal-payer.md) — MCP server · ★ 250
- [databroker](https://affpapa.org/en/nevibecode/mcp/databroker.md) — MCP server
- [Pyrimid Protocol](https://affpapa.org/en/nevibecode/mcp/pyrimid-protocol.md) — MCP server
- [x402 economy tools](https://affpapa.org/en/nevibecode/mcp/x402-economy-tools.md) — MCP server
- [ZendIQ](https://affpapa.org/en/nevibecode/mcp/zendiq.md) — MCP server · ★ 1

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
