feat(mcp): surface when a newer CodeGraph release exists (non-blocking update check)#1253
Merged
Conversation
…ging anything (#1243) The recommended MCP config launches the local binary, so a server left running drifts behind releases silently — users discover the version gap only when something breaks. Per the reporter's preferred option 1, the server now checks the latest GitHub release in the background on startup (never blocking; reuses the upgrade command's release-redirect resolution so the two can't drift) and surfaces a one-line notice on three surfaces: one stderr line (the MCP host's server log), the initialize instructions (with do-not-run-it-yourself guidance for the agent), and codegraph_status. Discipline: results cache in ~/.codegraph/update-check.json shared across every proxy/daemon on the machine — 24h TTL on success, 1h backoff after failure, an outage never hides an already-known update, and a stale cache re-kicks a background refresh so long-lived daemons keep noticing. The initialize path is a memoized synchronous cache read (the respond-fast contract holds), and both handshake answerers (session + proxy) share one helper so they can't diverge. Never stdout. Hardening: the latest tag arrives from a network redirect via an on-disk cache and ends up inside agent-visible instructions, so only a canonical vX.Y.Z rebuilt from PARSED semver fields is ever interpolated — a tag carrying trailing text (parseSemver is not end-anchored) renders without it, and a non-version tag renders nothing and counts as a failed attempt. Off is off: CODEGRAPH_NO_UPDATE_CHECK=1 (dedicated) or DO_NOT_TRACK=1 (broad convention — already set by data-plane deployments) suppresses the network call and the notice entirely. Documented in TELEMETRY.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1243.
Problem
The recommended MCP config launches the local
codegraphbinary, so the server (and the prompt hook beside it) silently stays on whatever version was last manually upgraded. Users discover the drift only when something breaks. The reporter's preferred fix (their option 1): check on serve start, surface a notice, change nothing.What this does
On MCP server start (proxy, daemon, and direct modes share the hook), refresh a machine-shared update-check cache in the background and — when a newer release exists — surface one sentence on three surfaces:
initializeinstructions, with explicit "mention it to the user when convenient; do not run the upgrade yourself" guidance — the primary user-visible channel, sincecodegraph_statusis unlisted by defaultcodegraph_statusNothing auto-updates.
Design notes
resolveLatestVersion()(the GitHub release-redirect trick, linux install? how? #325-safe), so what the check reports and whatcodegraph upgradeinstalls can't drift.~/.codegraph/update-check.json, shared by every server process — 24h TTL on success, 1h backoff on failure; an outage never hides an already-known update; a stale cache re-kicks a background refresh so long-lived daemons keep noticing.initializepath is a memoized synchronous cache read (the MCP server fails to connect with Claude Code: Content-Length framing vs newline-delimited JSON transport mismatch #172 respond-fast contract holds), and both handshake answerers — session and proxy — share oneinitializeInstructions()helper so they can't diverge.vX.Y.Zrebuilt from parsed semver fields is ever interpolated. A tag with trailing text (parseSemverisn't end-anchored) renders without it; a non-version tag renders nothing and counts as a failed attempt.CODEGRAPH_NO_UPDATE_CHECK=1(dedicated) orDO_NOT_TRACK=1(broad convention) suppresses the network call and the notice entirely. Documented in TELEMETRY.md with the honest note that only a version number is fetched.Validation
🤖 Generated with Claude Code