Dev/anushakolan/set default log level none#3420
Draft
anushakolan wants to merge 2 commits intomainfrom
Draft
Conversation
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.
PR Description
Why make this change?
Closes #3275 - When
--mcp-stdiois used, control the outputWhen DAB runs as an MCP server with
--mcp-stdio, stdout must be reserved exclusively for JSON-RPC protocol messages. Any log output (even informational) causes MCP clients like Claude Desktop to interpret them as protocol violations, displaying warnings like "Discovered 7 tools" mixed with actual tool discovery results.Related: #3274 - MCP
logging/setLevelmethod not foundWhat is this change?
This PR implements proper output control for MCP stdio mode:
Default log level is
Nonewhen--mcp-stdiois used (no CLI or config override)Output redirection based on log level:
LogLevel.None: Both stdout and stderr →TextWriter.Null(zero output)Log level precedence: CLI
--LogLevel> Configruntime.telemetry.log-level> MCPlogging/setLevel--LogLevelFromConfigflag when config specifies a log levelEarly logging suppression in CLI before Service starts
IsMcpStdioModeflag to suppress CLI's own logging in MCP modeHow was this tested?
mcp.jsonto run DAB with--mcp-stdioLogLevel.None)"log-level": { "default": "Error" }toruntime.telemetry- logs appeared on stderr--LogLevel) takes precedence over configDynamicLogLevelProviderTests(5 tests) - CLI > Config > MCP precedenceStartCommandTests(39 tests) - CLI start command functionalitySample Request(s)
CLI Usage - Default (Zero Output)
With no
log-levelin config, MCP mode produces zero log output.CLI Usage - Config Override
Config file (
dab-config.json):{ "runtime": { "telemetry": { "log-level": { "default": "Warning" } } } }Logs at Warning level appear on stderr; MCP
logging/setLevelrequests are accepted but ignored.CLI Usage - CLI Override (Highest Priority)
Logs at Error level appear on stderr; both config and MCP
logging/setLevelare ignored.MCP logging/setLevel Request
{ "jsonrpc": "2.0", "id": 1, "method": "logging/setLevel", "params": { "level": "info" } }Only changes log level if neither CLI nor config specified a level.