Skip to main content
Glama
agent-safety-mcp

agent-safety-mcp

by LuciferForge

agent-safety-mcp

PyPI version License: MIT Python 3.10+

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

Related MCP server: mcp-doorman

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

Available Tools

17 tools
cost_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

    A3.9/5.0

    Scored across 17 tools

    Disambiguation4/5

    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.

    Naming Consistency5/5

    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.

    Tool Count4/5

    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.

    Completeness5/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP 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 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A drop-in proxy that guards MCP servers with policy enforcement, secret redaction, prompt-injection screening, rug-pull detection, rate limiting, and audit logging.
      4 npm
      Apache 2.0
    • A
      license
      C
      quality
      D
      maintenance
      Security 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.
      2
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A 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.
      2
      Apache 2.0