fix(cli): gate mcp-dev-wrapper debug stderr behind env flag#38
Open
smorchj wants to merge 1 commit intonitrocloudofficial:mainfrom
Open
fix(cli): gate mcp-dev-wrapper debug stderr behind env flag#38smorchj wants to merge 1 commit intonitrocloudofficial:mainfrom
smorchj wants to merge 1 commit intonitrocloudofficial:mainfrom
Conversation
Closes nitrocloudofficial#15 Hot-reload notices, the SSE log-server banner, and the per-restart messages are useful when debugging the wrapper itself but pollute stderr during normal stdio MCP development. Add a DEBUG_ENABLED constant gated on either: NITROSTACK_DEBUG=1 DEBUG=nitrostack (or any value containing 'nitrostack') A new debug() helper routes informational lines through console.error only when the flag is set. Real failures (spawn errors, the consecutive-failure bail-out, unhandled rejections, the usage line, server.on('error')) still go to stderr unconditionally. Verified the build output: 6 unconditional console.error calls remain (real failures), 10 calls now route through debug().
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 #15
Summary
mcp-dev-wrappercurrently writes hot-reload notices, the SSE log-server banner, and per-restart messages to stderr unconditionally. That's noisy when debugging stdio MCP, where stderr is the only signal channel you actually want to read.This PR gates all informational logs behind an env flag while keeping real failures unconditional.
Changes
Single file:
typescript/packages/cli/src/mcp-dev-wrapper.tsDEBUG_ENABLEDconstant computed once at module load:Both forms are supported so users coming from the broader Node ecosystem can use the standard
DEBUG=nitrostackpattern, whileNITROSTACK_DEBUG=1is the canonical short form.Add a
debug(...args)helper that routes throughconsole.erroronly when the flag is set.Replace 10 informational
console.errorcalls withdebug():Log streaming server running at ...bannerMCP_SERVER_PORT is ...debug lineServer exited with code N (attempt N/M), restarting...(non-fatal restart)Server exited with code N, restarting...(clean exit)Changes detected, restarting server...Server restarted successfullyFile changed: ...File added: ...Shutting down...Keep these on unconditional
console.error:Server failed N times in a row. Giving up.(consecutive-failure bail-out)Server error: ...frommcpProcess.on('error')run().catch()Testing
npm run buildpasses with no TypeScript errorsconsole.errorcalls remain (real failures), 10 calls now route throughdebug()NITROSTACK_DEBUG=1set, behavior is identical to beforeAcceptance criteria
MCP_SERVER_PORT) behindNITROSTACK_DEBUGorDEBUGnamespace