Harden compile MCP stdout handling and add compile stdio pollution coverage#26968
Harden compile MCP stdout handling and add compile stdio pollution coverage#26968
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c9da255d-4104-43e9-8911-088372c96594 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c9da255d-4104-43e9-8911-088372c96594 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c9da255d-4104-43e9-8911-088372c96594 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
| cmdArgs = append(cmdArgs, "--check-secrets") | ||
|
|
||
| // Execute the CLI command | ||
| cmd := execCmd(ctx, cmdArgs...) |
There was a problem hiding this comment.
Done in 51c81e1 — pkg/cli/mcp_tools_readonly.go has been reverted to its pre-change state, and the related stdout-only mcp-inspect test coverage was removed.
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6da62d79-7117-4bea-8f71-476d7ab9e44c Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/a4f38db7-d04e-4612-b5e8-df906de5a0fd Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
Adds regression coverage to ensure the MCP compile tool’s successful responses are sourced from subprocess stdout only, and that the MCP server’s stdio stdout remains JSON-RPC-only during compile calls.
Changes:
- Added a unit test asserting
compileresponses do not include subprocess stderr/log noise on success. - Added an integration test that drives the
mcp-serverover stdio and verifies stdout traffic is valid JSON-RPC andcompileresult text is clean JSON.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/mcp_tools_output_streams_test.go | New unit test to prevent stderr/log pollution in successful compile tool output |
| pkg/cli/mcp_server_stdio_integration_test.go | New integration test validating MCP stdio stdout remains JSON-RPC-only while calling compile |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
| func mockCommandWithOutput(stdoutText, stderrText string) execCmdFunc { | ||
| return func(ctx context.Context, args ...string) *exec.Cmd { | ||
| script := fmt.Sprintf("printf %q; printf %q 1>&2", stdoutText, stderrText) | ||
| return exec.CommandContext(ctx, "sh", "-c", script) | ||
| } |
| } | ||
| defer func() { | ||
| _ = stdin.Close() |
🧪 Test Quality Sentinel ReportTest Quality Score: 100/100✅ Excellent test quality
Test Classification Details
Per-Test Analysis📋 Detailed test analysis✅
|
…tics Generated by Design Decision Gate to document the architectural decision that the compile MCP tool must source success responses exclusively from subprocess stdout, with stderr reserved for diagnostics. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Commit pushed:
|
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (229 new lines in AI has analyzed the PR diff and generated a draft ADR to help you get started: 📄 Draft ADR: The draft captures the key design decision embedded in this PR: the What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision. Why ADRs Matter
ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
References: §24594338493
|
|
@copilot review all comments |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/e4f0478b-70ee-4aea-a26a-440476876a8b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 4af17a2 — I addressed the open review items: made the shell-based stdout/stderr test helper POSIX-safe (no Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
compiletool handling to keep successful tool content sourced from subprocess stdout onlycompilefor all workflowscompiletool responsesChanges
compiletool behavior using stdout-only success output semanticsmcp_tools_management.gochanges per review feedback (soadd,update, andfixstream handling remains unchanged)mcp_tools_readonly.gochanges per review feedback (somcp-inspectstream handling remains unchanged)pkg/cli/mcp_tools_output_streams_test.go:TestCompileTool_UsesOnlyStdoutOnSuccesspkg/cli/mcp_server_stdio_integration_test.go:TestMCPServer_CompileAllWorkflows_StdoutOnlyJSONRPCValidation
go test -v ./pkg/cli -run 'TestCompileTool_UsesOnlyStdoutOnSuccess'go test -v -tags=integration ./pkg/cli -run 'TestMCPServer_CompileAllWorkflows_StdoutOnlyJSONRPC'make agent-finish; failures observed are pre-existing/unrelated in this environment (pkg/clitimeout in full suite andpkg/workflowwasm golden failures).