envguard-mcp
# `envguard-mcp` — 3-Runtime `.env` Parser, Client-Bundle Secret Leak & 4-Way Drift MCP Server + GitHub Action
[](https://glama.ai/mcp/servers/z121245017-ai/envguard-mcp)
Zero-dependency, 100% offline **Model Context Protocol (`MCP`) Server**, **CLI**, and **GitHub Action** enabling AI coding agents (Claude Desktop, Claude Code, Cursor, Windsurf, Antigravity) and pull-request CI pipelines to catch:
1. **3-Runtime `.env` Parser Divergences** across Node `dotenv` v16, `docker run --env-file`, and POSIX `sh` / `docker compose` (inline `#` password truncation, literal `"..."` quotes in Docker, `$2b$12$` bcrypt corruption, `export ` rejections, and Windows `CRLF` `\r` trailing bytes).
2. **Frontend Bundle Secret Leaks** where private keys, database URIs, live API secrets, or Supabase `service_role` JWTs are accidentally exposed under `NEXT_PUBLIC_`, `VITE_`, `NUXT_PUBLIC_`, `REACT_APP_`, `EXPO_PUBLIC_`, or `PUBLIC_`.
3. **4-Way Configuration Drift** across `.env`, `.env.example`, `docker-compose.yml`, and polyglot source code (`process.env`, `import.meta.env`, `Deno.env`, `Bun.env`, `os.environ`, `os.Getenv`, `std::env::var`).
> **Zero-Secret-Leak Guarantee**: Every MCP tool and CI report strictly redacts raw values into `<redacted len:N bytes:B fnv1a:HHHHHHHH>` fingerprints so production secrets never enter LLM context windows or CI logs.
## MCP Tools Exposed (`stdio`)
| Tool | Purpose | Safety Annotations |
| :--- | :--- | :--- |
| `compare_env_runtime_parsers` | Compares exact parsed byte lengths and FNV-1a hashes across Node `dotenv` v16, `docker run --env-file`, and POSIX `sh` / `docker compose` without exposing raw secret plaintext. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
| `detect_client_bundle_secret_leaks` | Audits `.env*` files and source code for private keys, `service_role` JWTs, or DB credentials accidentally prefixed with `NEXT_PUBLIC_`, `VITE_`, `NUXT_PUBLIC_`, `REACT_APP_`, or `EXPO_PUBLIC_`. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
| `audit_env_compose_code_drift` | Computes 4-way cross-drift across `.env`, `.env.example`, `docker-compose.yml`, and source code references, returning redacted findings and a `0–100` deployment safety score. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
| `generate_sanitized_env_example` | Produces a zero-secret `.env.example` (automatically renaming leaked client-prefix server keys) and an escaped fail-fast `docker-compose.yml` snippet. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
## Quick Start (MCP Client & Local CLI)
```bash
# Start MCP server over stdio (supports both NDJSON and Content-Length framing)
npx -y github:z121245017-ai/envguard-mcp
# List MCP tool schemas
npx -y github:z121245017-ai/envguard-mcp --list
# Compare 3-runtime .env parser behavior from terminal (raw secrets redacted)
npx -y github:z121245017-ai/envguard-mcp --cli compare_env_runtime_parsers '{"envText":"DB_PASS=p@ss#word123\nREDIS_PASS=\"secret\""}'
```
### Claude Desktop / Cursor / Windsurf / Antigravity Config
```json
{
"mcpServers": {
"envguard": {
"command": "npx",
"args": ["-y", "github:z121245017-ai/envguard-mcp"]
}
}
}
```
### Docker (`node:22-alpine`, non-root `USER node`)
```bash
docker build -t envguard-mcp .
docker run -i --rm envguard-mcp
```
## GitHub Action (`z121245017-ai/envguard-mcp@v1`)
Add `envguard-mcp@v1` to `.github/workflows/` to block pull requests that introduce `NEXT_PUBLIC_` / `VITE_` secret leaks or forget to document new `process.env` / `import.meta.env` keys in `.env.example`:
```yaml
name: EnvGuard Secret Leak & Drift Check
on:
pull_request:
permissions:
contents: read
jobs:
envguard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Audit client-bundle secret leaks and .env.example drift
uses: z121245017-ai/envguard-mcp@v1
with:
env-example: '.env.example'
code-paths: 'src,app'
fail-on-client-leaks: 'true'
fail-on-example-drift: 'true'
```
### Action Inputs & Outputs
| Name | Kind | Default | Description |
| :--- | :--- | :--- | :--- |
| `workspace` | Input | `.` | Workspace directory to scan. |
| `env-file` | Input | `""` | Optional `.env` or template file checked for 3-runtime parser divergence and client-bundle leaks. |
| `env-example` | Input | `.env.example` | Path to `.env.example` used for undocumented variable drift checks. |
| `compose-file` | Input | `""` | Optional path to `docker-compose.yml` / `compose.yaml` (auto-detected when omitted). |
| `code-paths` | Input | `.` | Comma-separated source directories or files scanned for environment variable references. |
| `fail-on-client-leaks` | Input | `true` | Exit `1` when server secrets or `service_role` JWTs are exposed under `NEXT_PUBLIC_` / `VITE_` / etc. |
| `fail-on-example-drift` | Input | `true` | Exit `1` when variables referenced in source code or Compose are missing from `.env.example`. |
| `fail-on-parser-divergence` | Input | `true` | Exit `1` when an inspected `.env` file diverges across `dotenv`, `docker --env-file`, and POSIX `sh`. |
| `verdict` | Output | — | `PASSED` or `BLOCKED`. |
| `safety-score` | Output | — | Deterministic safety score (`0–100`). |
| `client-leaks-found` | Output | — | Count of client-bundle secret exposure findings. |
| `example-drift-found` | Output | — | Count of undocumented variables missing from `.env.example`. |
| `parser-divergences-found` | Output | — | Count of 3-runtime `.env` parser divergences. |
| `report-json` | Output | — | Redacted JSON summary (raw secret values are never included). |
## Verification
```bash
npm test
```
## License
MIT License — `0` external npm dependencies, `0` network calls, `100%` local execution.
TDQS
Scored across 4 tools
Each tool targets a distinct env-security workflow: parser comparison, leak detection, config drift auditing, and sanitized template generation. The first and third tools both analyze env/compose configuration, so an agent may need to read descriptions carefully to choose between them, but their outputs and purposes differ.
All four names use snake_case and are verb-led or action-oriented, with clear domain-specific nouns. The pattern is consistent, though names are unusually long and the first tool is slightly more noun-heavy than the others.
Four tools is a tight, well-scoped set for an env-security auditing server. Each tool maps to a distinct step in the workflow, with no filler or redundant tools.
The surface covers comparison, leak detection, drift auditing, and safe example generation, which form a coherent lifecycle. It lacks a direct remediation or fix-application tool, but generation of sanitized examples partially fills that gap.