Fix audit MCP tool returning debug logs instead of JSON#16261
Merged
Conversation
Change audit MCP tool from CombinedOutput() to Output() to separate stdout and stderr. This ensures only the JSON output is returned to MCP clients, while debug logs go to stderr where they belong. This matches the pattern used by logs and compile MCP tools. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix audit command to return structured JSON report
Fix audit MCP tool returning debug logs instead of JSON
Feb 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the audit MCP tool where debug logs were being mixed with JSON output, making the output unparseable. The fix changes the output capture method from CombinedOutput() to Output() to properly separate stdout (JSON) from stderr (debug logs).
Changes:
- Modified audit MCP tool to use
Output()instead ofCombinedOutput()for capturing command output - Enhanced error handling to capture stderr separately for better diagnostics
- Added detailed comments explaining the rationale for using separate stdout/stderr capture
- Minor test formatting change (line wrapping)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/cli/mcp_server.go | Changed audit tool from CombinedOutput() to Output() to separate JSON stdout from debug stderr, matching the pattern used by logs and compile tools. Enhanced error handling to capture stderr separately for detailed error reporting. |
| actions/setup/js/log_parser_bootstrap.test.cjs | Formatting change: wrapped long expect statement onto a single line (no functional change) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The audit MCP tool returns unparseable output containing debug logs mixed with JSON instead of clean structured JSON.
Changes
pkg/cli/mcp_server.goCombinedOutput()toOutput()to separate stdout (JSON) from stderr (debug logs)logsandcompileMCP toolsContext
The audit command writes JSON to stdout via
json.NewEncoder(os.Stdout)and debug logs to stderr via the logger package. UsingCombinedOutput()mixed both streams, polluting the JSON output with lines like:Now returns only the JSON object on stdout.
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:
https://api.github.com/repos/github/gh-aw/actions/runs/22080602159/usr/bin/gh gh api repos/{owner}/{repo}/actions/runs/22080602159 --jq {databaseId: .id, number: .run_number, url: .html_url, status: .status, conclusion: .conclusion, workflowName: .name, workflowPath: .path, createdAt: .created_at, startedAt: .run_started_at, updatedAt: .updated_at, event: .event, headBranch: .head_branch,(http block)https://api.github.com/user/usr/bin/gh gh api user --jq .login(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.