Skip to content

feat(mcp): warn when project indexes need rebuilding - #1853

Closed
cbeaulieu-gt wants to merge 1 commit into
colbymchenry:mainfrom
cbeaulieu-gt:codex/upstream-mcp-stale-index-1852
Closed

cbeaulieu-gt wants to merge 1 commit into
colbymchenry:mainfrom
cbeaulieu-gt:codex/upstream-mcp-stale-index-1852

Conversation

@cbeaulieu-gt

Copy link
Copy Markdown
Contributor

Summary

  • warn each MCP client once per resolved project when its index predates the running extraction engine
  • keep warning state isolated per client across direct, shared-daemon, and daemon-to-local-fallback execution
  • always report index-build version, running version, and rebuild guidance from codegraph_status
  • document the behavior in the changelog

The check is local, preserves the nonblocking initialize handshake, and never starts indexing automatically.

Verification

  • npm run build
  • npx vitest run __tests__/mcp-index-version-warning.test.ts __tests__/mcp-staleness-banner.test.ts __tests__/upgrade.test.ts --maxWorkers=1 --minWorkers=1 — 69 passed
  • live daemon feature filter run three consecutive times — 6 passed total
  • git diff upstream/main...HEAD --check
  • post-commit artifact audit confirmed all eight changed files are present in HEAD
  • independent code review: no findings

Known upstream baseline

The broader upstream test suite is not currently zero-failure on this Windows host. Previously reproduced failures map to existing upstream issues/PRs, including daemon teardown EPERM cleanup covered by #1717; the focused feature assertions above pass.

Closes #1852

🤖 Generated by Codex on behalf of @cbeaulieu-gt

@cbeaulieu-gt
cbeaulieu-gt force-pushed the codex/upstream-mcp-stale-index-1852 branch from a049860 to cabf0d8 Compare October 4, 2026 02:06
@cbeaulieu-gt

Copy link
Copy Markdown
Contributor Author

Rebased this branch onto current main (6560052) and force-pushed the refreshed commit cabf0d8. The conflicts were limited to the daemon-test imports and the proxy’s newer local-engine handback/retry lifecycle; the resolution preserves that upstream lifecycle while retaining the per-client extraction-version warning state.

Current verification:

  • npm run build — passed
  • npx vitest run __tests__/mcp-index-version-warning.test.ts --maxWorkers=1 --minWorkers=1 — 6 passed
  • npx vitest run __tests__/mcp-daemon.test.ts -t "#1852" --maxWorkers=1 --minWorkers=1 — 2 passed, 22 skipped
  • git diff --check — passed
  • all files referenced by the PR are present in HEAD

A full npm test run was also attempted on this Windows host and was not green: 5,486 passed, 317 skipped, and 180 failed across 75 files, plus one watcher error. The failures were broad parallel-load 5s/10s timeouts and Windows EPERM cleanup locks; without an exact-main control run I am not classifying them as an upstream baseline. The affected #1852 suites pass in the isolated serial runs above.

The PR is now conflict-free and mergeable; it still awaits review.

🤖 Generated by Codex on behalf of @cbeaulieu-gt

colbymchenry pushed a commit that referenced this pull request Oct 31, 2026
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>
@colbymchenry

Copy link
Copy Markdown
Owner

Thanks @cbeaulieu-gt! This landed as #3122 with your authorship, which closes #1852. We left out the plan document, reworded the warning so indexing stays the user's call, and made the one-time check use the canonical project root. The session-owned state and the proxy failover handling are yours as written.

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