fix: Replace fmt.Printf with structured logging in authentication flows #35
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.
Description
Fixes MCP protocol compliance violations in authentication wrapper code where
fmt.Printfwas causing protocol communication issues by writing directly to stdout/stderr. The MCP specification requires structured logging only.Changes
internal/auth/client/wrapper.go: Replaced allfmt.Printfcalls with structured logging usinglog.Infowith proper key-value pairscmd/session/session.go: Fixed to use correctfmt.Printffor CLI output (CLI commands incmd/directory are exempt from MCP logging restrictions)\n), newlines, and trailing punctuation from log messages to follow MCP structured logging patternsWhy This Matters
The MCP specification requires that servers use structured logging only to stderr. Direct output to stdout/stderr via
fmt.Printf,fmt.Println,print, orprintlnbreaks MCP protocol communication.This fix ensures the MCP server's authentication flows properly use structured logging as required, preventing interference with protocol communication.
Type of Change
Testing
Test Results
All unit tests passed successfully:
make testTest Output (All Passed)
Manual Validation
Checklist
make testpassesRelated Issues
Fixes authentication flow logging issues that caused warnings in MCP clients due to protocol violations.
Additional Context
This is part 1 of a 2-part change. Part 2 (separate PR) will add automated enforcement mechanisms (golangci-lint configuration, Makefile checks, and documentation) to prevent future violations.