Skip to content

fix(env): honor CGC_RUNTIME_DB_PATH env var in _default_global_db_path to fix MCP start failure#1295

Open
TranscendenceLiang wants to merge 1 commit into
CodeGraphContext:mainfrom
TranscendenceLiang:main
Open

fix(env): honor CGC_RUNTIME_DB_PATH env var in _default_global_db_path to fix MCP start failure#1295
TranscendenceLiang wants to merge 1 commit into
CodeGraphContext:mainfrom
TranscendenceLiang:main

Conversation

@TranscendenceLiang

Copy link
Copy Markdown

The KuzuDB C++ engine cannot handle paths with non-ASCII characters, mirroring the same Windows limitation that already affects the LadybugDB engine in GitNexus.

Root cause

The MCP server resolves its database path via _default_global_db_path(), which:

  1. Only consulted FALKORDB_PATH for the falkordb backend.
  2. Otherwise hardcoded CONFIG_DIR / "global" / "db" / <backend>, where CONFIG_DIR defaults to ~/.codegraphcontext (i.e. C:\Users\<name>\.codegraphcontext on Windows).

Meanwhile, the CLI commands (cgc index, cgc stats) already honored CGC_RUNTIME_DB_PATH in _initialize_services() as the highest-priority override. The MCP server simply didn't check it, so even users who had relocated the DB via .env saw MCP crash on the default Chinese path.

Fix

Read CGC_RUNTIME_DB_PATH first in _default_global_db_path(), before any backend-specific lookup. This keeps the MCP server consistent with the CLI's existing resolution order.

env_override = os.environ.get("CGC_RUNTIME_DB_PATH")
if env_override:
    return env_override

The MCP server resolves its DB path via _default_global_db_path,
which only consulted FALKORDB_PATH for falkordb and otherwise
hardcoded the default under CONFIG_DIR. On Windows machines
where CONFIG_DIR contains non-ASCII characters (e.g. C:\Users\<name>\),
this crashes KuzuDB with a path encoding error:

  RuntimeError: IO exception: Cannot open file.
    path: C:\Users\<name>\.codegraphcontext\global\db\kuzudb

By checking CGC_RUNTIME_DB_PATH first (matches what cgc index and
cgc stats already honor via _initialize_services), the MCP server
uses the same relocated path and stays consistent with the CLI.
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@TranscendenceLiang is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog tasks

Development

Successfully merging this pull request may close these issues.

1 participant