feat(serve): --no-telemetry turns telemetry off for one MCP server entry

A team that shares an MCP config had no way to opt one server entry out of
telemetry without an environment variable, which not every client lets a
shared config set. Issue 1908 asked for a flag.

serve --no-telemetry sets CODEGRAPH_TELEMETRY=0 for the process, the same
chokepoint --no-watch uses for CODEGRAPH_NO_WATCH, so there is no new
telemetry code path: telemetry reads the variable on every check, and the
background daemon a server spawns inherits its environment. A daemon that is
already running keeps its own setting until it exits, which TELEMETRY.md
states; codegraph telemetry off covers every process.

Changes on top of the contributor's commit: the test spawns the server with
the WASM runtime flags, as AGENTS.md requires on Windows (without them the
re-exec'd grandchild keeps the temp dir open past the child's exit), and the
changelog bullet states the limit and credits the author.

Validated with real proxy-to-daemon runs on Windows against opted-in private
homes, reading the telemetry queue each daemon left on exit:
- a flagged client starts the daemon: nothing recorded;
- control, no flag: the tool call is recorded;
- a flagged client joins a running unflagged daemon: its call is recorded,
  the documented limit;
- an unflagged client joins a flagged daemon: nothing recorded;
- codegraph telemetry off with a daemon running: nothing recorded.

Original PR #1923 by @danusha2345.
Fixes #1908

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danusha2345
2026-10-30 19:31:16 +00:00
committed by Colby Mchenry
co-authored by Claude Opus 5.5
parent 7889da6697
commit 47526d2078
4 changed files with 122 additions and 1 deletions
+7 -1
View File
@@ -2349,7 +2349,8 @@ program
.option('-p, --path <path>', 'Project path (optional for MCP mode, uses rootUri from client)')
.option('--mcp', 'Run as MCP server (stdio transport)')
.option('--no-watch', 'Disable the file watcher (no auto-sync; useful on slow filesystems like WSL2 /mnt drives)')
.action(async (options: { path?: string; mcp?: boolean; watch?: boolean }) => {
.option('--no-telemetry', 'Send no usage telemetry from this server (same as CODEGRAPH_TELEMETRY=0)')
.action(async (options: { path?: string; mcp?: boolean; watch?: boolean; telemetry?: boolean }) => {
const projectPath = options.path ? resolveProjectPath(options.path) : undefined;
// Commander sets watch=false when --no-watch is passed. Route it through
@@ -2357,6 +2358,11 @@ program
if (options.watch === false) {
process.env.CODEGRAPH_NO_WATCH = '1';
}
// Same for --no-telemetry (#1908): telemetry reads CODEGRAPH_TELEMETRY on
// every check, and a daemon this server spawns inherits the env.
if (options.telemetry === false) {
process.env.CODEGRAPH_TELEMETRY = '0';
}
try {
if (options.mcp) {