From e356af94939d3d56569bd9e39e61ef7c52bb5415 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Apr 2026 00:59:57 +0000 Subject: [PATCH 1/6] Initial plan From 7770361ef7f3778231479ebc8c2386bb45036d29 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Apr 2026 01:30:26 +0000 Subject: [PATCH 2/6] fix: remove invalid repository-level .mcp.json Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5f57f095-1b2e-444f-82bd-1e2b7fd6066b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .mcp.json | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .mcp.json diff --git a/.mcp.json b/.mcp.json deleted file mode 100644 index 01021df64d9..00000000000 --- a/.mcp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "servers": { - "github-agentic-workflows": { - "command": "gh", - "args": ["aw", "mcp-server"] - } - } -} From bb2ea4ced05495b379e15be6200c5cd83be8e1c9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Apr 2026 01:58:20 +0000 Subject: [PATCH 3/6] Plan: update mcp config format for Claude Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5a922218-3dfb-40cd-b1b5-b260b7f9df72 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .mcp.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .mcp.json diff --git a/.mcp.json b/.mcp.json new file mode 100644 index 00000000000..96e7285c803 --- /dev/null +++ b/.mcp.json @@ -0,0 +1,11 @@ +{ + "servers": { + "github-agentic-workflows": { + "command": "gh", + "args": [ + "aw", + "mcp-server" + ] + } + } +} \ No newline at end of file From d6a5faf05c71017f2c855058d50bacbdb376a4ab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Apr 2026 02:11:38 +0000 Subject: [PATCH 4/6] fix: use Claude-compatible mcpServers in .mcp.json Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5a922218-3dfb-40cd-b1b5-b260b7f9df72 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .mcp.json | 9 +++---- .../docs/reference/gh-aw-as-mcp-server.md | 2 +- pkg/cli/mcp_config_file.go | 7 +++--- pkg/cli/mcp_config_file_test.go | 25 ++++++++++++++----- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.mcp.json b/.mcp.json index 96e7285c803..9ca83b55e03 100644 --- a/.mcp.json +++ b/.mcp.json @@ -1,11 +1,8 @@ { - "servers": { + "mcpServers": { "github-agentic-workflows": { "command": "gh", - "args": [ - "aw", - "mcp-server" - ] + "args": ["aw", "mcp-server"] } } -} \ No newline at end of file +} diff --git a/docs/src/content/docs/reference/gh-aw-as-mcp-server.md b/docs/src/content/docs/reference/gh-aw-as-mcp-server.md index 24c4b0b2255..e4c81f181aa 100644 --- a/docs/src/content/docs/reference/gh-aw-as-mcp-server.md +++ b/docs/src/content/docs/reference/gh-aw-as-mcp-server.md @@ -72,7 +72,7 @@ Alternatively, create `.mcp.json` manually: ```json wrap { - "servers": { + "mcpServers": { "github-agentic-workflows": { "command": "gh", "args": ["aw", "mcp-server"] diff --git a/pkg/cli/mcp_config_file.go b/pkg/cli/mcp_config_file.go index d9ff14b77e1..803dc904692 100644 --- a/pkg/cli/mcp_config_file.go +++ b/pkg/cli/mcp_config_file.go @@ -21,9 +21,10 @@ type VSCodeMCPServer struct { CWD string `json:"cwd,omitempty"` } -// MCPConfig represents the structure of mcp.json +// MCPConfig represents the structure of .mcp.json for Claude Code. type MCPConfig struct { - Servers map[string]VSCodeMCPServer `json:"servers"` + Servers map[string]VSCodeMCPServer `json:"mcpServers,omitempty"` + LegacyServers map[string]VSCodeMCPServer `json:"servers,omitempty"` } // ensureMCPConfig creates .mcp.json with gh-aw MCP server configuration @@ -98,7 +99,7 @@ func renderMCPConfigUpdateInstructions(filePath, serverName string, serverConfig "Existing file detected: "+filePath) fmt.Fprintln(os.Stderr) fmt.Fprintln(os.Stderr, "To enable GitHub Copilot Agent MCP server integration, please add the following") - fmt.Fprintln(os.Stderr, "to the \"servers\" section of your .mcp.json file:") + fmt.Fprintln(os.Stderr, "to the \"mcpServers\" section of your .mcp.json file:") fmt.Fprintln(os.Stderr) // Generate the JSON to add diff --git a/pkg/cli/mcp_config_file_test.go b/pkg/cli/mcp_config_file_test.go index 68aa78e2e1a..a06625680df 100644 --- a/pkg/cli/mcp_config_file_test.go +++ b/pkg/cli/mcp_config_file_test.go @@ -189,7 +189,7 @@ func TestMCPConfigParsing(t *testing.T) { { name: "valid config with single server", jsonData: `{ - "servers": { + "mcpServers": { "test-server": { "command": "node", "args": ["server.js"] @@ -202,7 +202,7 @@ func TestMCPConfigParsing(t *testing.T) { { name: "valid config with CWD", jsonData: `{ - "servers": { + "mcpServers": { "test-server": { "command": "gh", "args": ["aw", "mcp-server"], @@ -215,14 +215,27 @@ func TestMCPConfigParsing(t *testing.T) { }, { name: "invalid JSON", - jsonData: `{"servers": invalid}`, + jsonData: `{"mcpServers": invalid}`, wantErr: true, wantValid: false, }, { name: "empty config", jsonData: `{ - "servers": {} + "mcpServers": {} + }`, + wantErr: false, + wantValid: true, + }, + { + name: "legacy config key", + jsonData: `{ + "servers": { + "test-server": { + "command": "node", + "args": ["server.js"] + } + } }`, wantErr: false, wantValid: true, @@ -240,8 +253,8 @@ func TestMCPConfigParsing(t *testing.T) { } if !tt.wantErr && tt.wantValid { - if config.Servers == nil { - t.Error("Expected servers map to be initialized") + if config.Servers == nil && config.LegacyServers == nil { + t.Error("Expected mcpServers or legacy servers map to be initialized") } } }) From 69f27f025257df133a8b9291c9dacd94cb64142f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Apr 2026 02:24:16 +0000 Subject: [PATCH 5/6] refactor: clarify MCPConfig field names and legacy parsing Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5a922218-3dfb-40cd-b1b5-b260b7f9df72 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/init_mcp_test.go | 10 ++++---- pkg/cli/mcp_config_file.go | 10 ++++---- pkg/cli/mcp_config_file_test.go | 42 ++++++++++++++++++--------------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/pkg/cli/init_mcp_test.go b/pkg/cli/init_mcp_test.go index 982dca422af..7eedc8d98e1 100644 --- a/pkg/cli/init_mcp_test.go +++ b/pkg/cli/init_mcp_test.go @@ -93,11 +93,11 @@ func TestInitRepository_WithMCP(t *testing.T) { t.Fatalf("Failed to parse .mcp.json: %v", err) } - if _, exists := config.Servers["github-agentic-workflows"]; !exists { + if _, exists := config.MCPServers["github-agentic-workflows"]; !exists { t.Errorf("Expected .mcp.json to contain github-agentic-workflows server") } - server := config.Servers["github-agentic-workflows"] + server := config.MCPServers["github-agentic-workflows"] if server.Command != "gh" { t.Errorf("Expected command to be 'gh', got %s", server.Command) } @@ -178,7 +178,7 @@ func TestEnsureMCPConfig_RendersInstructions(t *testing.T) { // Create initial .mcp.json with a different server initialConfig := MCPConfig{ - Servers: map[string]VSCodeMCPServer{ + MCPServers: map[string]VSCodeMCPServer{ "other-server": { Command: "other-command", Args: []string{"arg1"}, @@ -208,12 +208,12 @@ func TestEnsureMCPConfig_RendersInstructions(t *testing.T) { } // Check that other-server still exists - if _, exists := config.Servers["other-server"]; !exists { + if _, exists := config.MCPServers["other-server"]; !exists { t.Errorf("Expected existing 'other-server' to be preserved") } // Check that github-agentic-workflows was NOT added (file should not be modified) - if _, exists := config.Servers["github-agentic-workflows"]; exists { + if _, exists := config.MCPServers["github-agentic-workflows"]; exists { t.Errorf("Expected 'github-agentic-workflows' server to NOT be added (should render instructions instead)") } } diff --git a/pkg/cli/mcp_config_file.go b/pkg/cli/mcp_config_file.go index 803dc904692..e3d2b52163d 100644 --- a/pkg/cli/mcp_config_file.go +++ b/pkg/cli/mcp_config_file.go @@ -23,8 +23,8 @@ type VSCodeMCPServer struct { // MCPConfig represents the structure of .mcp.json for Claude Code. type MCPConfig struct { - Servers map[string]VSCodeMCPServer `json:"mcpServers,omitempty"` - LegacyServers map[string]VSCodeMCPServer `json:"servers,omitempty"` + MCPServers map[string]VSCodeMCPServer `json:"mcpServers,omitempty"` + Servers map[string]VSCodeMCPServer `json:"servers,omitempty"` } // ensureMCPConfig creates .mcp.json with gh-aw MCP server configuration @@ -52,7 +52,7 @@ func ensureMCPConfig(verbose bool) error { } // Check if the server is already configured correctly - if existingConfig, exists := config.Servers[ghAwServerName]; exists { + if existingConfig, exists := config.MCPServers[ghAwServerName]; exists { existingJSON, _ := json.Marshal(existingConfig) newJSON, _ := json.Marshal(ghAwConfig) if string(existingJSON) == string(newJSON) { @@ -73,9 +73,9 @@ func ensureMCPConfig(verbose bool) error { // File doesn't exist - create it mcpConfigLog.Print("No existing config found, creating new one") config := MCPConfig{ - Servers: make(map[string]VSCodeMCPServer), + MCPServers: make(map[string]VSCodeMCPServer), } - config.Servers[ghAwServerName] = ghAwConfig + config.MCPServers[ghAwServerName] = ghAwConfig // Write config file with proper indentation data, err := json.MarshalIndent(config, "", " ") diff --git a/pkg/cli/mcp_config_file_test.go b/pkg/cli/mcp_config_file_test.go index a06625680df..437ad11b235 100644 --- a/pkg/cli/mcp_config_file_test.go +++ b/pkg/cli/mcp_config_file_test.go @@ -23,10 +23,10 @@ func TestEnsureMCPConfig(t *testing.T) { verbose: false, wantErr: false, validateContent: func(t *testing.T, config *MCPConfig) { - if config.Servers == nil { - t.Error("Expected servers map to be initialized") + if config.MCPServers == nil { + t.Error("Expected mcpServers map to be initialized") } - server, exists := config.Servers["github-agentic-workflows"] + server, exists := config.MCPServers["github-agentic-workflows"] if !exists { t.Error("Expected github-agentic-workflows server to exist") } @@ -41,7 +41,7 @@ func TestEnsureMCPConfig(t *testing.T) { { name: "renders instructions for existing config without gh-aw server", existingConfig: &MCPConfig{ - Servers: map[string]VSCodeMCPServer{ + MCPServers: map[string]VSCodeMCPServer{ "other-server": { Command: "node", Args: []string{"server.js"}, @@ -52,14 +52,14 @@ func TestEnsureMCPConfig(t *testing.T) { wantErr: false, validateContent: func(t *testing.T, config *MCPConfig) { // File should NOT be modified - should remain with only 1 server - if len(config.Servers) != 1 { - t.Errorf("Expected 1 server (file should not be modified), got %d", len(config.Servers)) + if len(config.MCPServers) != 1 { + t.Errorf("Expected 1 server (file should not be modified), got %d", len(config.MCPServers)) } - if _, exists := config.Servers["other-server"]; !exists { + if _, exists := config.MCPServers["other-server"]; !exists { t.Error("Expected existing other-server to be preserved") } // gh-aw server should NOT be added (instructions rendered instead) - if _, exists := config.Servers["github-agentic-workflows"]; exists { + if _, exists := config.MCPServers["github-agentic-workflows"]; exists { t.Error("Expected github-agentic-workflows server to NOT be added (instructions should be rendered)") } }, @@ -67,7 +67,7 @@ func TestEnsureMCPConfig(t *testing.T) { { name: "skips update when config is identical", existingConfig: &MCPConfig{ - Servers: map[string]VSCodeMCPServer{ + MCPServers: map[string]VSCodeMCPServer{ "github-agentic-workflows": { Command: "gh", Args: []string{"aw", "mcp-server"}, @@ -77,15 +77,15 @@ func TestEnsureMCPConfig(t *testing.T) { verbose: false, wantErr: false, validateContent: func(t *testing.T, config *MCPConfig) { - if len(config.Servers) != 1 { - t.Errorf("Expected 1 server, got %d", len(config.Servers)) + if len(config.MCPServers) != 1 { + t.Errorf("Expected 1 server, got %d", len(config.MCPServers)) } }, }, { name: "renders instructions for existing config with different settings", existingConfig: &MCPConfig{ - Servers: map[string]VSCodeMCPServer{ + MCPServers: map[string]VSCodeMCPServer{ "github-agentic-workflows": { Command: "old-command", Args: []string{"old-arg"}, @@ -96,7 +96,7 @@ func TestEnsureMCPConfig(t *testing.T) { wantErr: false, validateContent: func(t *testing.T, config *MCPConfig) { // File should NOT be modified - old settings should remain - server := config.Servers["github-agentic-workflows"] + server := config.MCPServers["github-agentic-workflows"] if server.Command != "old-command" { t.Errorf("Expected command to remain 'old-command' (file should not be modified), got %q", server.Command) } @@ -253,8 +253,12 @@ func TestMCPConfigParsing(t *testing.T) { } if !tt.wantErr && tt.wantValid { - if config.Servers == nil && config.LegacyServers == nil { - t.Error("Expected mcpServers or legacy servers map to be initialized") + if tt.name == "legacy config key" { + if config.Servers == nil { + t.Error("Expected legacy servers map to be initialized") + } + } else if config.MCPServers == nil { + t.Error("Expected mcpServers map to be initialized") } } }) @@ -265,7 +269,7 @@ func TestMCPConfigJSONMarshaling(t *testing.T) { t.Parallel() config := MCPConfig{ - Servers: map[string]VSCodeMCPServer{ + MCPServers: map[string]VSCodeMCPServer{ "github-agentic-workflows": { Command: "gh", Args: []string{"aw", "mcp-server"}, @@ -286,11 +290,11 @@ func TestMCPConfigJSONMarshaling(t *testing.T) { } // Verify structure - if len(unmarshaledConfig.Servers) != 1 { - t.Errorf("Expected 1 server, got %d", len(unmarshaledConfig.Servers)) + if len(unmarshaledConfig.MCPServers) != 1 { + t.Errorf("Expected 1 server, got %d", len(unmarshaledConfig.MCPServers)) } - server, exists := unmarshaledConfig.Servers["github-agentic-workflows"] + server, exists := unmarshaledConfig.MCPServers["github-agentic-workflows"] if !exists { t.Fatal("Expected github-agentic-workflows server to exist") } From 3bb6c07fa1de069bb3fe46b8994900c734f1072d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Apr 2026 02:25:10 +0000 Subject: [PATCH 6/6] test: tighten legacy mcp config assertions Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5a922218-3dfb-40cd-b1b5-b260b7f9df72 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/mcp_config_file.go | 3 ++- pkg/cli/mcp_config_file_test.go | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/cli/mcp_config_file.go b/pkg/cli/mcp_config_file.go index e3d2b52163d..2ee4f87d864 100644 --- a/pkg/cli/mcp_config_file.go +++ b/pkg/cli/mcp_config_file.go @@ -24,7 +24,8 @@ type VSCodeMCPServer struct { // MCPConfig represents the structure of .mcp.json for Claude Code. type MCPConfig struct { MCPServers map[string]VSCodeMCPServer `json:"mcpServers,omitempty"` - Servers map[string]VSCodeMCPServer `json:"servers,omitempty"` + // Servers is a legacy key kept for backward-compatible reads of existing .mcp.json files. + Servers map[string]VSCodeMCPServer `json:"servers,omitempty"` } // ensureMCPConfig creates .mcp.json with gh-aw MCP server configuration diff --git a/pkg/cli/mcp_config_file_test.go b/pkg/cli/mcp_config_file_test.go index 437ad11b235..41089d74282 100644 --- a/pkg/cli/mcp_config_file_test.go +++ b/pkg/cli/mcp_config_file_test.go @@ -257,6 +257,9 @@ func TestMCPConfigParsing(t *testing.T) { if config.Servers == nil { t.Error("Expected legacy servers map to be initialized") } + if config.MCPServers != nil { + t.Error("Expected mcpServers map to be nil for legacy-only config") + } } else if config.MCPServers == nil { t.Error("Expected mcpServers map to be initialized") }