MCP Hub
Back to servers

agent-guard-mcp

agent-guard-mcp

glama
Updated
Apr 10, 2026

agent-guard-mcp

CI License: MIT Go Reference

MCP Guard Server — Budget control, approval workflows, and audit logging for AI agents.

Works with Claude Code, Cursor, ChatGPT, and any AI agent that speaks the MCP protocol.

Features

  • Budget Control — Daily credits hard limit prevents agent overspending
  • High-Risk Approval — Operations exceeding amount threshold or matching sensitive resource keywords trigger human approval
  • Approval Workflow — Agent requests → token generated → human approves via Dashboard or Telegram
  • Audit Log — All spend, approval, and rejection actions recorded with cursor-based pagination
  • Web Dashboard — Gin + HTMX + Tailwind real-time dashboard
  • Telegram Notifications — Instant approval links for high-risk operations
  • Multi-Transport — stdio / SSE / StreamableHTTP with automatic detection

MCP Tools

ToolDescription
check_budgetQuery today's budget status
spendExecute a spend (auto-detects high-risk)
request_approvalExplicitly request human approval
approveApprove a pending token
rejectReject a pending token
check_approvalPoll approval status
get_audit_logQuery audit log with filtering and pagination
get_pending_approvalsList all pending approval requests

Quick Start

Requirements

  • Go 1.24+
  • No CGO required (pure Go SQLite driver)

Build from Source

git clone https://github.com/dygogogo/agent-guard-mcp.git
cd agent-guard-mcp
go build -o mcp-guard main.go

Download Pre-built Binary

Download the latest release for your platform:

Platformamd64arm64
macOSdarwin-amd64.zipdarwin-arm64.zip
Linuxlinux-amd64.ziplinux-arm64.zip
Windowswindows-amd64.zipwindows-arm64.zip

Or visit the latest release page.

Configuration

Configure via environment variables or .env file:

VariableDescriptionDefault
MCP_TRANSPORTTransport: stdio / sse / httpAuto-detect (TTY → http)
BUDGET_LIMITDaily budget cap (credits)10.0
HIGH_RISK_THRESHOLDHigh-risk amount threshold2.0
HIGH_RISK_RESOURCESHigh-risk resource keywords (comma-separated)delete,send
DB_PATHSQLite database path./mcp-guard.db
DASHBOARD_PORTDashboard HTTP port8080
APPROVAL_BASE_URLBase URL for approval linkshttp://localhost:8080
LOG_LEVELLog level: debug/info/warn/errorinfo
PAYER_IDPayer identityhostname
TELEGRAM_BOT_TOKENTelegram Bot Token (optional)-
TELEGRAM_CHAT_IDTelegram Chat ID (optional)-

Running

# HTTP mode (auto-detected, with Dashboard)
./mcp-guard
# Dashboard: http://localhost:8080/dashboard
# MCP endpoint: http://localhost:8080/mcp

# stdio mode (for MCP clients)
MCP_TRANSPORT=stdio ./mcp-guard

# SSE mode
MCP_TRANSPORT=sse ./mcp-guard
# SSE endpoint: http://localhost:8080/sse

Claude Code Integration

Add to Claude Code's MCP configuration:

{
  "mcpServers": {
    "agent-guard-mcp": {
      "command": "mcp-guard",
      "env": {
        "MCP_TRANSPORT": "stdio",
        "BUDGET_LIMIT": "10"
      }
    }
  }
}

Architecture

┌─────────────┐     MCP Protocol     ┌────────────────┐
│  AI Agent   │ ◄──────────────────► │  MCP Guard      │
│ (Claude,    │   stdio / HTTP       │  Server         │
│  Cursor...) │                      │                  │
└─────────────┘                      │  ┌────────────┐ │
                                     │  │  BudgetStore │ │
┌─────────────┐    HTTP              │  │  (SQLite)    │ │
│  Dashboard  │ ◄──────────────────► │  └────────────┘ │
│  (Gin+HTMX) │                      └────────────────┘
└─────────────┘

┌─────────────┐    Webhook
│  Telegram   │ ◄────── Approval notifications
└─────────────┘

Core Files

FileDescription
main.goEntry point, transport selection, graceful shutdown
server.goMCP Server with 8 registered tools
store.goBudgetStore interface + SQLite implementation
approval.goHigh-risk detection, approval workflow, Telegram
config.goEnvironment config, auto transport detection
logger.gozap logging (stdio mode: file only)
dashboard.goGin Web Dashboard

Approval Workflow

1. Agent calls spend(amount=5.0, resource="/api/delete")
2. MCP Guard detects high-risk (amount > threshold OR resource keyword matched)
3. Returns {status: "pending_approval", token: "xxx"}
4. Agent polls check_approval(token) for status
5. Human approves/rejects via Dashboard or Telegram
6. Agent receives final result (approved/rejected/budget_exceeded)

Testing

# All tests with race detection
go test -race -count=1 ./...

# Integration tests only
go test -race -run TestIntegration -v ./...

# Coverage
go test -race -cover ./...

Tech Stack

  • Go 1.24 — Language
  • mcp-go — MCP protocol Go SDK
  • Gin — Web framework (Dashboard)
  • modernc.org/sqlite — Pure Go SQLite (no CGO)
  • zap — Structured logging
  • HTMX + Tailwind CSS — Dashboard frontend

License

MIT


中文

Reviews

No reviews yet

Sign in to write a review