Skip to content

zcodegraph MCP returns malformed database after reindex #679

Description

@jununfly

Problem

In jununfly/ZAgenticLoop, zcodegraph_explore failed with:

Error: Tool execution failed: database disk image is malformed

I then ran:

zcodegraph index

The CLI completed successfully:

Indexed 49 files
702 nodes, 1,213 edges
Indexed with rust-hybrid
Fallback health: degraded
27 TypeScript fallback files

But a later MCP zcodegraph_explore call still returned the same malformed database error.

Expected

After a successful zcodegraph index, MCP queries should use the rebuilt usable index, or surface a clear remediation step if the MCP server is still holding a stale/corrupt SQLite handle.

Actual

MCP continues to report database disk image is malformed even after CLI reindex succeeds.

Context

  • Project: jununfly/ZAgenticLoop
  • Command run from repo root: zcodegraph index
  • Follow-up MCP call: zcodegraph_explore
  • CLI index result was usable but fallback-degraded.

Possible cause

The MCP process may keep an old/corrupt DB connection or cache after the CLI rebuilds the index, or the reindex may not replace the same database file used by the MCP server.

Suggested behavior

  • Detect and recover from malformed SQLite DB by reopening/rebuilding.
  • If recovery is unsafe, return a specific remediation such as restarting MCP or running a particular repair command.
  • Consider verifying that CLI and MCP resolve the same .zcodegraph path.

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