Skip to main content
Glama

EnvSpeak

MCP 服务器和 CLI,用于解析 .env 文件、Docker Compose 和 Kubernetes 中的配置/环境变量级联——告诉 AI 代理(以及你)某个变量在运行时实际求值为什么,以及为什么。

与 CSS 级联相同的问题形态——多个来源、不明显的优先级规则,以及一个仅仅因为定义位置而“胜出”的值——只不过应用于应用程序配置而非样式表。它是 stylesafe 和 stylespeak 的姊妹项目,后者为 CSS 做同样的事情。

问题

真实应用的配置来自 .env、.env.local、.env.production、docker-compose.yml(environment: 与 env_file:)、Kubernetes ConfigMap/Secret 对象,以及代码中的硬编码回退——五层以上,每一层都有自己的优先级规则,而这些规则组合起来的方式并不像你猜测的那样。最著名的陷阱:普通的 .env.local 会覆盖 .env.production,除非你还有一个 .env.production.local——因为在常规 dotenv 级联中,“本地”的优先级高于“特定环境”。编辑配置的代理无法知道某个变量实际解析为什么,也不知道如果更改某一层会破坏什么。

Related MCP server: @mcpx-digital/env-check

工具

  • resolve_variable — DATABASE_URL 实际求值为什么,哪个文件胜出?

  • trace_variable — 该变量在所有领域和环境中的每个设置位置。

  • impact_preview — 如果我更改此文件中的此值,下游实际会改变什么——又有哪些被更高优先级的东西屏蔽?

  • config_manifest — 一份压缩的全项目摘要:每个变量、其来源,以及风险热点(位于被跟踪文件中的机密、在代码中读取但没有任何回退且在任何地方都没有来源的变量)。

  • diff_environments — 解析两个环境/服务/工作负载下的每个变量,查看它们之间实际有何不同。

安装

npm install -g @patrizzos/envspeak

作为 MCP 服务器

{
  "mcpServers": {
    "envspeak": {
      "command": "envspeak"
    }
  }
}

作为 CLI

envspeak resolve DATABASE_URL --environment production
envspeak trace LOG_LEVEL
envspeak impact --file .env --variable LOG_LEVEL --newValue debug
envspeak manifest
envspeak diff --a '{"nodeEnv":"development"}' --b '{"nodeEnv":"production"}'

如果省略 --files,envspeak 会在 --projectRoot(默认:当前目录)下自动发现 .env*、Compose 和 Kubernetes 清单文件。传入 --files a,b,c 以显式限定范围——建议用于 MCP 调用,这样代理就能精确控制读取的内容。

编码的优先级约定

dotenv(Next.js/Vite 风格,事实标准):process.env(shell)> .env.[env].local > .env.local > .env.[env] > .env > 代码回退(process.env.X || 'default')。注意 .env.local 的优先级高于 .env.[env]——即上面的陷阱。

Docker Compose:docker compose run -e(CLI)> environment: > env_file:(列表中的最后一个文件在冲突时胜出)> Dockerfile ENV(不分析)。

Kubernetes:内联 env: 始终覆盖 envFrom:(批量 ConfigMap/Secret 导入;其中列表中的最后一个条目胜出)。环境值在 Pod 启动时冻结——编辑引用的 ConfigMap/Secret 不会在未重启或滚动更新的情况下到达运行中的 Pod。impact_preview 会标记这一点。

每个结果都包含一个 confidence 级别和一个 caveat 字符串,因为 shell 导出或 CLI 传入的覆盖始终是可能的,并且静态分析永远看不到——envspeak 会明确说明这一点,而不是假装拥有它并不具备的确定性。

安全

  • 零运行时依赖。 用于 Compose/Kubernetes 文件的 YAML 子集解析器是手写的,而不是从 npm 引入的,因此没有第三方供应链攻击面。npm audit 在构造上就是干净的。

  • 路径遍历防护。 文件读取会针对 projectRoot 进行解析,并拒绝逃逸出该目录,即使工具调用被给予精心构造的相对路径。

  • 原型污染防护。 从 YAML 内容解析出的对象键(__proto__、constructor、prototype)永远不会用于属性赋值。

  • 机密默认脱敏。 Kubernetes Secret 值仅显示为 ab***yz,无论哪个工具展示它们,都不会完整显示。

  • 机密可能性启发式。 变量名和值形态(AWS 密钥、GitHub 令牌、PEM 块、高熵凭据形态字符串)会被标记,与 .gitignore 交叉引用,并作为 secretFlag / 风险热点呈现,而不是静默放过。

  • 有界、非回溯的正则表达式。 用于代码默认值扫描的模式匹配会限制匹配长度,并避免嵌套量词,以防止在大文件上出现 ReDoS。

  • 无论这些防护如何,envspeak 都会读取你指向的任何文件——请限定代理可以传递的 files 列表,就像你限定任何具有文件系统访问权限的工具一样。

开发

npm test   # zero dependencies — no install step needed

许可证

MIT

Available Tools

5 tools
config_manifestB

Compressed, project-wide summary of every config variable found — sources, domains, and risk hotspots (likely secrets in tracked files, variables read in code with no source). Load once per session instead of repeated resolve_variable calls.

Inputs: files (required), projectRoot, maxVariables.

diff_environmentsA

Resolves every variable under two different environment/service/workload selectors and reports what differs between them.

Inputs: files (required), environmentA (required), environmentB (required), variables, +1 more.

impact_previewB

Predicts which environments/services/workloads are actually affected if a variable's value in one file is changed (or removed) — including which contexts are shielded by a higher-precedence source.

Inputs: file (required), files (required), variable (required), newValue, +1 more.

resolve_variableA

Resolves what a config/env variable actually evaluates to across dotenv, docker-compose, and Kubernetes sources, and which source wins.

Inputs: files (required), variable (required), service, workload, +3 more.

trace_variableA

Lists every place a variable is defined or read across dotenv, compose, k8s, and code, and what wins in each discovered environment/service/workload context.

Inputs: files (required), variable (required), projectRoot.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 5 tools

    Disambiguation4/5

    Most tools are clearly separated by purpose: manifest summarizes, impact previews, diff compares, and trace enumerates. The only real overlap is between resolve_variable and trace_variable, since both explain precedence and 'what wins,' though one targets the final value and the other targets all definition/read locations.

    Naming Consistency3/5

    resolve_variable and trace_variable follow a clean verb_noun pattern, but config_manifest and impact_preview are noun compounds, and diff_environments uses a terse verb. The names are readable and descriptive, but the naming convention is not uniform across the set.

    Tool Count5/5

    Five tools is well-scoped for a read-only environment/config analysis server. Each tool covers a distinct analytical need without redundancy or bloat, and the count feels intentional rather than thin or excessive.

    Completeness5/5

    The set covers the full analysis workflow: resolving a single variable, tracing all usages, generating a project-wide manifest, predicting change impact, and diffing environments. No obvious missing operation is needed for the stated domain.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Provides AI coding agents with structured, evidence-based diagnostics about the local development environment, detecting tech stack, runtime mismatches, dependency state, services, ports, and Git status without exposing secrets or using network calls.
      10
      Apache 2.0
    • A
      license
      A
      quality
      C
      maintenance
      Compares 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.
      3
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Checks which .env, .git, keys and source maps Cloudflare Pages, Vercel, Netlify or Firebase would publish, before and after deploy. CLI, live probe, Claude Code hook, MCP server and GitHub Action.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables 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 npm
      MIT