-
Notifications
You must be signed in to change notification settings - Fork 17
Spike: structured CLI output (io.Writer / MCP stdio mode) #279
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem statement
User-visible output is scattered across fmt.Print*, Cobra, the interactive login path, and MCP. Stdio MCP requires a strict contract: stdout = JSON-RPC only; everything else should go to stderr or an injected writer. Violations regress MCP hosts (e.g. "not valid JSON" in the client). Phase 1 fixes the known gateway mcp + Execute() paths; a broader design reduces repeat risk.
Direction to explore
- A small presentation / output boundary, e.g.
UserOutputwithOut,Err io.Writeronconfigorcmd, defaulting toos.Stdout/os.Stderr. - Modes:
TTYvsMCPStdio(orNonInteractive) chosen once per invocation (command leaf, env, or context). Execute()and other high-touch paths useErr(or mode-aware writers) instead of hardcoded stdout for messages when in MCP stdio mode.- Longer term: inventory and migrate direct
fmt.Printwhere protocol safety matters.
Questions for the spike
- How much of the codebase writes non-protocol text to stdout? (grep / inventory)
- Should MCP mode be env-only, command-derived, or both?
- logrus / verbose logging: ensure debug does not hit stdout in MCP.
- Tests: subprocess
gateway mcp+ fake stdin; assert no non-JSON lines on stdout until JSON-RPC (may overlap Phase 1d acceptance tests).
Exit criteria
Close with a short design note + follow-up epic, or won't do with rationale (cost vs. rare footguns).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request