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 MchenryandClaude Fable 5 authored and GitHub committed 2026-07-10 17:36:47 -05:00
1 parent 8b82fe71f8
commit 47823944a3
8 files changed
+545 -3

No files matched your search

+9
View File
@@ -30,6 +30,7 @@ import {
import { clamp, validatePathWithinRoot, validateProjectPath, isConfigLeafNode, CONFIG_LEAF_LANGUAGES } from '../utils';
import { isGeneratedFile } from '../extraction/generated-detection';
import { scanDynamicDispatch } from './dynamic-boundaries';
import { getUpdateNotice } from '../upgrade/update-check';
/**
* An expected, recoverable "codegraph can't serve this" condition — most
@@ -4081,6 +4082,14 @@ export class ToolHandler {
);
}
// A newer release exists (#1243) — status is where users and agents look
// when something seems off, so surface the drift here too. Cheap memoized
// cache read; absent entirely when up to date or opted out.
const updateNotice = getUpdateNotice();
if (updateNotice) {
lines.push(`**Update available:** ${updateNotice}`);
}
// Non-zero at rest means a resolution pass was interrupted mid-run, so
// some files' call/impact edges are missing until the next sync sweeps
// the leftovers (#1187). Surface it — an agent trusting an incomplete