Skip to content

fix(mcp): honor CONFIG_PATH env var instead of clobbering it with the --config default (#1736) - #1737

Open
Anai-Guo wants to merge 1 commit into
getzep:mainfrom
Anai-Guo:fix/config-path-env-1736
Open

fix(mcp): honor CONFIG_PATH env var instead of clobbering it with the --config default (#1736)#1737
Anai-Guo wants to merge 1 commit into
getzep:mainfrom
Anai-Guo:fix/config-path-env-1736

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Aug 7, 2026

Copy link
Copy Markdown

Summary

Fixes #1736. The documented CONFIG_PATH env-var pattern for pointing the MCP server at a custom config.yaml in container deployments was silently ignored on every boot.

Root cause

The --config CLI argument carried a non-empty Path default:

default_config = Path(__file__).parent.parent / 'config' / 'config.yaml'
parser.add_argument('--config', type=Path, default=default_config, ...)

Since that default is always truthy, args.config is populated even when --config is never passed. The startup code then ran unconditionally:

if args.config:
    os.environ['CONFIG_PATH'] = str(args.config)

so the bundled demo config path always overwrote whatever CONFIG_PATH the deployment environment had set, before GraphitiConfig() (and its YamlSettingsSource, which reads os.environ.get('CONFIG_PATH', 'config/config.yaml')) ever ran. Net effect: the env-var path never took effect, with no error or warning.

Fix

  • Change the --config default to None so an explicitly-passed flag can be distinguished from the default.
  • Only write CONFIG_PATH when --config was actually passed; otherwise fall back to the bundled default only if CONFIG_PATH is not already set in the environment.

Precedence is now: explicit --config > CONFIG_PATH env var > bundled default. This restores the documented env-var behavior while preserving the previous no-argument default (the bundled absolute path), so nothing regresses for users who rely on neither.

Testing

  • python -m ast parse check on the modified module.
  • Traced the three precedence paths against config/schema.py:303 (os.environ.get('CONFIG_PATH', 'config/config.yaml')).

🤖 Generated with Claude Code

… --config default (getzep#1736)

The --config CLI argument carried a non-empty Path default, which argparse
populates on every run even when the flag is not passed. The startup code then
unconditionally did os.environ['CONFIG_PATH'] = str(args.config), so the
bundled demo config path always overwrote whatever CONFIG_PATH the deployment
environment set, before GraphitiConfig() read it. The documented CONFIG_PATH
env-var pattern for container deployments therefore never took effect, silently.

Change the flag default to None and only write CONFIG_PATH when --config was
actually passed; otherwise fall back to the bundled default only if CONFIG_PATH
is not already set in the environment. Precedence is now:
explicit --config > CONFIG_PATH env var > bundled default, preserving the
previous no-argument behavior while restoring the env-var path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CONFIG_PATH env var silently overwritten by always-truthy --config CLI default

1 participant