Skip to content

fix(mcp): actionable error when graph.db is missing#56

Merged
smochan merged 1 commit into
mainfrom
feat/mcp-graph-not-built-error
May 30, 2026
Merged

fix(mcp): actionable error when graph.db is missing#56
smochan merged 1 commit into
mainfrom
feat/mcp-graph-not-built-error

Conversation

@smochan

@smochan smochan commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • New `GraphNotBuiltError` raised by `_load_graph` when `.codegraph/graph.db` is absent.
  • MCP dispatcher catches it and returns `{error: "graph_not_built", message: "...Run \`codegraph build\`...", db_path: ...}`.
  • Replaces the silent "empty result" behaviour that LLMs mistranslated as "workspace is empty".

v0.1.2 backlog item #8.

Test plan

  • 2 new tests in `tests/test_mcp_graph_not_built.py` (raise on missing db; dispatcher returns structured error).
  • Existing MCP suite (20 tests) green.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

codegraph PR review

Diff vs main · severity ≤ high

codegraph review (target: main)

Diff: +8 / -0 / ~0 nodes, +28 / -0 edges

Findings (1)

severity rule qualname file:line score message
low new-dead-code codegraph.mcp_server.server.GraphNotBuiltError.__init__ codegraph/mcp_server/server.py:28 10 Potentially unreachable new code

Triggered by codegraph CI · last run

@smochan smochan force-pushed the feat/mcp-graph-not-built-error branch from 192726f to b6055e1 Compare May 30, 2026 17:12
@github-actions

Copy link
Copy Markdown

codegraph PR review

Diff vs main · severity ≤ high

codegraph review (target: main)

Diff: +75 / -0 / ~0 nodes, +301 / -1 edges

Findings (1)

severity rule qualname file:line score message
low new-dead-code codegraph.mcp_server.server.GraphNotBuiltError.__init__ codegraph/mcp_server/server.py:28 10 Potentially unreachable new code

Triggered by codegraph CI · last run

Pre-0.1.2 the MCP server happily returned empty results when
.codegraph/graph.db didn't exist. Claude / Cursor paraphrased that as
"workspace is empty", sending users down the wrong rabbit hole.

`_load_graph` now raises a new `GraphNotBuiltError` carrying the
resolved db path. The MCP dispatcher catches it and returns a
structured `{error, message, db_path}` payload telling the LLM exactly
what command to suggest: `codegraph build`.

v0.1.2 backlog item #8.
@smochan smochan force-pushed the feat/mcp-graph-not-built-error branch from b6055e1 to d882cd3 Compare May 30, 2026 18:18
@github-actions

Copy link
Copy Markdown

codegraph PR review

Diff vs main · severity ≤ high

codegraph review (target: main)

Diff: +8 / -0 / ~0 nodes, +28 / -0 edges

Findings (1)

severity rule qualname file:line score message
low new-dead-code codegraph.mcp_server.server.GraphNotBuiltError.__init__ codegraph/mcp_server/server.py:28 10 Potentially unreachable new code

Triggered by codegraph CI · last run

@smochan smochan merged commit 93a5f37 into main May 30, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant