Envdoc

io.github.CloudCorpRecords由 GitHub 帳號 CloudCorpRecords 發布v0.1.0更新於 Oct 25, 2026

Check .env.example against actual env usage in code: missing, stale, and undocumented vars.

已驗證STDIO僅桌面開發者工具安全與監控

概覽

AI 產生的概覽

一個本機 MCP 伺服器,將儲存庫程式碼中使用的環境變數名稱與 .env.example 比對,並回報是否出現偏差。

可以做什麼
掃描指定儲存庫路徑下 TypeScript、JavaScript 與 Python 檔案中的環境變數讀取,與 .env.example 或 .env.sample 中列出的名稱比較,回傳包含結論、計數與發現項目的 JSON 報告。
適用情境
當希望助理檢查專案的範例環境變數檔是否與程式碼實際讀取的變數一致時使用,例如新成員加入前或審查設定變更時。
執行需求
透過 npx(Node.js)或已發佈的 Docker 映像作為本機程序執行;未宣告帳號、API 金鑰或環境變數。它會讀取本機上儲存庫路徑中的檔案。
安裝前請注意
它會讀取儲存庫檔案,但從不讀取、儲存或輸出環境變數的值,只比較名稱。它僅做靜態分析,不執行被掃描儲存庫中的任何內容。涵蓋範圍限於大寫名稱與特定存取寫法,動態或解構存取不會被回報。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Envdoc,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

envdoc

Diff environment variables used in code against .env.example.

envdoc scans source files for actual env var reads and compares the names it finds with the names documented in .env.example (or .env.sample). It reports vars that are used but not documented, vars that are documented but never used, and whether the repo is in sync or has drifted. Values are never read into the report: only names are compared.

What it does

  • Walks the target directory and scans .ts, .js, .mjs, .cjs, and .py files.
  • Skips node_modules, .git, dist, and any directory named fixtures.
  • Finds usages of these forms:
    • process.env.NAME
    • process.env["NAME"] and process.env['NAME']
    • import.meta.env.NAME
    • os.environ["NAME"] and os.environ['NAME']
    • os.environ.get("NAME") and os.environ.get('NAME')
    • os.getenv("NAME") and os.getenv('NAME')
  • Reads .env.example at the repo root, or .env.sample if .env.example is not present (first found wins). Names come from lines of the form KEY= or export KEY=. Only the left side of = is parsed.
  • Emits a deterministic report: findings are ordered by var name, files are walked in sorted order, and no timestamps are included.

Name pattern: NAME is [A-Z][A-Z0-9_]* . Names must start with an uppercase letter and contain only uppercase letters, digits, and underscores. Lowercase-start names after process.env are ignored by design. See Limits for details.

Install

bash
npx @reneturcios/envdoc check

Or run from a checkout:

bash
npm installnpm run buildnode dist/cli.js check .

CLI

bash
# Check the current directory (human readable output)npx @reneturcios/envdoc check
# Check another pathnpx @reneturcios/envdoc check path/to/repo
# Machine readable outputnpx @reneturcios/envdoc check path/to/repo --json
# Start the MCP server on stdionpx @reneturcios/envdoc mcp
# Print the versionnpx @reneturcios/envdoc --version

Exit codes:

  • 0 when the verdict is IN-SYNC
  • 1 when the verdict is DRIFT
  • 2 on usage error
  • 141 when the reader closed the output pipe early (the shell-visible equivalent of SIGPIPE)

Example output:

envdoc check .: DRIFT  DRIFT: 2 used, 1 documented, 1 missing, 0 stale.  counts: used 2, documented 1, missing 1, stale 0  findings (2):    [MEDIUM] app.ts:2 USED-NOT-DOCUMENTED FEATURE_CHARLIE is used in code but not documented in .env.example    [INFO] VALUES-IGNORED Values are ignored: only variable names are compared, values are never read into the reportDRIFT: at least one medium or high finding. Document the missing vars or add an example file.

MCP server

Add to your MCP client config:

json
{  "mcpServers": {    "envdoc": {      "command": "npx",      "args": ["-y", "@reneturcios/envdoc", "mcp"]    }  }}

Tools:

  • check_env_docs: scan a repo path and return the full report as JSON. Input is a single path string. The report contains the verdict, counts (used, documented, missing, stale), findings, and a summary. Values are never included.

Docker:

bash
docker run -i ghcr.io/cloudcorprecords/envdoc:0.1.0 mcp

Rules

RuleSeverityMeaning
USED-NOT-DOCUMENTEDmediumA var is used in code but not listed in the example file. The finding carries the file and line of first use. One finding per var.
DOCUMENTED-NOT-USEDlowA var is listed in the example file but never used in code. One finding per var. Vars on the always-ok list are excluded.
NO-EXAMPLEhighNo .env.example or .env.sample was found but code uses at least one var. One finding per report.
VALUES-IGNOREDinfoValues are never read into the report. Only names are parsed; for the example file only the left side of = is read. Exactly one finding per report.

Counts in every report:

  • used: number of distinct vars found in code
  • documented: number of distinct vars listed in the example file
  • missing: number of used vars that are not documented (the count of USED-NOT-DOCUMENTED findings)
  • stale: number of documented vars that are never used and are not on the always-ok list (the count of DOCUMENTED-NOT-USED findings)

Always-ok list

These vars are never flagged as documented-not-used, even when no code in the repo reads them. They are commonly set by the platform, the runtime, or CI rather than by application code:

  • NODE_ENV
  • PORT
  • HOST
  • CI
  • DEBUG

The list applies only to the DOCUMENTED-NOT-USED rule. If code uses one of these vars and it is not documented, it is still reported as USED-NOT-DOCUMENTED like any other var.

Verdict rules

  • IN-SYNC: no medium or high findings. Low and info findings may still be present. Exit code 0.
  • DRIFT: at least one medium or high finding. Exit code 1.

Special case: if no example file exists and code uses no vars at all, the verdict is IN-SYNC, all findings are info severity, and the summary is "no env usage found".

If no example file exists and code does use vars, the verdict is DRIFT with a high NO-EXAMPLE finding plus one USED-NOT-DOCUMENTED finding per missing var.

Limits

  • Name patterns only, values never read. envdoc compares names only. It never reads, stores, or prints env values. For the example file it parses only the left side of = on each line. For code it matches only the literal name patterns listed above.
  • Only uppercase names are tracked. A name must match [A-Z][A-Z0-9_]* . Lowercase-start names after process.env are ignored. Mixed-case names that start with a lowercase letter are not tracked.
  • Dynamic env access cannot be tracked. Code that computes the var name at runtime, such as process.env[someVar], process.env[prefix + suffix], or os.environ[some_var], names no literal var in the source and is not reported. Audit dynamic keys separately.
  • Only the listed access forms are recognized. Other forms such as destructuring (const { FOO } = process.env), os.environ.NAME attribute access, or framework helpers are not detected in this version.
  • Only .ts, .js, .mjs, .cjs, and .py files are scanned. Other file types are ignored.
  • The example file is looked up only at the target root as .env.example, then .env.sample. Nested example files are not merged.
  • Static analysis only. Nothing in a scanned repo is executed.

Development

bash
npm installnpm run buildnpm test

License

MIT

來源:README.md,提交 5a6b6a2

工具

1

check_env_docs

Scan a repo's source for environment variable reads and compare with its .env.example: variables used in code but missing from the example (with file and line), variables documented but never used, and a verdict of IN-SYNC or DRIFT. Values are never read, only names.

輸入參數path必填

版本歷史

1
  1. v0.1.0最新Oct 25, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分