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を自動検出
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
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/dygogogo/agent-guard-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server