Server data from the Official MCP Registry
Security, cost, and health governance proxy for MCP infrastructure
Security, cost, and health governance proxy for MCP infrastructure
MCP Guardian is a well-architected security proxy with comprehensive detection capabilities, proper authentication infrastructure, and reasonable permission scoping for its purpose. However, several code quality issues and one notable credential handling concern reduce confidence: hardcoded environment variable whitelisting without extensibility, incomplete response inspection logic in the provided code snippet, and lack of defensive input validation in JSON parsing. The project demonstrates strong security intent but requires refinement in implementation details before production deployment. Supply chain analysis found 7 known vulnerabilities in dependencies (0 critical, 2 high severity). Package verification found 1 issue.
4 files analyzed Β· 16 issues found
Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.
This plugin requests these system permissions. Most are normal for its category.
Set these up before or after installing:
Environment variable: MCP_GUARDIAN_DB_PATH
Environment variable: ALERT_WEBHOOK_URL
Environment variable: METRICS_ENABLED
Add this to your MCP configuration file:
{
"mcpServers": {
"io-github-rudraneel93-mcp-guardian": {
"env": {
"METRICS_ENABLED": "your-metrics-enabled-here",
"ALERT_WEBHOOK_URL": "your-alert-webhook-url-here",
"MCP_GUARDIAN_DB_PATH": "your-mcp-guardian-db-path-here"
},
"args": [
"-y",
"@mcp-guardian/server"
],
"command": "npx"
}
}
}From the project's GitHub README.
Runtime security, cost governance, and health monitoring proxy for MCP infrastructure.
MCP Guardian sits between AI agents and MCP servers, enforcing active security policies, tracking real token costs, monitoring server health, and providing enterprise observability β all through a YAML-configurable engine with hot-reload.
It works as a transparent proxy, a standalone CLI, an MCP server (so agents can self-audit), and a pnpm monorepo β install only what you need.
# Install globally
npm install -g @mcp-guardian/server
# Scan your MCP servers for CVEs, secrets, and injection attacks
mcp-guardian scan --all
# Proxy with active policy enforcement
mcp-guardian proxy --policy ./default-policy.yaml --blocking-mode block
# Generate a full security-cost-health report
mcp-guardian report --all --format markdown --output guardian-report.md
# Run as an MCP server (AI agents can self-audit)
mcp-guardian # stdio transport, auto-starts MCP server
.env files, docker-compose.yml, and environment variablesalg: none confusion attacks), audience/issuer validation, agent identity extractiontools/call traffic and counts tokens via tiktoken (o200k_base for OpenAI, char-ratio estimates for Anthropic/Google/DeepSeek/Meta/Mistral)/healthz and /readyz endpoints β Liveness and readiness probes for K8s deploymentpackages/core (detection engine), packages/cli, packages/server (MCP server), plus root src/ (proxy, scanners, services, policy, auth)IHistoryDb, ISecurityScanner, ICostAuditor, IHealthMonitor, IPolicyEngine for testability and swappable implementationsGUARDIAN_STRICT_MODE=true refuses startupgh-pages on tagged releasesnpm audit, CycloneDX SBOM generation, npm provenance attestation# Global CLI
npm install -g @mcp-guardian/server
# As an MCP server (for AI assistant integration)
npx @mcp-guardian/server
# From source (monorepo)
git clone https://github.com/rudraneel93/mcp-guardian.git
cd mcp-guardian
pnpm install
pnpm build
pnpm start
mcp-guardian scanmcp-guardian scan --all # Scan all discoverable MCP configs
mcp-guardian scan --config ./mcp.json # Scan a specific config
mcp-guardian scan --fail-on-critical # Exit 1 if any CRITICAL CVE found
mcp-guardian scan --fail-on-secrets # Exit 1 if any hardcoded secret found
mcp-guardian scan --threshold-score 60 # Exit 2 if any server scores below 60
Outputs per-server CVE list, auth status, typo-squat risk, secrets found, and composite security score (0β100).
mcp-guardian auditmcp-guardian audit --all # Audit costs for all servers
mcp-guardian audit --server github # Filter to a specific server
mcp-guardian audit --threshold-cost 0.01 # Exit 2 if total cost exceeds $0.01
Outputs per-server token usage, estimated cost (USD), and tool-level breakdown.
mcp-guardian healthmcp-guardian health --all # Health-check all servers
mcp-guardian health --fail-on-overload # Exit 1 if any server has tool overload
mcp-guardian health --threshold-latency 1000 # Exit 2 if latency exceeds 1000ms
Outputs per-server latency, success rate, tool count, and overload warnings.
mcp-guardian reportmcp-guardian report --all # Full security-cost-health report
mcp-guardian report --format markdown # Output as markdown
mcp-guardian report --format json # Output as JSON
mcp-guardian report --output guardian-report.md # Write to file
mcp-guardian report --threshold-score 75 # Exit 2 if overall score below 75
Generates a comprehensive report with overall score (weighted: security 40%, health 30%, cost efficiency 30%).
mcp-guardian proxymcp-guardian proxy --config ./mcp.json --policy ./default-policy.yaml --blocking-mode block
mcp-guardian proxy --policy ./policy.yaml --dry-run # Simulate without activating
mcp-guardian proxy --auth-issuer https://accounts.google.com --auth-audience my-app
mcp-guardian proxy --auth-required # Fail-closed auth
Starts the transparent proxy. Policy modes: audit (passive), warn (flag only), block (active enforcement). With --dry-run, evaluates policy against historical call records without activating the proxy.
Policies are YAML files evaluated against every tools/call in real time. The pipeline normalizes payloads (decoding hex/unicode/URL/HTML entity obfuscation), performs semantic shell analysis, then evaluates rules in order.
# default-policy.yaml
version: '1.0'
policy:
mode: block
default_action: block # fail-closed β blocks anything not explicitly allowed
rules:
- name: block-shell-injection
action: block
patterns:
- curl\s|wget\s
- rm\s+-rf
- ;\s*\w
- '&&|\|\|'
- \$\{
- '`[^`]+`'
- /etc/passwd|/etc/shadow
- name: deny-dangerous-tools
action: block
tools:
deny:
- execute_command
- bash
- sh
- eval
- exec
- system
- spawn
- fork
- popen
- source
- name: rate-limit-tool-calls
action: flag
maxCallsPerMinute: 120
- name: token-budget
action: flag
maxTokens: 50000
Hot-reload: Edit the YAML file β the policy engine swaps atomically without restarting the proxy.
RBAC example:
- name: admin-only-tool
action: block
tools:
deny: [dangerous_operation]
rbac:
scopes: [admin]
clientIds: [^trusted-agent-]
MCP Guardian runs as a first-class MCP server, exposing security tools to AI assistants:
{
"mcpServers": {
"guardian": {
"command": "npx",
"args": ["@mcp-guardian/server"]
}
}
}
Available tools:
scan_security β CVE, auth, typo-squat, and secret scanningaudit_costs β Token usage and cost estimationcheck_health β Latency, success rate, and tool countfull_report β Complete security-cost-health report (JSON/markdown/text)Available resources:
mcp-guardian://latest-scan β Most recent security scan resultsAvailable prompts:
audit-config β Generates audit instructions for an MCP config| Layer | What it catches |
|---|---|
| Payload normalization | Hex escaping, Unicode escapes, URL encoding, HTML entities, shell obfuscation |
| Regex triage | Cross-tool chaining, privilege escalation, exfiltration URLs, stealth directives, Unicode obfuscation (38 patterns, 8 categories) |
| Schema analysis | Injection in parameter defaults, suspicious parameter names, enum injection |
| Shell AST | Command substitution, pipe chains, redirects, logical chains, 33 dangerous commands, Unicode homoglyphs |
| LLM semantic | Context-aware verdict on tool descriptions β catches adversarial intent regex can't see |
| Secret patterns + entropy | 50+ named patterns + Shannon entropy for base64/hex secrets |
| Policy engine | Tool denylists, regex patterns, rate limits, token budgets, RBAC, default-deny |
| Response inspection | Prompt injection in tool RESPONSES, data exfiltration URLs, base64-encoded payloads |
helm repo add mcp-guardian https://rudraneel93.github.io/mcp-guardian
helm install guardian mcp-guardian/mcp-guardian \
--set persistence.enabled=true \
--set metrics.enabled=true \
--set secrets.mode=external \
--set secrets.existingSecret=mcp-guardian-secrets
The Helm chart includes:
/healthz, /readyz on port 9090)docker run -v $(pwd)/mcp.json:/etc/mcp-guardian/config.json \
-v $(pwd)/policy.yaml:/etc/mcp-guardian/policy.yaml \
ghcr.io/rudraneel93/mcp-guardian:latest \
proxy --config /etc/mcp-guardian/config.json --policy /etc/mcp-guardian/policy.yaml
| Variable | Default | Description |
|---|---|---|
MCP_GUARDIAN_DB_PATH | ~/.mcp-guardian/history.db | SQLite database path |
MCP_GUARDIAN_SECRET_ALLOWLIST | β | Comma-separated safe high-entropy strings |
MCP_GUARDIAN_MAX_PAYLOAD_BYTES | 10485760 (10 MB) | Max JSON-RPC payload size |
GUARDIAN_SECRET_PROVIDER | env | Secret backend: env, hashicorp-vault, aws-secrets-manager |
GUARDIAN_ALLOW_MODE_OVERRIDE | false | Allow CLI --blocking-mode to override policy file mode |
GUARDIAN_STRICT_MODE | false | Exit on Redis-not-configured in multi-replica/K8s |
METRICS_ENABLED | false | Expose Prometheus metrics |
METRICS_PORT | 9090 | Prometheus metrics port |
DASHBOARD_ENABLED | false | Enable web dashboard |
DASHBOARD_PORT | 4000 | Dashboard port |
DASHBOARD_METRICS_PUBLIC | false | Allow unauthenticated metrics access |
REDIS_URL | β | Redis connection for HA rate limiting and sessions |
ALERT_WEBHOOK_URL | β | Slack or Discord webhook for critical alerts |
ALERT_MIN_SEVERITY | warning | Minimum severity for webhook alerts |
ANTHROPIC_API_KEY | β | API key for LLM semantic analysis layer |
NVD_API_KEY | β | NIST NVD API key for CVE lookups |
MCP_PRICING_MODEL | gpt-4o | Default model for cost estimation |
ββββββββββββββββββββββββββββ
β MCP Guardian Proxy β
β ββββββββββββββββββββββ β
AI Client ββJSON-RPCββ Policy Engine ββββ Upstream MCP Server
β β (audit/warn/block) β β β
β ββββββββββ¬ββββββββββββ β β
β β β β
β ββββββββββΌββββββββββββ β β
β β HistoryDatabase β β β
β β (better-sqlite3 β β β
β β WAL + lockfile) β β β
β ββββββββββββββββββββββ β β
ββββββββββββββββββββββββββββ β
β
βββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββΌβββββββββββ ββββββββββββββββ ββββββββββββ
β Security Scanner β β Cost Auditor β β Health β
β β’ CVE (OSV+NVD) β β β’ tiktoken β β Monitor β
β β’ Auth probing β β β’ litellm β β β’ JSON- β
β β’ Typo-squat β β β’ per-model β β RPC β
β β’ Secret (50+ β β pricing β β probe β
β + entropy) β β β β β’ latencyβ
β β’ Command AST β ββββββββββββββββ ββββββββββββ
β β’ Response inspect β
ββββββββββββββββββββββ
tools/call JSON-RPC to proxy/metrics# Clone and install
git clone https://github.com/rudraneel93/mcp-guardian.git
cd mcp-guardian
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Type-check
pnpm typecheck
# Run specific test suites
cd packages/core && npx vitest run
cd packages/server && npx vitest run
cd packages/cli && npx vitest run
# Run corpus evaluation
pnpm eval
# Development mode (hot-reload)
pnpm dev
A WAF inspects HTTP traffic patterns; MCP Guardian operates at the MCP protocol layer β it understands tools/call semantics, tool names, argument schemas, and agent identities. It can block execute_command calls while allowing read_file, enforce per-tool rate limits, and validate JWT claims with algorithm pinning. It also scans MCP servers for CVEs, secrets, and typo-squatting β things a WAF cannot do.
Typically 5β25ms for policy evaluation (regex + schema + semantic shell analysis). JWT validation adds another 5β15ms. The total proxy overhead is under 50ms for most calls. If LLM semantic analysis is enabled, that adds 200β800ms per tool definition scan (not per call β it runs once during manifest verification, not on every intercepted request).
Yes. Set the policy mode to audit:
policy:
mode: audit
This logs every decision without blocking or flagging. Use it to understand what your agents are calling before enforcing rules. You can also run mcp-guardian proxy --policy ./policy.yaml --dry-run to simulate blocking against historical call records.
The proxy does not pass traffic through if the engine is unavailable β it returns a JSON-RPC error to the client. This is intentional fail-safe behavior. The policy engine is a synchronous, in-process evaluator (no network calls for regex/schema rules), so crashes are extremely unlikely. The LLM semantic layer gracefully degrades to an info-level "skipped" result if the API is unreachable.
Yes, with caveats. The proxy works single-instance or multi-replica, but rate limiting and session state require Redis (REDIS_URL) in multi-replica mode. Without Redis, rate limits are per-pod and session tokens from pod A are invalid on pod B. Set GUARDIAN_STRICT_MODE=true to refuse startup if Redis is missing in a multi-replica/K8s environment. For the audit database, use separate DB paths (MCP_GUARDIAN_DB_PATH) per instance, or migrate to PostgreSQL (planned for v2.4).
Only if you configure ANTHROPIC_API_KEY. The semantic scanner sends tool definitions (name + description + inputSchema) to Claude for security analysis β never the actual tool call arguments or response content. Tool definitions are metadata, not user data. You can disable the semantic layer entirely with --skip-semantic or by not setting the API key.
Add them to the MCP_GUARDIAN_SECRET_ALLOWLIST environment variable (comma-separated) to suppress false positives. For custom detection patterns, you can extend src/scanners/secret-scanner.ts and rebuild. The entropy threshold (4.5 bits per character) is also configurable in source.
Yes. The @mcp-guardian/core package exports the detection engine directly:
import { scanServer, fetchToolsFromStdio } from '@mcp-guardian/core';
const tools = await fetchToolsFromStdio({ command: 'npx', args: ['@my-mcp-server'] });
const result = await scanServer('my-server', tools, 'stdio');
// result.status: 'clean' | 'warning' | 'critical'
// result.tools: per-tool scan results with issues
The root package (@mcp-guardian/server) exports the full CLI, proxy, and MCP server.
The default-policy.yaml shipped with the package blocks shell injection patterns (curl, wget, rm -rf, command chaining, /etc/passwd), explicitly denies dangerous tools (execute_command, bash, sh, eval, exec, etc.), rate-limits at 120 calls/min, flags tokens over 50K, and applies default_action: block β meaning anything not explicitly allowed is blocked. You can override this with your own policy file.
The TypeScript codebase is platform-agnostic, but the stdio proxy spawns child processes and uses Unix signal handling. Windows support via WSL2 is fully functional. Native Windows cmd.exe / PowerShell is experimentally supported but not the primary target. The HTTP/SSE proxy transport works on any platform.
Set ALERT_WEBHOOK_URL to a Slack or Discord webhook URL, and optionally ALERT_MIN_SEVERITY (default: warning). The alerter fires on policy blocks, circuit breaker state changes, and cost threshold breaches. Messages include server name, rule triggered, and timestamp.
~/.mcp-guardian/history.db by default. Override with MCP_GUARDIAN_DB_PATH. The database uses SQLite with WAL mode, advisory file locking, and automatic purging of records older than 30 days. For tests, pass ':memory:' to use an in-memory database.
Use dry-run mode:
mcp-guardian proxy --policy ./new-policy.yaml --dry-run
This evaluates the policy against every call record in your history database and prints a per-server block/pass breakdown without activating the proxy. If the block rate is unexpectedly high or low, adjust rules before deploying.
The proxy validates JWT bearer tokens in the Authorization header of tools/call requests. However, AI clients like Cline and Claude Desktop don't natively generate OAuth tokens. You have three options:
env.AUTH_TOKEN in your MCP server config. The proxy passes it as a Bearer token to upstream servers and validates it if --auth-required is set.AUTH_TOKEN. Rotate it manually or via vault.RBAC scopes are defined in your policy YAML under rules[].rbac.scopes and mapped to JWT claims (the scope or scopes claim in the token). DPoP (RFC 9449) requires the client to sign a proof-of-possession JWT per request β this is functional in code but not yet supported by any mainstream AI client.
For OpenAI models (GPT-4o, o1, o3), counting uses tiktoken with o200k_base encoding β these are exact (Β±1%). For other providers:
| Provider | Method | Typical accuracy |
|---|---|---|
| Anthropic (Claude) | Char ratio (0.30) | Β±5β15% |
| Google (Gemini) | Char ratio (0.22) | Β±10β25% |
| DeepSeek | Char ratio (0.27) | Β±8β20% |
| Mistral | Char ratio (0.25) | Β±8β20% |
| Meta (Llama) | Char ratio (0.25) | Β±8β20% |
Results are flagged with isEstimate: true when char-ratio counting is used. Treat non-OpenAI cost figures as estimates, not accounting-grade numbers.
MCP Guardian uses logarithmic compound scoring: each additional CVE in the same severity tier adds diminishing penalty. 1 critical CVE = β30, 2 = β60, 5 = β100, 10 = β130, 100 = β230. This prevents a single vulnerable package from zeroing the entire score while still scaling penalty with volume. CVE recency and EPSS (Exploit Prediction Scoring System) integration is planned for v2.4.
mTLS requires:
opensslSet MCP_TLS_CA_PATH=/path/to/ca.pem and MCP_TLS_CLIENT_CERT_PATH=/path/to/client.crt, MCP_TLS_CLIENT_KEY_PATH=/path/to/client.key per server in your MCP config's env section. A mcp-guardian certs init helper command is planned for v2.4 to automate this.
The proxy fails closed β malformed YAML causes a startup error and the proxy refuses to start. It does not silently fall back to the last good policy or default to audit mode. Use --dry-run to validate new policies before deploying:
mcp-guardian proxy --policy ./new-policy.yaml --dry-run
See CONTRIBUTING.md for guidelines. The monorepo uses pnpm workspaces with turbo for build orchestration. Run pnpm install && pnpm build && pnpm test to verify your setup. All PRs must pass the 80% coverage threshold and the red-team corpus evaluation (F1 β₯ 85%).
MCP Guardian is production-grade for controlled environments (single-instance or Redis-backed multi-replica with GUARDIAN_STRICT_MODE). The database layer uses better-sqlite3 with WAL mode and advisory file locking β crash-safe and non-blocking. It handles the core use case β active policy enforcement with audit trails β reliably. For high-trust enterprise deployments, a third-party security audit is planned for v2.5. See SECURITY.md for details on our security posture.
MIT β see LICENSE.
Built with TypeScript, better-sqlite3, pino, prom-client, jose, shell-quote, tiktoken, commander, chalk, and lru-cache.
Be the first to review this server!
by Toleno Β· Developer Tools
Toleno Network MCP Server β Manage your Toleno mining account with Claude AI using natural language.
by mcp-marketplace Β· Developer Tools
Create, build, and publish Python MCP servers to PyPI β conversationally.
by Microsoft Β· Content & Media
Convert files (PDF, Word, Excel, images, audio) to Markdown for LLM consumption