agent-guard-mcp

agent-guard-mcp

agent-guard-mcp

Category
访问服务器

README

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

Tool Description
check_budget Query today's budget status
spend Execute a spend (auto-detects high-risk)
request_approval Explicitly request human approval
approve Approve a pending token
reject Reject a pending token
check_approval Poll approval status
get_audit_log Query audit log with filtering and pagination
get_pending_approvals List 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:

Platform amd64 arm64
macOS darwin-amd64.zip darwin-arm64.zip
Linux linux-amd64.zip linux-arm64.zip
Windows windows-amd64.zip windows-arm64.zip

Or visit the latest release page.

Configuration

Configure via environment variables or .env file:

Variable Description Default
MCP_TRANSPORT Transport: stdio / sse / http Auto-detect (TTY → http)
BUDGET_LIMIT Daily budget cap (credits) 10.0
HIGH_RISK_THRESHOLD High-risk amount threshold 2.0
HIGH_RISK_RESOURCES High-risk resource keywords (comma-separated) delete,send
DB_PATH SQLite database path ./mcp-guard.db
DASHBOARD_PORT Dashboard HTTP port 8080
APPROVAL_BASE_URL Base URL for approval links http://localhost:8080
LOG_LEVEL Log level: debug/info/warn/error info
PAYER_ID Payer identity hostname
TELEGRAM_BOT_TOKEN Telegram Bot Token (optional) -
TELEGRAM_CHAT_ID Telegram 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

File Description
main.go Entry point, transport selection, graceful shutdown
server.go MCP Server with 8 registered tools
store.go BudgetStore interface + SQLite implementation
approval.go High-risk detection, approval workflow, Telegram
config.go Environment config, auto transport detection
logger.go zap logging (stdio mode: file only)
dashboard.go Gin 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


中文

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选