Add checks as a first-class MCP tool to the gh-aw MCP server#24757
Add checks as a first-class MCP tool to the gh-aw MCP server#24757
checks as a first-class MCP tool to the gh-aw MCP server#24757Conversation
Exposes `gh aw checks` as an `agentic-workflows` MCP tool so review-style workflows can fetch normalized CI state without shelling out to `gh aw checks`. - pkg/cli/mcp_tools_readonly.go: registerChecksTool calling FetchChecksResult - pkg/cli/mcp_server.go: register checks tool in createMCPServer - pkg/cli/mcp_server_command.go: add checks to Long tool list - docs/…/gh-aw-as-mcp-server.md: document the new checks tool - .github/aw/debug-agentic-workflow.md: add checks to MCP equivalents list Agent-Logs-Url: https://github.com/github/gh-aw/sessions/bad45885-e19c-4193-b686-d4a71933c62e Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
checks as a first-class MCP tool to the gh-aw MCP server
|
@copilot I test an integration test for this new command. Look at our other MP commands are tested. |
Adds TestMCPServer_ChecksToolReturnsValidJSON to mcp_server_json_integration_test.go following the same pattern as the audit/logs tool tests: - missing pr_number → MCP error - valid pr_number without GitHub credentials → graceful error - valid pr_number with credentials → JSON with all ChecksResult fields verified Also adds checks to TestMCPServer_AllToolsReturnContent. Uses strings.HasPrefix for safe prefix checking. Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c5b20c48-dfd4-4ac0-bcb8-d6e8afe3ed14 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added
Also added |
|
Hey Two things need attention before this can land:
If you'd like a hand knocking these out, here's a prompt you can hand off to your coding agent:
|
There was a problem hiding this comment.
Pull request overview
Adds a new read-only MCP tool (checks) to the gh-aw MCP server so workflows can fetch normalized PR CI check state via MCP instead of shelling out to gh aw checks.
Changes:
- Added
checksMCP tool that callsFetchChecksResultand returnsChecksResultas JSON. - Registered
checksin the MCP server and surfaced it in CLI help + docs. - Extended MCP integration tests to include the new tool.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/mcp_tools_readonly.go | Implements registerChecksTool MCP tool returning ChecksResult JSON |
| pkg/cli/mcp_server.go | Registers checks tool during server creation |
| pkg/cli/mcp_server_json_integration_test.go | Adds integration test coverage and includes checks in the all-tools test matrix |
| pkg/cli/mcp_server_command.go | Lists checks in mcp-server --help output |
| docs/src/content/docs/reference/gh-aw-as-mcp-server.md | Documents checks parameters and normalized states |
| .github/aw/debug-agentic-workflow.md | Adds checks to MCP ↔ CLI equivalents list |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 4
| mcpLog.Printf("Executing checks tool: pr_number=%s, repo=%s", args.PRNumber, args.Repo) | ||
|
|
||
| result, err := FetchChecksResult(args.Repo, args.PRNumber) | ||
| if err != nil { | ||
| return nil, nil, newMCPError(jsonrpc.CodeInternalError, "failed to fetch checks", map[string]any{"error": err.Error()}) |
There was a problem hiding this comment.
The PR description claims this tool avoids subprocesses, but FetchChecksResult ultimately shells out to the gh CLI via workflow.ExecGH (checks_command.go:186). If the goal is specifically to avoid calling gh aw checks that’s fine, but the description (and/or tool docs) should be clarified to avoid implying a pure in-process implementation.
| // Register remaining read-only tools | ||
| registerChecksTool(server) | ||
| registerMCPInspectTool(server, execCmd) | ||
|
|
There was a problem hiding this comment.
In createMCPServer, checks is registered after logs/audit registration. Since createMCPServer returns early if registerLogsTool/registerAuditTool fail (e.g., schema generation errors), this read-only tool may never be available even though it doesn’t depend on those privileged tools. Consider registering checks alongside the other read-only tools before any early-return points.
| params := &mcp.CallToolParams{ | ||
| Name: "checks", | ||
| Arguments: map[string]any{ | ||
| "pr_number": "1", |
There was a problem hiding this comment.
This test calls checks with only pr_number while running in a temporary git repo that has no remotes configured. Even if credentials are available, gh api typically can’t resolve the current repository without a remote/--repo, so the “verify JSON structure” branch is effectively unreachable. To actually validate JSON when creds are present, either set a repo remote in setupMCPServerTest or pass a known public repo argument here.
| "pr_number": "1", | |
| "pr_number": "1", | |
| "repo": "cli/cli", |
| if textContent.Text == "" { | ||
| t.Fatal("Expected non-empty text content from checks tool") | ||
| } | ||
|
|
||
| // In test environments without GitHub credentials, an error message is returned | ||
| if strings.HasPrefix(textContent.Text, "Error:") { | ||
| t.Logf("Checks tool returned error message (expected in test environment without GitHub credentials)") | ||
| return | ||
| } | ||
|
|
||
| // If credentials are available, verify JSON structure |
There was a problem hiding this comment.
After session.CallTool succeeds, this test checks for an "Error:" prefix in the returned content. But the checks tool returns failures as an MCP (jsonrpc) error (i.e., via the err return), so this branch should never be hit and may confuse future readers. Consider removing it or adjusting it to match the tool’s actual error-returning behavior.
| if textContent.Text == "" { | |
| t.Fatal("Expected non-empty text content from checks tool") | |
| } | |
| // In test environments without GitHub credentials, an error message is returned | |
| if strings.HasPrefix(textContent.Text, "Error:") { | |
| t.Logf("Checks tool returned error message (expected in test environment without GitHub credentials)") | |
| return | |
| } | |
| // If credentials are available, verify JSON structure | |
| if strings.TrimSpace(textContent.Text) == "" { | |
| t.Fatal("Expected non-empty text content from checks tool") | |
| } | |
| // On success, the checks tool should return structured output; failures are | |
| // reported by session.CallTool via err above. |
The gh-aw MCP server exposed 8 tools but omitted
checks, forcing review workflows to shell out togh aw checks— the one remaining gh-aw-specific bash dependency that breaks on unauthenticated agent runs.Changes
pkg/cli/mcp_tools_readonly.go— AddedregisterChecksTool: acceptspr_number(required) andrepo(optional), callsFetchChecksResultdirectly (no subprocess, same pattern asregisterStatusTool), returns fullChecksResultJSONpkg/cli/mcp_server.go— RegisteredregisterChecksToolincreateMCPServeralongside the other read-only toolspkg/cli/mcp_server_command.go— Addedchecksto the--helptool listdocs/…/gh-aw-as-mcp-server.md— Documentedchecksparameters and normalized states (success,failed,pending,no_checks,policy_blocked).github/aw/debug-agentic-workflow.md— Addedcheckstool →gh aw checksto the MCP equivalents listpkg/cli/mcp_server_json_integration_test.go— AddedTestMCPServer_ChecksToolReturnsValidJSONwith subtests for missingpr_number(expects MCP error) and validpr_number(validates allChecksResultJSON fields when credentials are available, gracefully handles auth errors otherwise); also addedcheckstoTestMCPServer_AllToolsReturnContentUsage
Review workflows can now replace the bash dependency:
The returned
required_statefield is the authoritative CI verdict in repos with optional deployment integrations (Vercel, Netlify) posting commit statuses alongside required CI checks.