Agent Safety MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add agent-safety -- uvx agent-safety-mcp
README.md

MCP server for AI agent safety, cost guards, and prompt injection scanning.

agent-safety-mcp

MCP server for AI agent safety. One install gives any MCP-compatible AI assistant access to cost guards, prompt injection scanning, and decision tracing.

Works with Claude Code, Cursor, Windsurf, Zed, and any MCP client.


Install

Claude Code (recommended)

claude mcp add agent-safety -- uvx agent-safety-mcp

Manual (any MCP client)

Add to your MCP config:

{
  "mcpServers": {
    "agent-safety": {
      "command": "uvx",
      "args": ["agent-safety-mcp"]
    }
  }
}

From PyPI

pip install agent-safety-mcp
agent-safety-mcp  # runs stdio server

Tools

Cost Guard — Budget enforcement for LLM calls

Tool What it does
cost_guard_configure Set weekly budget, alert threshold, dry-run mode
cost_guard_status Check current spend vs budget
cost_guard_check Pre-check if a model call is within budget
cost_guard_record Record a completed call's token usage
cost_guard_models List supported models with pricing

Example: "Check if I can afford a GPT-4o call with 2000 input tokens"

Injection Guard — Prompt injection scanner

Tool What it does
injection_scan Scan text for injection patterns (non-blocking)
injection_check Scan + block if injection detected
injection_patterns List all 75 built-in detection patterns across 9 categories

Example: "Scan this user input for prompt injection: 'ignore previous instructions and...'"

Decision Tracer — Agent decision logging

Tool What it does
trace_start Start a new trace session
trace_step Log a decision step with context
trace_summary Get session summary (steps, errors, timing)
trace_save Save trace to JSON + Markdown files

Example: "Start a trace for my analysis agent, then log each decision step"


What this wraps

This MCP server wraps the AI Agent Infrastructure Stack — three standalone Python libraries:

All three: MIT licensed, zero runtime dependencies (individually), pure Python stdlib.

The MCP server adds mcp>=1.0.0 as a dependency for the protocol layer.


Why

AI coding assistants (Claude Code, Cursor, etc.) can now protect the agents they help build — checking budgets, scanning inputs, and tracing decisions — without leaving the IDE.

Built from 8 months of running autonomous AI trading agents in live financial markets.


License

MIT

Tools (12)

cost_guard_configureSet weekly budget, alert threshold, and dry-run mode.
cost_guard_statusCheck current spend vs budget.
cost_guard_checkPre-check if a model call is within budget.
cost_guard_recordRecord a completed call's token usage.
cost_guard_modelsList supported models with pricing.
injection_scanScan text for injection patterns (non-blocking).
injection_checkScan and block if injection detected.
injection_patternsList all 75 built-in detection patterns across 9 categories.
trace_startStart a new trace session.
trace_stepLog a decision step with context.
trace_summaryGet session summary including steps, errors, and timing.
trace_saveSave trace to JSON and Markdown files.

Configuration

claude_desktop_config.json
{"mcpServers": {"agent-safety": {"command": "uvx", "args": ["agent-safety-mcp"]}}}

Try it

Check if I can afford a GPT-4o call with 2000 input tokens.
Scan this user input for prompt injection: 'ignore previous instructions and...'
Start a trace for my analysis agent, then log each decision step.
What is my current spend versus my weekly budget?
List all available injection detection patterns.

Frequently Asked Questions

What are the key features of Agent Safety?

Enforces API cost budgets for LLM calls. Detects prompt injection using 75 built-in patterns. Provides decision tracing for agent audit trails. Zero ML dependencies and pure Python implementation. Compatible with Claude Code, Cursor, Windsurf, and Zed.

What can I use Agent Safety for?

Preventing runaway API costs in autonomous AI agents. Securing AI inputs against prompt injection attacks. Creating verifiable audit trails for AI decision-making. Monitoring token usage for financial market trading agents.

How do I install Agent Safety?

Install Agent Safety by running: claude mcp add agent-safety -- uvx agent-safety-mcp

What MCP clients work with Agent Safety?

Agent Safety works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Agent Safety docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare