Skip to main content
Glama
AgentGuard

AgentGuard

by prachics

AgentGuard

A gateway between an AI agent and its MCP tools. The agent connects to AgentGuard as if it were one MCP server; AgentGuard connects to the real ones and checks every tool call against a policy first.

An agent told by a web page to email the customer list outside: open, it does; guarded, AgentGuard refuses the export and the email

flowchart LR
    A[AI agent<br/>MCP client] -->|tools/call| G
    subgraph G[AgentGuard]
        P[Policy<br/>rule, role, arg schema] --> AP{Approval?}
        AP -->|no, or approved| R[Rate limit]
    end
    R --> U[(Upstream MCP servers)]
    AP -->|held| DB[(Postgres<br/>approvals, audit log)]
    H[Approver] -->|admin API| DB
    G -.->|each decision| DB

What it does

  • Per-tool policy: a tool with no rule is neither listed nor callable.

  • Roles: a rule can limit a tool to named roles. Listings show a caller only what its role may use.

  • Argument constraints: arguments are validated against a JSON Schema (Ajv, strict mode) before anything is forwarded.

  • Rate limits: a token bucket per tool and caller.

  • Human approval for writes: a call waits in Postgres until a named approver approves or denies it on the admin API.

  • Append-only audit log: every decision, allowed or refused, is written to Postgres. A refusal whose audit write fails is still refused.

  • Prompt-injection suite: a harness that replays injected tool output against open and guarded runs. See docs/INJECTION.md.

Related MCP server: evav-gateway

Policy

servers:
  files: {command: npx, args: [tsx, examples/files-server.ts]}
tools:
  files__read_file: {allow: true, kind: read}
  files__write_file:
    allow: true
    kind: write
    roles: [writer]
    approval: true
    args:
      properties:
        path: {type: string, pattern: "^notes/[\\w.-]+$"}
        text: {type: string, maxLength: 10000}
      required: [path, text]
      additionalProperties: false
    rate: {per_minute: 10, burst: 3}
  files__delete_file: {allow: false, kind: write}

Run it

Needs Node.js 22+.

npm install
npx tsx src/cli.ts --config examples/agentguard.yaml              # stdio
npx tsx src/cli.ts --config examples/agentguard.yaml --http 3333  # Streamable HTTP

For approvals and the audit log, start Postgres and the admin API:

docker compose up -d
export AGENTGUARD_DATABASE_URL='postgresql://agentguard:agentguard_dev_password@127.0.0.1:5435/agentguard'
export AGENTGUARD_ADMIN_KEYS='<16+ character secret>:alice:approver'
npx tsx src/cli.ts --config examples/agentguard.yaml --admin 3334

Routes: GET /admin/approvals, POST /admin/approvals/ID/approve|deny, GET /admin/audit.

Worked example

examples/incidentiq puts IncidentIQ's tools behind AgentGuard.

Layout

Path

What is there

src/

The gateway: gateway.ts (call flow), policy.ts (rules), admin.ts (approval and audit API), store.ts (Postgres)

examples/

A sample policy, a sample upstream server, and IncidentIQ's tools

injection/

Prompt-injection harness and recorded runs

test/

Vitest suites

Tests

docker compose up -d   # approval and audit tests use Postgres
npm test
npm run typecheck

CI runs typecheck, the tests against Postgres, and the build. Full configuration reference: docs/GUIDE.md.

Stack

TypeScript, Node.js, MCP SDK, PostgreSQL, Ajv, Vitest · MIT licensed

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      A secure MCP gateway for enterprise AI tool execution, enabling governed invocation of business tools with authentication, RBAC, audit logging, PII redaction, and async processing.
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Governed MCP gateway that lets AI agents call tools with policy enforcement, prompt-injection screening, a kill-switch, and tamper-evident signed audit logs.
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Acts as an MCP gateway between AI agents and upstream tool servers, evaluating YAML policies on every tool call, injecting real credentials at the last mile, scanning requests and responses for secrets, PII, and prompt injection, and recording each action in a tamper-evident audit log. Also supports HTTP forward-proxy governance with rate limiting, cost tracking, and policy replay against historical audit data.
      4
      Apache 2.0