envdoctor-mcp
Parses and validates .env files (.env, .env.*, templates) in a project: compares .env against .env.example for missing/extra/empty variables, checks dotenv expansion semantics (${VAR}, ${VAR:-default}), flags syntax problems, duplicates, BOM/CRLF, quoting and placeholder mistakes, and proposes a safe .env.example — reporting only variable names, line numbers, lengths and type guesses, never values.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@envdoctor-mcp Compare my .env with .env.example and tell me what's missing."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
envdoctor-mcp
An MCP server that diagnoses environment-variable problems in a project, read-only, and without ever showing a value.
Your agent gets variable names, line numbers, lengths and type guesses, which is everything it needs to fix a broken
.env, and nothing it could leak.
How it differs from other .env MCP servers. Existing ones, such as
env-check-mcp, compare .env against .env.example and redact the
report. envdoctor-mcp also reads your source code (JavaScript/TypeScript, Python, Ruby, Rust, Go, Java/Kotlin/Scala, C#, PHP, Elixir, Prisma, compose files) to find variables that are used but
undocumented, or documented but dead. It validates shapes (URL, port, bool, DSN, JWT, path-exists, placeholders,
whitespace, CRLF, BOM, quoting mistakes). It warns when a secret would ship to the browser (VITE_, NEXT_PUBLIC_, ...).
It checks git ignore state and history by file name. It proposes a safe .env.example. It handles monorepos with several
env roots. It has zero dependencies beyond mcp: the dotenv parser is hand-written and cross-checked against
python-dotenv in the tests.
Install
Needs uv. Replace the path with the project you want inspected; the server can read nothing outside it.
Claude Code
claude mcp add envdoctor -- uvx envdoctor-mcp --dir .Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"envdoctor": {
"command": "uvx",
"args": ["envdoctor-mcp", "--dir", "C:\\Users\\you\\projects\\myapp"]
}
}
}Related MCP server: envdoc
Tools
Tool | What it answers |
| Which env files exist ( |
|
|
| Scans source for env reads and cross-checks the templates: used-but-undocumented with |
| Placeholders, empty values, trailing whitespace, unquoted spaces, CRLF, BOM, literal quotes, undefined |
| For each real env file: ignored? tracked? in any commit on any branch? Plus env files committed once and deleted (still in history). Names and hashes only. |
| A |
All tools take path (a folder inside the sandbox, default the whole sandbox).
Source scanning understands process.env.X, process.env["X"], const { X } = process.env, import.meta.env.X,
Deno.env.get, os.environ[...], os.environ.get, os.getenv, ENV['X'], ENV.fetch, std::env::var, env!,
os.Getenv, os.LookupEnv, System.getenv, Environment.GetEnvironmentVariable, getenv, $_ENV, Laravel env(),
System.get_env, Prisma env(), and ${X} in compose files.
Try asking
"Run env_overview on this repo and tell me which env files are missing a template."
"Why does my app crash on startup? Compare my .env with .env.example."
"Which environment variables does the code read that nobody documented?"
"Validate my .env files. Anything that looks unfinished or malformed?"
"Is my .env safe from git? Did I ever commit one?"
"Write me a .env.example for the api package."
"Could any of my secrets end up in the browser bundle?"
Security
Values are never output. Every report is built from names, line numbers, counts, lengths and type words. The parser keeps values in memory only so shapes can be checked; no formatting code touches them. Syntax-error messages are fixed phrases with a line number. A line holding a single bare word is reported by line number only (it could be a secret pasted on its own).
A trip-wire backs that up. If any output ever contained the value of a secret-looking variable, the tool refuses to return it and says so.
Read-only. Nothing is written, deleted or executed. The only subprocess is
git(rev-parse,check-ignore,ls-files,logby file name).Sandboxed.
--diris the only place the server reads. Paths that resolve outside it (including through symlinks) are refused; symlinks pointing out of the sandbox are skipped and reported.The tests plant fake secrets in hostile files (garbage lines, unterminated quotes, template secrets, commented-out values) and assert that none appears in any tool output, any error, or the stdio transcript.
Limits
Source scanning is a text scan: matches inside comments count and dynamic names (
process.env[name]) are invisible. "Documented but unused" can be wrong for variables read by frameworks, shell scripts or Dockerfiles.The compose and CI readers are line-based, not full YAML.
Expansion follows python-dotenv:
${VAR},${VAR:-d}and${VAR-d}are resolved against earlier variables of the same file, never against your real environment, and:-and-both mean "when unset".*_PATH/*_DIR/*_FILEexistence is only checked in.env,.env.local, development and test files.
Development
uv sync --extra test
uv run pytest
uv run ruff check src tests && uv run mypy --strict srcA from-scratch tutorial that builds a minimal version of this server lives in envdoctor-mcp-the-hard-way.
MIT licensed.
Available Tools
6 toolscheck_gitignoreA
Is each real env file safe from git? For every .env/.env.* file (templates excluded) says
whether it is ignored, tracked, or present in any commit on any branch, and lists env files
that were committed once and deleted (still in history). Uses git check-ignore,
git ls-files and git log --all by file name only: no content is read, no history is
rewritten. Also flags a template that is itself ignored. Requires git on PATH.
path: folder inside the repository to check.
Inputs: path. Returns: result
compare_envA
Compare .env with its template (.env.example/.sample/.template) in every env root.
Reports names missing from .env, extra names the template does not document, variables
empty in .env but required by the template (a # optional comment above a template line
exempts it), duplicated names, and values whose type differs from the template's.
Commented-out template lines (# NAME=) count as documented.
path: folder to scan. file / against: compare two specific env files instead (paths
relative to path), for example file=".env.production", against=".env.example".
Inputs: file, path, against. Returns: result
env_overviewA
Map every environment-variable source under a folder. Finds .env, .env.local,
.env., templates (.env.example/.sample/.template), docker-compose
environment:/env_file:, and CI workflow env: blocks; groups them by env root (a
monorepo has several) and reports variable counts, duplicates, syntax problems, BOM/CRLF,
and which framework client prefixes (VITE_, NEXT_PUBLIC_, ...) are in use. Never shows
values. Start here.
path: folder to scan, relative to the server's --dir sandbox (default: the whole sandbox).
Inputs: path. Returns: result
find_usageA
Scan source code for environment reads and cross-check them with the templates. Understands process.env.X / process.env["X"] / destructuring, import.meta.env.X, Deno.env.get, os.environ[...] / os.environ.get / os.getenv, ENV['X'] / ENV.fetch, std::env::var / env!, os.Getenv / os.LookupEnv, System.getenv, Environment.GetEnvironmentVariable, getenv / $ENV / Laravel env(), System.get_env, Prisma env(), and ${X} in compose files. Reports variables used in code but undocumented in the template (with file:line), documented but never read, and client-exposed secret-looking names. Ambient variables (PATH, HOME, NODE_ENV, GITHUB*) are ignored. It is a text scan: reads inside comments count, dynamic names (process.env[name]) are invisible.
path: folder to scan, relative to the sandbox.
Inputs: path. Returns: result
generate_exampleA
Propose a safe .env.example as text (one section per env root). It lists every variable
seen in env files, templates and source code, each with a type hint, whether it looks
secret, where the code reads it, and a warning if a secret would be exposed to the browser.
Every line is NAME= with nothing after the equals sign: no value, not even from your
templates. Nothing is written to disk; paste or save the text yourself.
path: folder to scan.
Inputs: path. Returns: result
validate_envA
Check env files for mistakes, from names and shapes only (no value is ever printed). Flags: placeholders (changeme, your_key_here), empty values, trailing whitespace, unquoted spaces, CRLF, a BOM, values wrapped in literal quotes, undefined ${REF}s, duplicates, syntax errors; names that promise a type but disagree (*URL not a URL, *PORT out of range, booleans, integers, emails, JWTs, *PATH that does not exist); localhost URLs in production files; real-looking secrets inside a template; and secret-looking names with a browser-exposed prefix (VITE, NEXT_PUBLIC, REACT_APP, ...).
path: folder to scan. file: validate only this env file (relative to path).
Inputs: file, path. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct role: overview, template comparison, source-code usage scanning, validation, git safety, and example generation. Overlap in reported issues is minimal and the descriptions make boundaries explicit, with env_overview marked as the starting point.
All names use consistent snake_case and are readable. Most follow an action_object pattern, though env_overview is noun-based rather than verb-based, a minor deviation.
Six tools is well-scoped for an environment-file auditing server. Each tool covers a distinct workflow and none feels redundant or missing from the core purpose.
The surface covers discovery, template comparison, code usage cross-checking, validation, gitignore safety, and safe example generation. For a read-only env auditing tool, this is a complete lifecycle without obvious dead ends.
Maintenance
Related MCP Connectors
Live checks for agent-written code: missing packages, end-of-life versions, stale Actions, secrets.
Package, dependency, CI and config safety checks for coding agents. Pay per call.
Checks AI-written code for leaked keys and made-up packages, on your machine. Never uploads code.
A vault for .env files and project credentials: one encryption key per project, a second factor before protected values open, an audit row for every reveal, and scoped MCP access for coding agents.
Related MCP Servers
- AlicenseAqualityCmaintenanceCompares a project's .env file against its .env.example template to surface missing, extra, and empty keys, flag empty required variables, and produce paste-safe key inventories for tickets or sharing. Runs entirely on local files with every value redacted, so secrets are never echoed or uploaded.3MIT
- AlicenseNot gradedqualityBmaintenanceEnables scanning a repository's source files for actual environment variable reads and diffing those names against .env.example or .env.sample. Returns a deterministic JSON report with the sync verdict, counts, and findings for used-but-undocumented, documented-but-unused, and missing-example vars, without ever reading values.53 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to validate .env files against .env.example, detecting missing keys, type mismatches, placeholders, and undocumented entries while reporting only key names, line numbers, and issue codes so secret values never enter LLM context.1MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to scan env files and entire projects for hard-coded secrets such as API keys, tokens, and private keys, returning only sanitized reports with line numbers, secret types, and variable names. Secret values never enter the model's context, and all access is read-only and confined to the project root.2MIT