Skip to content

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Feb 3, 2026

The MCP server's status tool was spawning a subprocess to execute gh aw status --json, adding unnecessary overhead and complexity.

Changes

  • Extracted GetWorkflowStatuses() function: Core logic for retrieving workflow status data, returns []WorkflowStatus for programmatic use
  • Refactored StatusWorkflows(): Now calls GetWorkflowStatuses() internally, eliminated ~200 lines of duplicated code between JSON and text output paths
  • Updated MCP server: Replaced subprocess invocation with direct function call to GetWorkflowStatuses()

Benefits

  • Simpler: No subprocess management or stderr parsing
  • Faster: Direct in-process function call vs process spawning
  • Better errors: Native Go error types instead of string parsing

Example

Before:

// MCP server spawned subprocess
cmd := execCmd(ctx, "status", "--json")
output, err := cmd.CombinedOutput()

After:

// Direct function call
statuses, err := GetWorkflowStatuses(pattern, "", "", "")
jsonBytes, _ := json.Marshal(statuses)

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
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha --abbrev-ref HEAD /usr/bin/base64 (http block)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 1759396/b121/vet.cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path prune -f /usr/bin/base64 ":"claude/refac (http block)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion (http block)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo (http block)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name go HEAD x_amd64/vet (http block)
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login go (http block)
    • Triggering command: /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

Refactor the mcp-server status tool to call into the "status" command directly instead of running a subprocess.

Determine the best implementation strategy to avoid concurrency issues, simplicity and speed.

- 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>
@Claude Claude AI changed the title [WIP] Refactor mcp-server status tool to call status command directly Refactor MCP server status tool to call GetWorkflowStatuses directly Feb 3, 2026
@Claude Claude AI requested a review from pelikhan February 3, 2026 13:38
@pelikhan pelikhan marked this pull request as ready for review February 3, 2026 13:40
Copilot AI review requested due to automatic review settings February 3, 2026 13:40
@pelikhan pelikhan added the smoke label Feb 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

💀 Blimey! Changeset Generator was cancelled and walked the plank! No treasure today, matey! ☠️

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

Agent Container Tool Check

Tool Status Version
bash GNU bash 5.2.21
sh available
git 2.52.0
jq 1.7
yq 4.50.1
curl 8.5.0
gh 2.86.0
node 24.13.0
python3 3.13.11
go 1.24.12
java NOT FOUND
dotnet NOT FOUND

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.

AI generated by Agent Container Smoke Test

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

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

@pelikhan

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

PR titles: Refactor MCP server status tool to call GetWorkflowStatuses directly; Consolidate changeset processing into release workflow and simplify changeset.js
GitHub MCP ✅ | safeinputs-gh ✅
Serena activate ✅ | Playwright ❌ (tool missing)
Tavily search ✅ | File write+cat ✅
Discussion query+comment ✅ | Build ✅
Overall: FAIL

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 reuse GetWorkflowStatuses() and centralize JSON/text output handling.
  • Updated MCP server status tool to call GetWorkflowStatuses() 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 runs gh commands via workflow.ExecGH (no context), so a cancelled MCP request may continue running. Consider threading ctx through (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.

@pelikhan pelikhan merged commit b99f00a into main Feb 3, 2026
170 of 171 checks passed
@pelikhan pelikhan deleted the claude/refactor-mcp-server-status-tool branch February 3, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants