Repository navigation
Description
Version
codebase-memory-mcp 0.10.2
Platform
Linux (arm64)
Install channel
GitHub release archive / install.sh
Binary variant
standard
What happened, and what did you expect?
When CBM_CACHE_DIR points to a non-default cache directory, codebase-memory-mcp install -y --force configures the Codex MCP server without forwarding that variable:
[mcp_servers.codebase-memory-mcp]
command = "/root/.local/bin/codebase-memory-mcp"
args = []Codex sanitizes the environment of stdio MCP subprocesses unless variables are explicitly listed in env_vars. Consequently, the CBM subprocess spawned by Codex falls back to the default cache directory while the active account daemon uses the custom CBM_CACHE_DIR.
The cache mismatch closes the MCP connection during initialization. Codex then exposes none of the CBM tools.
I expected the CBM installer to configure Codex to forward CBM_CACHE_DIR whenever that variable is set:
[mcp_servers.codebase-memory-mcp]
command = "/root/.local/bin/codebase-memory-mcp"
args = []
env_vars = ["CBM_CACHE_DIR"]Reproduction
-
Set a custom cache directory:
export CBM_CACHE_DIR=/workspaces/example/.cache/codebase-memory-mcp -
Install/configure CBM:
codebase-memory-mcp install -y --force
-
Start the daemon and index a repository:
codebase-memory-mcp daemon start codebase-memory-mcp cli index_repository --repo-path /workspaces/example
-
Inspect
~/.codex/config.toml. The generated MCP entry hascommandandargs, but noenv_vars. -
Start Codex from an environment containing
CBM_CACHE_DIRand request a CBM tool such aslist_projects. -
Observe that CBM tools are unavailable and the MCP handshake fails.
For comparison, add this manually:
env_vars = ["CBM_CACHE_DIR"]Start a new Codex session and call list_projects again. The MCP connection succeeds and the indexed project is returned.
No repository source code is required to reproduce the problem.
Logs
error: CBM could not start because the active account daemon uses a different cacheCodex also reports:
MCP startup failed: handshaking with MCP server failed: connection closed: initialize response
The two cache locations in the reproduced case were:
Active daemon: /workspaces/example/.cache/codebase-memory-mcp
Codex-spawned CBM fallback: /root/.cache/codebase-memory-mcp
Proposed solution
When CBM_CACHE_DIR is set during installation, add it to the Codex server’s forwarded environment:
[mcp_servers.codebase-memory-mcp]
env_vars = ["CBM_CACHE_DIR"]The installer should preserve existing env_vars entries and add CBM_CACHE_DIR only if it is absent.
The same setting may also be needed in installer-generated Codex agent profiles that declare their own [mcp_servers.codebase-memory-mcp] transport.
A regression test could:
- Run configuration generation with
CBM_CACHE_DIRset. - Verify that the resulting Codex server table contains
env_vars = ["CBM_CACHE_DIR"]. - Verify that existing forwarded variables are preserved.
- Verify that the generated TOML remains idempotent across repeated installs.
Project scale
Not relevant; the failure occurs during MCP initialization before graph access.
Confirmations
- I searched existing issues and did not find a duplicate mentioning Codex
env_varsorCBM_CACHE_DIR. - The reproduction does not require proprietary code.
Related but distinct: #1383 discusses account-daemon cache conflicts, but not the Codex installer’s missing environment forwarding.
Activity
anton-matosov commentedon Aug 12, 2026
I have worked around this issue by adding the env_vars after install and reverting before reinstall with this little script:
https://github.com/plume-works/agent-devcontainer/pull/46/changes#diff-570bc27223451d80b291a06294080e6fbee20dc73f427e9a292f6fff1d373294
fix(cli): forward CBM_CACHE_DIR to the Codex-spawned server (#1562)
DeusData commentedon Aug 12, 2026
@anton-matosov — fixed and shipping in v0.10.3 (releasing now), commit
63f26f4c. The generated Codex block now carriesenv_vars = ["CBM_CACHE_DIR"], exactly the shape you verified by hand.One deliberate difference from the obvious implementation: the name is listed unconditionally, not only when
CBM_CACHE_DIRhappens to be set during install.env_varsnames variables to forward if present, so listing it costs nothing when unset — and it keeps working for someone who sets the variable after installing, which install-time detection would silently miss and reproduce your exact bug with no way to tell.Thank you for tracing it to the sanitized subprocess environment and confirming the corrected block end-to-end before filing. That turned it into a one-line change.
DeusData commentedon Aug 13, 2026
v0.10.3 is published — https://github.com/DeusData/codebase-memory-mcp/releases/tag/v0.10.3 (GitHub archives, npm, and PyPI are all serving it).
This fix is in it. Please give it a try when you get a chance: if it behaves in your setup, feel free to close this out, and if anything still looks off, say so and we'll pick it straight back up. Thank you again for the report.
DeusData commentedon Aug 13, 2026
Closing as fixed in v0.10.3 by commit
63f26f4c. Generated Codex configuration now listsCBM_CACHE_DIRinenv_varsunconditionally, so it is forwarded whenever present without depending on install-time state.Thank you again @anton-matosov for tracing the handshake failure to Codex's sanitized subprocess environment and verifying the corrected TOML shape. If the custom-cache path still diverges on v0.10.3 or newer, comment here and we will reopen it.
Upgrade codebase-memory-mcp to 0.10.3 and drop the Codex patch workar…
fix(cli): forward CBM_RUNTIME_DIR in the generated Codex configuration (
feat(cli): add Grok Build as an install target
fix(install): adopt the Codex MCP table after Codex rewrites it (#1720)