agent-safety-mcp
Supports exporting agent decision logs and session summaries as Markdown files for human-readable documentation and reporting.
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-mcpManual (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 serverRelated MCP server: mcp-doorman
Tools
Cost Guard — Budget enforcement for LLM calls
Tool | What it does |
| Set weekly budget, alert threshold, dry-run mode |
| Check current spend vs budget |
| Pre-check if a model call is within budget |
| Record a completed call's token usage |
| 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 |
| Scan text for injection patterns (non-blocking) |
| Scan + block if injection detected |
| 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 |
| Start a new trace session |
| Log a decision step with context |
| Get session summary (steps, errors, timing) |
| 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:
ai-cost-guard —
pip install ai-cost-guardai-injection-guard —
pip install ai-injection-guardai-decision-tracer —
pip install ai-decision-tracer
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
Available Tools
17 toolscost_guard_checkA
Pre-check if a model call is within budget. Returns safe/blocked status.
Args: model: Model identifier (e.g. "anthropic/claude-haiku-4-5-20251001", "openai/gpt-4o"). estimated_input_tokens: Expected input token count. estimated_output_tokens: Expected output token count.
Inputs: model (required), estimated_input_tokens, estimated_output_tokens.
cost_guard_configureA
Configure the cost guard budget.
Args: weekly_budget_usd: Maximum spend per week in USD. alert_at_pct: Warn when spend reaches this percentage (0.0-1.0). dry_run: If true, all calls raise BudgetExceededError (safe for testing).
Inputs: weekly_budget_usd, alert_at_pct, dry_run.
cost_guard_modelsA
List all supported models with their per-token pricing.
Inputs: no named parameters.
cost_guard_recordA
Record a completed LLM call's token usage and cost.
Args: model: Model identifier used for the call. input_tokens: Actual input tokens consumed. output_tokens: Actual output tokens consumed. purpose: Optional label for this call (e.g. "summarizer", "classifier").
Inputs: model (required), input_tokens (required), output_tokens (required), purpose.
cost_guard_statusA
Check current budget spend — how much is left, percentage used, call details.
Inputs: no named parameters.
injection_checkB
Scan text and block if injection is detected above threshold.
Args: text: The text to check for injection attempts. threshold: Block at this severity or above — "LOW", "MEDIUM", "HIGH", "CRITICAL".
Inputs: text (required), threshold.
injection_patternsA
List all built-in injection detection patterns with categories and weights.
Inputs: no named parameters. Returns: result
injection_scanA
Scan text for prompt injection patterns. Returns risk assessment without blocking.
Args: text: The text to scan for injection attempts. threshold: Sensitivity level — "LOW", "MEDIUM", "HIGH", or "CRITICAL".
Inputs: text (required), threshold.
kya_create_cardB
Create a KYA (Know Your Agent) identity card for an agent.
Args: agent_id: Unique ID in format "org/agent-name" (e.g. "luciferforge/research-bot"). name: Human-readable agent name. purpose: What this agent does (min 10 chars for validity). capabilities: Comma-separated list of capabilities (e.g. "text_generation,web_search"). owner_name: Owner/organization name. version: Agent version string.
Inputs: agent_id (required), name, purpose, capabilities, +2 more.
kya_generate_keypairA
Generate an Ed25519 keypair for signing agent identity cards.
Args: name: Key name (default "mcp-session"). Keys stored at ~/.kya/keys/
Inputs: name.
kya_sign_cardA
Sign an existing KYA card with the session's Ed25519 private key.
Args: agent_id: The agent_id of the card to sign. Must call kya_create_card first.
Inputs: agent_id (required).
kya_verify_cardA
Verify a KYA identity card — check structure, completeness, and signature.
Args: agent_id: Look up a card created in this session by agent_id. card_json: Or pass raw card JSON to verify an external card.
Inputs: agent_id, card_json.
safety_checkA
Run a unified safety check: injection scan + cost check + trace step.
This is the recommended single tool for pre-flight safety. It runs injection scanning, checks the cost budget, and logs the decision.
Args: text: The input text to scan for injections. model: Model identifier for cost checking (optional). estimated_input_tokens: Expected input tokens for cost check. estimated_output_tokens: Expected output tokens for cost check. step_name: Name for the trace step.
Inputs: text (required), model, estimated_input_tokens, estimated_output_tokens, +1 more.
trace_saveA
Save the current trace to disk as JSON and Markdown files.
Inputs: no named parameters.
trace_startA
Start a new trace session for an AI agent.
Args: agent: Agent name (used in filenames). trace_dir: Directory to save trace files. model: Optional model name to attach as metadata.
Inputs: agent, trace_dir, model.
trace_stepA
Log a decision step in the current trace session.
Args: name: Step name (e.g. "analyze_signal", "classify_intent"). decision: What the agent decided. confidence: Confidence score (0.0-1.0). input_data: What the agent saw (brief description). reason: Why this decision was made. outcome: "ok" or "error".
Inputs: name (required), decision, confidence, input_data, +2 more.
trace_summaryB
Get a summary of the current trace session — step count, errors, timing.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 17 tools
Most tools have distinct purposes with clear boundaries between cost management, injection detection, KYA identity, and tracing domains. However, injection_check and injection_scan have overlapping functionality (both scan text for injections), which could cause confusion despite different blocking behaviors. The other tools are well-differentiated within their respective domains.
Tool names follow highly consistent snake_case patterns with clear domain prefixes: cost_guard_*, injection_*, kya_*, trace_*, and safety_check. Each tool name clearly indicates its domain and function, with no mixing of conventions or inconsistent verb styles across the set.
17 tools is slightly high but reasonable for covering multiple safety domains (cost, injection, identity, tracing). The count feels comprehensive rather than excessive, though some consolidation might improve coherence. Each domain has an appropriate number of tools for its scope.
The tool set provides complete coverage for agent safety workflows: cost management (configure, check, record, status), injection detection (check, scan, patterns), KYA identity (create, sign, verify, key generation), and tracing (start, step, summary, save). The safety_check tool even provides unified coverage, and there are no obvious gaps in the safety lifecycle.
Maintenance
Related MCP Connectors
Scan prompts for injection attacks, redact PII, and audit LLM SDK usage from any MCP client
Zero-LLM guardrail MCP to detect prompt injections, redact/HMAC PII, and validate tool args.
Email safety MCP server. Detects phishing, prompt injection, CEO fraud for AI agents.
Real-time MCP & A2A prompt-injection, jailbreak, and tool-schema poisoning firewall for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server for AI agent security guardrails. Provides input validation, prompt injection detection, PII redaction, output filtering, policy enforcement, rate limiting, and comprehensive audit logging.111 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA drop-in proxy that guards MCP servers with policy enforcement, secret redaction, prompt-injection screening, rug-pull detection, rate limiting, and audit logging.4 npmApache 2.0
- AlicenseCqualityDmaintenanceSecurity scanner and MCP server that catches dangerous patterns in MCP servers and AI agent projects, such as leaked secrets, shell execution, and prompt-injection text. Runs as both a CLI and MCP server with CI-friendly severity gates.21MIT
- AlicenseAqualityDmaintenanceA deterministic MCP server that guards AI/agent output by detecting secrets, injection, and PII in ~85µs with zero dependencies. Gives a clear ship/block verdict and runs locally or hosted.2Apache 2.0