# AgentGuard MCP server

> Provides runtime checks in Python to prevent runaway AI agents by monitoring budgets, tool call loops, retries, and elapsed time.

- Repository: https://github.com/bmdhodl/agent47
- Page: https://hostedmcp.org/servers/bmdhodl/agent47
- Transport: stdio
- Stars: 4
- License: MIT
- Latest version: 0.2.2

## Install

### Claude Code

```sh
claude mcp add --env 'AGENTGUARD_API_KEY=<YOUR_AGENTGUARD_API_KEY>' agent47 -- npx -y @agentguard47/mcp-server
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "agent47": {
      "command": "npx",
      "args": [
        "-y",
        "@agentguard47/mcp-server"
      ],
      "env": {
        "AGENTGUARD_API_KEY": "<YOUR_AGENTGUARD_API_KEY>"
      }
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "agent47": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@agentguard47/mcp-server"
      ],
      "env": {
        "AGENTGUARD_API_KEY": "<YOUR_AGENTGUARD_API_KEY>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"agent47","type":"stdio","command":"npx","args":["-y","@agentguard47/mcp-server"],"env":{"AGENTGUARD_API_KEY":"<YOUR_AGENTGUARD_API_KEY>"}}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "agent47": {
      "command": "npx",
      "args": [
        "-y",
        "@agentguard47/mcp-server"
      ],
      "env": {
        "AGENTGUARD_API_KEY": "<YOUR_AGENTGUARD_API_KEY>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add agent47 --env 'AGENTGUARD_API_KEY=<YOUR_AGENTGUARD_API_KEY>' -- npx -y @agentguard47/mcp-server
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.agent47]
command = "npx"
args = ["-y", "@agentguard47/mcp-server"]

[mcp_servers.agent47.env]
AGENTGUARD_API_KEY = "<YOUR_AGENTGUARD_API_KEY>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'AGENTGUARD_API_KEY=<YOUR_AGENTGUARD_API_KEY>' agent47 npx -- -y @agentguard47/mcp-server
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "agent47": {
      "command": "npx",
      "args": [
        "-y",
        "@agentguard47/mcp-server"
      ],
      "env": {
        "AGENTGUARD_API_KEY": "<YOUR_AGENTGUARD_API_KEY>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `AGENTGUARD_API_KEY` | yes | yes | AgentGuard read API key for querying traces, alerts, costs, usage, and savings. |
| `AGENTGUARD_URL` | no | no | Optional AgentGuard API base URL. Defaults to production. |

## FAQ

### Does AgentGuard require an account or network access to work?

No, the base SDK has no runtime dependencies and needs no account, allowing for offline checks.

### Can AgentGuard stop a local model like Ollama?

Yes, it can price patched calls at paid rates even for local models behind an OpenAI-compatible URL, allowing a dollar budget to stop a model that costs nothing.

### Does AgentGuard act as a sandbox for my code?

No, it is not a sandbox or permission system; a permitted operation can still be destructive.
