Skip to main content

Module env

Module env 

Source
Expand description

.env discovery + loader.

Walks upward from a start directory looking for a .env file and loads the first one found into the process environment. Mirrors the Python mcp_methods._utils.load_env semantics exactly so the same .env file behaves identically whether the server boots via Rust or Python:

  • Skip blank lines and lines starting with #.
  • KEY=VALUE only (lines without = are skipped).
  • Values may be quoted with single or double quotes; the outer quotes are stripped.
  • Existing env vars are NOT overwritten.

Operators who want a non-implicit pick can declare env_file: path at the top level of the manifest YAML; that wins over the walk-up.

Functionsยง

load_env_explicit
Load a specific .env path. Errors if the file does not exist โ€” the explicit env_file: manifest key promises that path.
load_env_walk
Walk upward from start looking for .env. Returns the path loaded, or None if nothing was found before reaching the root. Silent on parse errors per-line โ€” a single bad line should not stop the rest of the file from loading.