fix(mcp): silence the daemon-attach log by default (#618)#725
Merged
Conversation
The "Attached to shared daemon" line is benign INFO, but it was written to stderr — and MCP hosts render all server stderr at error level (and append an `undefined` data field), so on every session start a healthy attach showed up as `[error] … undefined`. It is now gated behind CODEGRAPH_MCP_LOG_ATTACH=1: silent by default, opt-in for debugging daemon attach. Both attach sites (runProxy + connectWithHello) route through one helper. The daemon integration tests opt the harness into the log so their attach assertions still observe a successful attach. Re-applies the approach from #640 by @mturac. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Summary
The "Attached to shared daemon" line is benign INFO, but it was written to
process.stderr— and MCP hosts render all server stderr at error level, and append anundefineddata field. So on every session start, a healthy attach to the shared daemon showed up in Claude Code (and others) as[error] [CodeGraph MCP] Attached to shared daemon on … (pid …, v…).followed byundefined. (Theundefinedis the host rendering the bare stderr line — codegraph never emits it.)Fix
Route both attach sites (
runProxy+connectWithHello) through onelogAttachedDaemon()helper gated behindCODEGRAPH_MCP_LOG_ATTACH=1— silent by default, opt-in for debugging. With the line gone, the host has nothing to render, so both the spurious[error]and theundefineddisappear.Tests
daemon-attach-log.test.ts: silent by default; logs only when the env var is1.mcp-daemon.test.ts: the harness now opts into the log so the existing attach assertions still observe a successful attach (a per-test env still wins; theNO_DAEMONnegative assertion is unaffected).Re-applies the approach from #640 by @mturac (closed in favor of this, since #640 had drifted out of date against
main).Closes #618.
🤖 Generated with Claude Code