Refactor MCP server status tool to call GetWorkflowStatuses directly#13491
Refactor MCP server status tool to call GetWorkflowStatuses directly#13491
Conversation
- Extracted core status logic into GetWorkflowStatuses function - Refactored StatusWorkflows to call GetWorkflowStatuses - Updated MCP server status tool to call GetWorkflowStatuses directly instead of spawning subprocess - Added tests for GetWorkflowStatuses function - Eliminated code duplication between JSON and text output paths - Improved simplicity and speed by removing subprocess overhead - No concurrency issues since all operations are synchronous Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
💀 Blimey! Changeset Generator was cancelled and walked the plank! No treasure today, matey! ☠️ |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
Agent Container Tool Check
Result: 10/12 tools available ❌ Status: FAIL - Java and .NET runtimes are not installed in the agent container. Core tools (bash, git, jq, yq, curl, gh, node, python3, go) are all available and working correctly.
|
|
Smoke Test Results (Run §21632510111) ✅ GitHub MCP | ✅ Safe Inputs GH | ✅ Serena MCP | ❌ Playwright | ✅ File Write | ✅ Bash | ✅ Discussion | ✅ Build | ✅ Dispatch Status: FAIL (8/9 passed) Note: Playwright MCP tools unavailable in execution context
|
|
PR titles: Refactor MCP server status tool to call GetWorkflowStatuses directly; Consolidate changeset processing into release workflow and simplify changeset.js
|
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
There was a problem hiding this comment.
Pull request overview
Refactors the MCP server’s status tool to avoid spawning a subprocess by calling the status-collection logic directly from Go code.
Changes:
- Extracted workflow status collection into a new exported
GetWorkflowStatuses()helper for programmatic consumers. - Refactored
StatusWorkflows()to reuseGetWorkflowStatuses()and centralize JSON/text output handling. - Updated MCP server
statustool to callGetWorkflowStatuses()and then apply optional jq filtering.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| pkg/cli/status_command.go | Introduces GetWorkflowStatuses() and reworks StatusWorkflows() to use it. |
| pkg/cli/mcp_server.go | Switches MCP status tool from subprocess execution to direct function call + JSON marshal. |
| pkg/cli/status_mcp_integration_test.go | Adds tests intended to validate MCP-oriented JSON shape and pattern filtering. |
Comments suppressed due to low confidence (1)
pkg/cli/mcp_server.go:173
- By switching from
execCmd(ctx, ...)to GetWorkflowStatuses, the status tool loses request-scoped cancellation/timeout propagation. GetWorkflowStatuses ultimately runsghcommands via workflow.ExecGH (no context), so a cancelled MCP request may continue running. Consider threadingctxthrough (e.g., GetWorkflowStatuses(ctx, ...) + workflow.ExecGHContext) so status calls can be aborted cleanly.
// Call GetWorkflowStatuses directly instead of spawning subprocess
statuses, err := GetWorkflowStatuses(args.Pattern, "", "", "")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The MCP server's
statustool was spawning a subprocess to executegh aw status --json, adding unnecessary overhead and complexity.Changes
GetWorkflowStatuses()function: Core logic for retrieving workflow status data, returns[]WorkflowStatusfor programmatic useStatusWorkflows(): Now callsGetWorkflowStatuses()internally, eliminated ~200 lines of duplicated code between JSON and text output pathsGetWorkflowStatuses()Benefits
Example
Before:
After:
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/graphql/usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name 64/pkg/tool/linux_amd64/vet(http block)/usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name 64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o 64/pkg/tool/linuTest User 1759�� eutil.go eutil_test.go 64/pkg/tool/linux_amd64/compile --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/compile(http block)/usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name 64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/vet 1759�� ache/go/1.25.0/x64/src/os/user -buildtags .cfg -errorsas -ifaceassert -nilfunc 1759396/b154/_x002.o(http block)https://api.github.com/repos/actions/checkout/git/ref/tags/v6/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -unreachable=false .cfg 64/pkg/tool/linux_amd64/vet(http block)/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha 2659381152/.github/workflows .cfg 64/pkg/tool/linux_amd64/vet ctor --64 E=3 64/pkg/tool/linux_amd64/vet 1759�� y 1759396/b248/ cal/bin/as --gdwarf-5 --64 -o /usr/libexec/gcc/x86_64-linux-gnu/13/cc1(http block)/usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -unreachable=false .cfg 64/pkg/tool/linux_amd64/compile(http block)https://api.github.com/repos/actions/github-script/git/ref/tags/v8/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha d HEAD 64/pkg/tool/linu-o(http block)/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha --abbrev-ref HEAD /usr/bin/base64(http block)/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha go HEAD /usr/bin/base64(http block)https://api.github.com/repos/actions/github-script/git/ref/tags/v8.0.0/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8.0.0 --jq .object.sha checker.md .cfg 64/pkg/tool/linux_amd64/vet(http block)/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8.0.0 --jq .object.sha ut-1779192219.c .cfg 64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/vet 1759�� /tmp/go-build1191759396/b376/_pkg_.a 1759396/b248/ bin/as -p github.com/aymanrev-parse -lang=go1.23 gcc(http block)/usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8.0.0 --jq .object.sha ify@v1.11.1/require/doc.go ify@v1.11.1/require/forward_requirements.go At,event,headBranch,headSha,displayTitle(http block)https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v6.0.0/usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v6.0.0 --jq .object.sha 03.o .cfg 64/pkg/tool/linux_amd64/vet(http block)/usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v6.0.0 --jq .object.sha 2659381152/.github/workflows .cfg At,event,headBranch,headSha,displayTitle --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/vet 1759��(http block)/usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v6.0.0 --jq .object.sha 3/001/test-frontmatter-with-arrays.md .cfg 64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/vet 1759�� ache/go/1.25.0/x64/src/os/user -I ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet(http block)https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts/usr/bin/gh gh run download 1 --dir test-logs/run-1 1759396/b248/ 64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/vet 1759�� ache/go/1.25.0/x64/src/os/user -I 64/pkg/tool/linux_amd64/compile --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/compile(http block)/usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env blog-auditor.md GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go(http block)/usr/bin/gh gh run download 1 --dir test-logs/run-1 go /usr/bin/gh -json GO111MODULE At,event,headBra--show-toplevel gh api ithub-script/git/ref/tags/v8 --jq /usr/bin/gh -json GO111MODULE ache/go/1.25.0/x--show-toplevel gh(http block)https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts/usr/bin/gh gh run download 12345 --dir test-logs/run-12345 1759396/b248/ 64/pkg/tool/linux_amd64/vet -pthread -Wl,--no-gc-sectrev-parse -fmessage-length--show-toplevel 64/pkg/tool/linux_amd64/vet 1759�� ache/go/1.25.0/x64/src/os/user -buildtags ps -errorsas -ifaceassert -nilfunc ps(http block)/usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env auto-triage-issues.md GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go(http block)/usr/bin/gh gh run download 12345 --dir test-logs/run-12345 nly /usr/bin/gh -json GO111MODULE ache/go/1.25.0/x--show-toplevel gh api ithub-script/git/ref/tags/v8 --jq /usr/bin/gh -json GO111MODULE ache/go/1.25.0/x--show-toplevel gh(http block)https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts/usr/bin/gh gh run download 12346 --dir test-logs/run-12346 1759396/b121/vet.cfg 64/pkg/tool/linux_amd64/vet(http block)/usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go(http block)/usr/bin/gh gh run download 12346 --dir test-logs/run-12346 go(http block)https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts/usr/bin/gh gh run download 2 --dir test-logs/run-2 1759396/b248/ 64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/vet 1759�� ache/go/1.25.0/x64/src/os/user ormatting.go 64/pkg/tool/linux_amd64/compile --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/compile(http block)/usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go(http block)/usr/bin/gh gh run download 2 --dir test-logs/run-2 remote.origin.url(http block)https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts/usr/bin/gh gh run download 3 --dir test-logs/run-3 1759396/b248/ 64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/vet 1759�� _test.go .cfg 64/pkg/tool/linux_amd64/compile --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/compile(http block)/usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env blog-auditor.md GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go(http block)/usr/bin/gh gh run download 3 --dir test-logs/run-3 rev-parse /usr/bin/gh -json GO111MODULE ache/go/1.25.0/x--show-toplevel gh api 2358033451 or a null string otherwise { printf "%s%s", /usr/bin/gh -json GO111MODULE ache/go/1.25.0/x--git-dir gh(http block)https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts/usr/bin/gh gh run download 4 --dir test-logs/run-4 1759396/b248/ x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet 1759�� /opt/hostedtoolcache/go/1.25.0/x64/src/runtime/c-p 1759396/b248/ 64/pkg/tool/linux_amd64/link --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/link(http block)/usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env brave.md GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go(http block)/usr/bin/gh gh run download 4 --dir test-logs/run-4 config(http block)https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts/usr/bin/gh gh run download 5 --dir test-logs/run-5 1759396/b248/ 64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/vet 1759�� /opt/hostedtoolcache/go/1.25.0/x64/src/runtime/c-p .cfg util.test --gdwarf-5 --64 -o util.test(http block)/usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go(http block)/usr/bin/gh gh run download 5 --dir test-logs/run-5 --jq 64/bin/git -json GO111MODULE At,event,headBra--show-toplevel gh api ithub-script/git/ref/tags/v8 or a null string otherwise { printf "%s%s", /usr/bin/gh -json GO111MODULE ache/go/1.25.0/x--git-dir gh(http block)https://api.github.com/repos/github/gh-aw/actions/workflows/usr/bin/gh gh workflow list --json name,state,path prune -f /usr/bin/base64 ":"claude/refac(http block)/usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100(http block)/usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 -Wl,--no-gc-sectrev-parse -fmessage-length--show-toplevel 64/pkg/tool/linux_amd64/vet 1759�� /opt/hostedtoolcache/go/1.25.0/x64/src/runtime/c-errorsas .cfg /x86_64-linux-gnu/13/cc1 --gdwarf-5 --64 -o /x86_64-linux-gnu/13/cc1(http block)https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0/usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha erate-action-metadata/main.go GO111MODULE 64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/link env aw.test GO111MODULE 0/x64/bin/node GOINSECURE GOMOD GOMODCACHE PIpJM-h_YvX3udS3pk/XBKAMvg_HJ8VrKjXklwd/xG3AbuhJksKd5jjj_WAy(http block)https://api.github.com/repos/nonexistent/repo/actions/runs/12345/usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion(http block)/usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE go env erate-action-metadata/main.go GO111MODULE 64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/link(http block)/usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion -json GO111MODULE ache/go/1.25.0/x64/bin/go infocmp -1 REDACTED go(http block)https://api.github.com/repos/owner/repo/actions/workflows/usr/bin/gh gh workflow list --json name,state,path --repo owner/repo(http block)/usr/bin/gh gh workflow list --repo owner/repo --json name,path,state Name,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --gdwarf-5 --64 -o 64/pkg/tool/linux_amd64/compile 1759�� g_.a -I rgo/bin/as --gdwarf-5 tants -o as(http block)/usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/xHEAD env 6963845/b359/_pkGOSUMDB GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go(http block)https://api.github.com/repos/test-owner/test-repo/actions/secrets/usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name go HEAD x_amd64/vet(http block)/usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name d/gh-aw/main.go GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/xHEAD env 6963845/b344/_pkGOSUMDB GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go(http block)/usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name --show-toplevel ache/go/1.25.0/xHEAD [i] !~ /^[0-9]+$/) exit(2); if (a[i] < b[i]) exit(3); else if (a[i] > b[i]) exit(0) 6963845/b377/_pkgit GO111MODULE 64/bin/go git conf�� user.name Test User /usr/bin/git yZOI/p9TIjHsMG8Lbase64 GO111MODULE 64/bin/go git(http block)https://api.github.com/user/usr/bin/gh gh api user --jq .login(http block)/usr/bin/gh gh api user --jq .login go(http block)/usr/bin/gh gh api user --jq .login -m Initial commit(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt