Skip to content

CLI build missing post-processing steps that build_or_update_graph_tool MCP tool includes #93

@igagankalra

Description

@igagankalra

Summary

code-review-graph build (CLI) and build_or_update_graph_tool(full_rebuild=True) (MCP tool) produce significantly different results. The CLI only runs Tree-sitter parsing, while the MCP tool also runs 4 post-processing steps. This means users who build via CLI get an incomplete graph with many features returning empty results.

This affects all CLI entry points — build, update, and watch — as well as the Claude Code PostToolUse hook which calls code-review-graph update.

Steps to Reproduce

  1. Install: pip install code-review-graph
  2. Build via CLI: code-review-graph build
  3. Start MCP server: code-review-graph serve
  4. Query communities → 0 results
  5. Query flows → 0 results
  6. Semantic search → 0 results (FTS not indexed)
  7. Architecture overview → 0 communities

Workaround: calling build_or_update_graph_tool(full_rebuild=True) via the MCP server produces the correct results with all features populated.

Expected Behavior

CLI build should produce the same output as the MCP build_or_update_graph_tool(full_rebuild=True) — or at minimum, the CLI docs/README should clarify that additional steps are needed.

Root Cause

cli.py (build command) calls only:

result = full_build(repo_root, store)

tools/build.py (build_or_update_graph) calls full_build() plus 4 post-build steps:

  1. Compute node signatures
  2. Rebuild FTS index (search.rebuild_fts_index)
  3. Trace execution flows (flows.trace_flowsflows.store_flows)
  4. Detect communities (communities.detect_communitiescommunities.store_communities)

These post-build steps populate the flows, flow_memberships, communities tables and the nodes_fts virtual table. Without them, the corresponding MCP tools return empty results.

Feature Comparison

Post-processing step CLI build MCP build_or_update_graph_tool
Tree-sitter parse (nodes + edges)
Compute signatures
Rebuild FTS index
Trace execution flows
Detect communities

Affected Entry Points

The same gap exists in all non-MCP paths:

  • code-review-graph build — CLI full build
  • code-review-graph update — CLI incremental update
  • code-review-graph watch — filesystem watcher (calls incremental_update internally)

The only path that works correctly is the MCP tool build_or_update_graph_tool().

Also Affects Claude Code Hooks

This isn't platform-specific — the bundled Claude Code hooks have the same gap:

  • hooks/session-start.sh suggests running code-review-graph build (CLI) when no graph exists — this produces an incomplete graph
  • hooks/hooks.json PostToolUse hook fires code-review-graph update (CLI) after every Write/Edit — incremental updates also skip post-processing

So even in Claude Code (the primary target platform), a user following the setup instructions gets an incomplete graph until an agent happens to call build_or_update_graph_tool() via the MCP server.

Suggestion

Extract the post-build pipeline from tools/build.py into a shared function and call it from both the MCP tool and the CLI commands. This would fix the CLI, the hooks, and the watch mode in one change.

Environment

  • code-review-graph v2.1.0
  • Python 3.14
  • macOS (Apple Silicon)
  • Tested with an agentic OpenCode workflow (multi-agent setup using the MCP server)

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