Skip to content

feat(mcp): warn once when a project's index predates the running engine - #3122

Merged
colbymchenry merged 1 commit into
mainfrom
claude/pr-1853-mcp-index-version-warning
Oct 31, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
claude/pr-1853-mcp-index-version-warning

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Summary

The first successful tool response for a project whose index predates the running extraction engine now opens with a one-time warning, once per project per MCP session. codegraph_status always reports the build version, the running version and whether a rebuild is recommended. Detection is local, and nothing rebuilds by itself.

Root cause

Only the codegraph status CLI reported an index built by an older engine. An agent working over MCP had no sign that its answers could miss what a newer engine extracts.

What came from the contributor, and what changed

The design is theirs: state on the session because one daemon serves many clients, a warning that an error response doesn't use up, independent tracking for each projectPath project, and the proxy noting a warning the daemon delivered so an in-process failover doesn't repeat it.

Our changes:

  • Dropped the plan document under docs/superpowers/.
  • Rebased over about 450 commits. The only conflict was the proxy's call into the tool handler.
  • The warning and the status line now leave indexing to the user ("Indexing is the user's decision: they can run codegraph index"), the wording the not-indexed guidance uses. AGENTS.md: indexing is the user's call, never the agent's.
  • One-time claims key on the canonical project root, so the proxy and the handler agree on a project however its path is spelled. Added a case for that, and a case for the wording.
  • CHANGELOG moved under [Unreleased], in house format.

No automatic rebuild: that stays #1798.

Validation

  • Tests: 7 unit cases in mcp-index-version-warning.test.ts and 2 real proxy and daemon cases in mcp-daemon.test.ts.
  • Mutations: turning the notice off fails 5 of 7, delivering it every time fails 5 of 7, and dropping the proxy's record fails the failover case.
  • Real MCP sessions, main against this branch, both arms on one index:
Repo Files tools/list Current index: 2 explores Stale: first explore Stale: second explore
express 149 same byte-identical main's + 338 chars byte-identical
flask 91 same byte-identical main's + 338 chars byte-identical
gin 110 same byte-identical main's + 338 chars byte-identical
excalidraw 738 same byte-identical main's + 338 chars byte-identical

Fixes #1852

Lands #1853 by @cbeaulieu-gt

🤖 Generated with Claude Code

After an upgrade, an agent reading an index an older extraction engine
built got no sign of it: only the `codegraph status` CLI said so, and the
default MCP surface never showed that.

The first successful tool response for such a project now opens with a
one-time warning naming the version that built the index, the running
engine and `codegraph index`, worded as the user's decision, since
indexing is never the agent's. Each MCP client session tracks each project
on its own, including projects reached with `projectPath`, and an error
response doesn't use the warning up. The state lives on the session, not
the handler, because one daemon serves many clients. The proxy notes a
warning the daemon delivered so failing over in-process doesn't repeat it.
`codegraph_status` always reports both versions and whether a rebuild is
recommended. Detection is local, and nothing rebuilds by itself.

Changes on top of the PR: its plan document is dropped, the wording now
leaves indexing to the user, and one-time claims key on the canonical
project root so the proxy and the handler agree on a project's spelling.

Validation: 7 new unit cases plus 2 daemon cases. Turning the notice off
fails 5 of 7, delivering it every time fails 5 of 7, and dropping the
proxy's record fails the failover case. Real MCP sessions on express,
flask, gin and excalidraw, main against this: tools/list identical. With a
current index, both explore responses byte-identical. With a stale index,
the first response is main's plus a 338-character warning, and the second
is byte-identical. The check costs about 30 to 50 microseconds a call.

Fixes #1852
Original PR #1853 by @cbeaulieu-gt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn MCP clients when a project index predates the current extraction version

2 participants