agent-guard-mcp
agent-guard-mcp
MCP Guard Server — AIエージェントのための予算管理、承認ワークフロー、および監査ログ機能を提供します。
Claude Code、Cursor、ChatGPT、その他MCPプロトコルに対応したあらゆるAIエージェントで動作します。
特徴
予算管理 — 1日のクレジット上限を設定し、エージェントの使いすぎを防止
高リスク操作の承認 — 設定金額を超える操作や、機密リソースのキーワードに一致する操作に対して人間による承認を要求
承認ワークフロー — エージェントからのリクエスト → トークン生成 → ダッシュボードまたはTelegram経由で人間が承認
監査ログ — すべての支出、承認、拒否アクションをカーソルベースのページネーション付きで記録
Webダッシュボード — Gin + HTMX + Tailwindによるリアルタイムダッシュボード
Telegram通知 — 高リスク操作に対する即時承認リンクの送信
マルチトランスポート — stdio / SSE / StreamableHTTPを自動検出
Related MCP server: llm-cost-guard
MCPツール
ツール | 説明 |
| 今日の予算状況を確認 |
| 支出を実行(高リスクを自動検知) |
| 人間による承認を明示的にリクエスト |
| 保留中のトークンを承認 |
| 保留中のトークンを拒否 |
| 承認状況をポーリング |
| フィルタリングとページネーション付きで監査ログを照会 |
| 保留中の承認リクエストを一覧表示 |
クイックスタート
要件
Go 1.24以上
CGO不要(純粋なGoのSQLiteドライバを使用)
ソースからビルド
git clone https://github.com/dygogogo/agent-guard-mcp.git
cd agent-guard-mcp
go build -o mcp-guard main.goビルド済みバイナリのダウンロード
お使いのプラットフォーム向けの最新リリースをダウンロードしてください:
プラットフォーム | amd64 | arm64 |
macOS | ||
Linux | ||
Windows |
または最新リリースページをご覧ください。
設定
環境変数または .env ファイルで設定します:
変数 | 説明 | デフォルト |
| トランスポート: stdio / sse / http | 自動検出 (TTY → http) |
| 1日の予算上限 (クレジット) | 10.0 |
| 高リスクとみなす金額のしきい値 | 2.0 |
| 高リスクリソースのキーワード (カンマ区切り) | delete,send |
| SQLiteデータベースのパス | ./mcp-guard.db |
| ダッシュボードのHTTPポート | 8080 |
| 承認リンクのベースURL | |
| ログレベル: debug/info/warn/error | info |
| 支払者ID | ホスト名 |
| Telegramボットトークン (オプション) | - |
| TelegramチャットID (オプション) | - |
実行
# 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/sseClaude Codeとの統合
Claude CodeのMCP設定に追加します:
{
"mcpServers": {
"agent-guard-mcp": {
"command": "mcp-guard",
"env": {
"MCP_TRANSPORT": "stdio",
"BUDGET_LIMIT": "10"
}
}
}
}アーキテクチャ
┌─────────────┐ MCP Protocol ┌────────────────┐
│ AI Agent │ ◄──────────────────► │ MCP Guard │
│ (Claude, │ stdio / HTTP │ Server │
│ Cursor...) │ │ │
└─────────────┘ │ ┌────────────┐ │
│ │ BudgetStore │ │
┌─────────────┐ HTTP │ │ (SQLite) │ │
│ Dashboard │ ◄──────────────────► │ └────────────┘ │
│ (Gin+HTMX) │ └────────────────┘
└─────────────┘
┌─────────────┐ Webhook
│ Telegram │ ◄────── Approval notifications
└─────────────┘コアファイル
ファイル | 説明 |
| エントリポイント、トランスポート選択、正常終了処理 |
| 8つのツールを登録したMCPサーバー |
| BudgetStoreインターフェース + SQLite実装 |
| 高リスク検知、承認ワークフロー、Telegram連携 |
| 環境設定、トランスポートの自動検出 |
| zapロギング (stdioモード時はファイルのみ) |
| Gin Webダッシュボード |
承認ワークフロー
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)テスト
# All tests with race detection
go test -race -count=1 ./...
# Integration tests only
go test -race -run TestIntegration -v ./...
# Coverage
go test -race -cover ./...技術スタック
Go 1.24 — 言語
mcp-go — MCPプロトコル Go SDK
Gin — Webフレームワーク (ダッシュボード)
modernc.org/sqlite — 純粋なGoのSQLite (CGOなし)
zap — 構造化ロギング
HTMX + Tailwind CSS — ダッシュボードフロントエンド
ライセンス
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
AgentGuard — 20-tool AI safety MCP: policy preflight, risk scoring, audit logging, rate limits.
Zero-secret MCP gateway for AI agents: risk-scored, audited calls with human-in-the-loop approval.
Agent Cost Allocator MCP — multi-tenant LLM cost attribution for chargeback billing. Companion to
MCP gateway: one connection for your AI apps, with tool policies, PII redaction and audit logs.
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.72 npm1MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for tracking LLM costs, setting spending limits, and receiving budget alerts directly within AI editors via slash commands like /guard.7 npm1MIT
- AlicenseBqualityAmaintenanceGovernance runtime for AI agents: a guard tool evaluates risky actions against policy before they execute (block / warn / require human approval), approvals route to a human queue, and every action becomes a replayable decision record with per-action spend tracking. Runs over stdio via npx @dashclaw/mcp-server; works with Claude Code, Codex, LangChain, CrewAI, or any MCP host.68318MIT
- AlicenseAqualityBmaintenanceMartinLoop is the independent governance and financial control layer for AI coding agents. Set hard spend limits, prevent runaway loops, enforce verification, trigger rollback on failure, and generate auditable receipts showing what changed, what it cost, and whether the work passed.24229 npm286Apache 2.0