Skip to content

codedb mcp <path> hangs on loading_snapshot. Correct syntax is codedb <path> mcp #503

@Elesiann

Description

@Elesiann

Bug

Running codedb mcp /path/to/project hangs indefinitely with scan=loading_snapshot files=0.

Root cause

isCommand() in main.zig:1072 includes "mcp" in its command list. So when called as
codedb mcp /path, the parser hits the isCommand(args[1]) branch at line 147, sets
root="." and cmd="mcp", and the path argument is silently ignored.

With root="." and root_is_explicit=false, the condition at line 227 evaluates to true:

const mcp_deferred_root = std.mem.eql(u8, cmd, "mcp") 
    and std.mem.eql(u8, root, ".") 
    and !root_is_explicit;

This triggers the deferred scan flow that waits for a roots/list MCP message —
which never arrives when running outside a MCP client, so the server hangs forever
at loading_snapshot.

Reproduction

codedb mcp /home/user/myproject
# → scan=loading_snapshot files=0  (hangs forever)

codedb /home/user/myproject mcp
# → scan=ready files=433  (works)

Fix

Two options:

  1. Fix the README to document the correct syntax: codedb <path> mcp
  2. Or handle both arg orderings in the parser — if args[1] == "mcp" and args[2]
    looks like a path, treat it as the root

Workaround: CODEDB_ROOT=/path codedb mcp also works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions