Update existing MCP configs with required gh-aw server fields#41462
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Error: copilot coding agent is not available for this repository |
|
@copilot run pr-finisher skill |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 5f039f3. I ran the finisher pass, recompiled the two stale smoke lockfiles, and re-ran |
There was a problem hiding this comment.
Pull request overview
This PR updates the gh aw init MCP configuration flow to normalize and repair an existing .github/mcp.json in place, ensuring the github-agentic-workflows MCP server entry includes the required fields (type, command, args, tools) rather than only printing manual update instructions.
Changes:
ensureMCPConfignow updates an existing.github/mcp.jsonin place (including legacyserversconfigs) and skips when already identical.- Adds helpers to select the correct server map (
mcpServersvs legacyservers) and merge required gh-aw server fields while preservingcwd. - Adjusts init messaging from “Created” to “Configured” for
.github/mcp.json, and updates tests and the repo’s.github/mcp.jsonaccordingly.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/mcp_config_file.go | Implements in-place normalization/repair of .github/mcp.json, including legacy key support. |
| pkg/cli/mcp_config_file_test.go | Updates/extends tests to validate create, update, skip, and legacy-update behavior. |
| pkg/cli/init.go | Updates verbose init output to reflect create-or-update semantics (“Configured”). |
| pkg/cli/init_mcp_test.go | Renames/updates test to assert existing MCP config files are updated in place. |
| .github/mcp.json | Updates repo MCP server entry to the normalized gh aw mcp-server form with tools list. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 3
| if err := writeMCPConfigFile(mcpConfigPath, config); err != nil { | ||
| return err | ||
| } | ||
| mcpConfigLog.Printf("Updated existing file: %s", mcpConfigPath) |
| // If the file already exists, it renders console instructions instead of editing | ||
| // ensureMCPConfig creates or updates .github/mcp.json with gh-aw MCP server configuration. | ||
| func ensureMCPConfig(verbose bool) error { | ||
| mcpConfigLog.Print("Creating .github/mcp.json") |
| expectedTools := []string{"compile", "audit", "logs", "inspect", "status", "audit-diff"} | ||
| if len(server.Tools) != len(expectedTools) { | ||
| t.Errorf("Expected tools %v, got %v", expectedTools, server.Tools) | ||
| } | ||
| if server.CWD != "${workspaceFolder}" { | ||
| t.Errorf("Expected cwd to be preserved, got %q", server.CWD) | ||
| } |
Existing
.github/mcp.jsonfiles were not being repaired or upgraded when thegithub-agentic-workflowsentry was missing fields added in newer gh-aw versions. This change updates existing configs in place so the gh-aw MCP server entry consistently includes the required shape, includingtypeandtools.Behavior change
ensureMCPConfignow edits an existing.github/mcp.jsoninstead of only printing manual update instructions.github-agentic-workflowsserver is present but incomplete, the config is normalized to the current required form.gh-aw server normalization
typecommandargstoolscwd) rather than replacing the object wholesale.Config compatibility
serverskey and updates the gh-aw entry there when needed.CLI output
.github/mcp.json” to “Configured.github/mcp.json” to reflect create-or-update behavior.Example
{ "mcpServers": { "github-agentic-workflows": { "command": "gh", "args": ["aw", "mcp-server"], "cwd": "${workspaceFolder}" } } }{ "mcpServers": { "github-agentic-workflows": { "type": "local", "command": "gh", "args": ["aw", "mcp-server"], "tools": ["compile", "audit", "logs", "inspect", "status", "audit-diff"], "cwd": "${workspaceFolder}" } } }