# safeagent

Blocks an AI agent from repeating the same action twice by tracking a stable request_id and rejecting duplicate calls.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 8
- Author: azender1
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/azender1/SafeAgent
- Updated: 2026-10-07
- HTML: https://affpapa.org/en/nevibecode/mcp/safeagent

## What it does

Each agent action gets a request_id. Calling `/claim` the first time returns PROCEED; calling it again with the same id returns SKIP along with the stored result. If a claim stays in PENDING after a crash or timeout, the server keeps it blocked instead of letting the agent fire the action again on its own.

The flow moves through three states: CLAIMABLE, PENDING, COMMITTED. An action is only marked COMMITTED once `/settle/{request_id}` is called with the outcome, so skipping that call leaves the claim stuck in PENDING. The project is upfront about scope: the server confirms its own claim record, not whether the outside provider actually processed the action once, so payment-style operations still need checking against the provider's own records.

Useful for stopping duplicate side effects from retries, like a payment firing twice after a timeout, a signup email going out two times, or a webhook from a provider that's allowed to deliver the same event more than once getting processed again.

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add safeagent -- uvx safeagent-exec-guard
```
uvx runs the command named after the package; if the README names another one, use uvx --from safeagent-exec-guard <command>

### Codex

**Platform CLI**
```bash
codex mcp add safeagent -- uvx safeagent-exec-guard
```
uvx runs the command named after the package; if the README names another one, use uvx --from safeagent-exec-guard <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "safeagent": {
            "command": "uvx",
            "args": [
                "safeagent-exec-guard"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from safeagent-exec-guard <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "safeagent": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "safeagent-exec-guard"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from safeagent-exec-guard <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add safeagent uvx safeagent-exec-guard
```
uvx runs the command named after the package; if the README names another one, use uvx --from safeagent-exec-guard <command>

## When to use it
- stop a payment retry from charging a customer twice
- prevent a signup flow from sending the welcome email twice
- guard against reprocessing a webhook a provider delivers more than once
- block a provisioning retry from creating a second workspace
- keep an unresolved agent action blocked instead of silently retrying it

## Example prompts
- Check SafeAgent before resubmitting the order:TQQQ:buy:6 trade so it isn't placed twice
- Claim a request id for the signup email and settle it once the send completes
- Run the Stripe webhook through claim and settle so a duplicate delivery gets skipped

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 386989
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33918
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81115
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119160
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43872

---
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
