Skip to main content
Glama
agent-guard-mcp
by dygogogo

agent-guard-mcp

CI License: MIT Go Reference

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ツール

ツール

説明

check_budget

今日の予算状況を確認

spend

支出を実行(高リスクを自動検知)

request_approval

人間による承認を明示的にリクエスト

approve

保留中のトークンを承認

reject

保留中のトークンを拒否

check_approval

承認状況をポーリング

get_audit_log

フィルタリングとページネーション付きで監査ログを照会

get_pending_approvals

保留中の承認リクエストを一覧表示

クイックスタート

要件

  • 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

ビルド済みバイナリのダウンロード

お使いのプラットフォーム向けの最新リリースをダウンロードしてください:

または最新リリースページをご覧ください。

設定

環境変数または .env ファイルで設定します:

変数

説明

デフォルト

MCP_TRANSPORT

トランスポート: stdio / sse / http

自動検出 (TTY → http)

BUDGET_LIMIT

1日の予算上限 (クレジット)

10.0

HIGH_RISK_THRESHOLD

高リスクとみなす金額のしきい値

2.0

HIGH_RISK_RESOURCES

高リスクリソースのキーワード (カンマ区切り)

delete,send

DB_PATH

SQLiteデータベースのパス

./mcp-guard.db

DASHBOARD_PORT

ダッシュボードのHTTPポート

8080

APPROVAL_BASE_URL

承認リンクのベースURL

http://localhost:8080

LOG_LEVEL

ログレベル: debug/info/warn/error

info

PAYER_ID

支払者ID

ホスト名

TELEGRAM_BOT_TOKEN

Telegramボットトークン (オプション)

-

TELEGRAM_CHAT_ID

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/sse

Claude 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
└─────────────┘

コアファイル

ファイル

説明

main.go

エントリポイント、トランスポート選択、正常終了処理

server.go

8つのツールを登録したMCPサーバー

store.go

BudgetStoreインターフェース + SQLite実装

approval.go

高リスク検知、承認ワークフロー、Telegram連携

config.go

環境設定、トランスポートの自動検出

logger.go

zapロギング (stdioモード時はファイルのみ)

dashboard.go

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…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP 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 npm
      1
      MIT
    • A
      license
      B
      quality
      A
      maintenance
      Governance 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.
      68
      318
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      MartinLoop 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.
      24
      229 npm
      286
      Apache 2.0

    Appeared in Searches