Problem
When codedb mcp is launched by an MCP client (opencode, Claude Code, etc.) from an unexpected cwd, or when the client does not provide usable roots, the server enters scan=loading_snapshot with files=0 and never recovers.
This produces a connected but functionally empty MCP server.
Observed behavior
cd /Users/dennis/Projects/personal
codedb snapshot # snapshot has 17 files
codedb mcp # files=0 scan=loading_snapshot (stuck)
codedb mcp --help # starts MCP server instead of showing help
codedb mcp --snapshot # silently ignored, starts server
The only workaround is wrapping the command in sh -lc "cd /path && exec codedb mcp".
Root causes
- Argument parsing:
codedb mcp --help starts the server instead of printing help. Unknown flags like --snapshot are silently ignored.
- Root resolution: When
root == "." and no CODEDB_ROOT is set, the server enters deferred mode and waits for MCP roots. If the client never sends roots (or sends empty roots), the 3s fallback fires — but if cwd is not indexable (e.g. /), the scan never triggers and loading_snapshot persists forever.
- No git root detection: Running
codedb mcp from a subdirectory of a git repo does not discover the repo root.
- Roots handshake errors: If
roots/list returns an error, missing result, or malformed roots, the deferred scan is never triggered.
Expected behavior
codedb mcp --help should print help and exit
codedb mcp [path] should honor the documented path argument
- Unknown flags should be rejected with a clear error
- Git root should be auto-detected from cwd
- Scan state should never remain stuck in
loading_snapshot indefinitely
- MCP stdout must contain only JSON-RPC messages
Related (already closed)
These were partially addressed but the combined scenario (MCP client + unexpected cwd + no roots) still fails.
Problem
When
codedb mcpis launched by an MCP client (opencode, Claude Code, etc.) from an unexpected cwd, or when the client does not provide usable roots, the server entersscan=loading_snapshotwithfiles=0and never recovers.This produces a connected but functionally empty MCP server.
Observed behavior
The only workaround is wrapping the command in
sh -lc "cd /path && exec codedb mcp".Root causes
codedb mcp --helpstarts the server instead of printing help. Unknown flags like--snapshotare silently ignored.root == "."and noCODEDB_ROOTis set, the server enters deferred mode and waits for MCP roots. If the client never sends roots (or sends empty roots), the 3s fallback fires — but if cwd is not indexable (e.g./), the scan never triggers andloading_snapshotpersists forever.codedb mcpfrom a subdirectory of a git repo does not discover the repo root.roots/listreturns an error, missing result, or malformed roots, the deferred scan is never triggered.Expected behavior
codedb mcp --helpshould print help and exitcodedb mcp [path]should honor the documented path argumentloading_snapshotindefinitelyRelated (already closed)
These were partially addressed but the combined scenario (MCP client + unexpected cwd + no roots) still fails.