feat(mcp): notice when a newer CodeGraph release exists, without changing anything (#1243) (#1253)

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 commit is contained in:
Colby Mchenry
2026-07-10 17:36:47 -05:00
committed by GitHub
co-authored by Claude Fable 5
parent 8b82fe71f8
commit 47823944a3
8 changed files with 545 additions and 3 deletions
+9
View File
@@ -50,6 +50,7 @@ import {
import { connectWithHello, runLocalHandshakeProxy } from './proxy';
import { getDaemonSocketCandidates } from './daemon-paths';
import { getTelemetry } from '../telemetry';
import { checkForUpdateInBackground } from '../upgrade/update-check';
import { EARLY_PPID } from './early-ppid';
import { supervisionLostReason, parsePpidPollMs, parseHostPpid } from './ppid-watchdog';
import { installMainThreadWatchdog, WatchdogHandle } from './liveness-watchdog';
@@ -228,6 +229,14 @@ export class MCPServer {
// to the handshake path and never keeps the process alive.
getTelemetry().startInterval();
// #1243: the MCP config launches the local binary, so a server left
// running drifts behind releases with no signal. Refresh the shared
// update-check cache in the background and log ONE stderr notice when a
// newer version exists (stderr only — stdout is the protocol channel).
// The notice also reaches the agent via the initialize instructions and
// codegraph_status. Fire-and-forget: adds nothing to the handshake path.
checkForUpdateInBackground();
// The detached daemon process itself. Checked before the opt-out so the
// daemon honors the same env it was spawned with (it never sets NO_DAEMON).
if (daemonInternalSet()) {