From f9e5b7d7e9824b9572af5854bcb0f0bf2847cf0b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 25 Dec 2025 05:00:30 +0000 Subject: [PATCH 1/2] Initial plan From 02ea5e7a6b60a758cfbf965acd416b3e3016d2ac Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 25 Dec 2025 05:09:28 +0000 Subject: [PATCH 2/2] Consolidate MCPServerConfig definitions - use parser.MCPServerConfig Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- pkg/awmg/gateway.go | 20 ++++--------- pkg/awmg/gateway_inspect_integration_test.go | 4 ++- pkg/awmg/gateway_integration_test.go | 4 ++- pkg/awmg/gateway_rewrite_test.go | 6 ++-- pkg/awmg/gateway_streamable_http_test.go | 6 ++-- pkg/awmg/gateway_test.go | 30 +++++++++++--------- 6 files changed, 36 insertions(+), 34 deletions(-) diff --git a/pkg/awmg/gateway.go b/pkg/awmg/gateway.go index 567ccfca4f5..7bee0c4b5f7 100644 --- a/pkg/awmg/gateway.go +++ b/pkg/awmg/gateway.go @@ -14,6 +14,7 @@ import ( "github.com/githubnext/gh-aw/pkg/console" "github.com/githubnext/gh-aw/pkg/logger" + "github.com/githubnext/gh-aw/pkg/parser" "github.com/modelcontextprotocol/go-sdk/mcp" "github.com/spf13/cobra" ) @@ -35,17 +36,8 @@ func GetVersion() string { // MCPGatewayConfig represents the configuration for the MCP gateway. type MCPGatewayConfig struct { - MCPServers map[string]MCPServerConfig `json:"mcpServers"` - Gateway GatewaySettings `json:"gateway,omitempty"` -} - -// MCPServerConfig represents configuration for a single MCP server. -type MCPServerConfig struct { - Command string `json:"command,omitempty"` - Args []string `json:"args,omitempty"` - Env map[string]string `json:"env,omitempty"` - URL string `json:"url,omitempty"` - Container string `json:"container,omitempty"` + MCPServers map[string]parser.MCPServerConfig `json:"mcpServers"` + Gateway GatewaySettings `json:"gateway,omitempty"` } // GatewaySettings represents gateway-specific settings. @@ -310,7 +302,7 @@ func parseGatewayConfig(data []byte) (*MCPGatewayConfig, error) { // Filter out internal workflow MCP servers (safeinputs and safeoutputs) // These are used internally by the workflow and should not be proxied by the gateway - filteredServers := make(map[string]MCPServerConfig) + filteredServers := make(map[string]parser.MCPServerConfig) for name, serverConfig := range config.MCPServers { if name == "safeinputs" || name == "safeoutputs" { gatewayLog.Printf("Filtering out internal workflow server: %s", name) @@ -327,7 +319,7 @@ func parseGatewayConfig(data []byte) (*MCPGatewayConfig, error) { // mergeConfigs merges two gateway configurations, with the second overriding the first func mergeConfigs(base, override *MCPGatewayConfig) *MCPGatewayConfig { result := &MCPGatewayConfig{ - MCPServers: make(map[string]MCPServerConfig), + MCPServers: make(map[string]parser.MCPServerConfig), Gateway: base.Gateway, } @@ -500,7 +492,7 @@ func (g *MCPGatewayServer) initializeSessions() error { } // createMCPSession creates an MCP session for a single server configuration -func (g *MCPGatewayServer) createMCPSession(serverName string, config MCPServerConfig) (*mcp.ClientSession, error) { +func (g *MCPGatewayServer) createMCPSession(serverName string, config parser.MCPServerConfig) (*mcp.ClientSession, error) { // Create log file for this server (flat directory structure) logFile := filepath.Join(g.logDir, fmt.Sprintf("%s.log", serverName)) gatewayLog.Printf("Creating log file for %s: %s", serverName, logFile) diff --git a/pkg/awmg/gateway_inspect_integration_test.go b/pkg/awmg/gateway_inspect_integration_test.go index 6e8bc1914bd..90968f01491 100644 --- a/pkg/awmg/gateway_inspect_integration_test.go +++ b/pkg/awmg/gateway_inspect_integration_test.go @@ -13,6 +13,8 @@ import ( "strings" "testing" "time" + + "github.com/githubnext/gh-aw/pkg/parser" ) // TestMCPGateway_InspectWithPlaywright tests the MCP gateway by: @@ -66,7 +68,7 @@ This workflow tests the MCP gateway configuration and tool list. // Create MCP gateway configuration with gh-aw MCP server configFile := filepath.Join(tmpDir, "gateway-config.json") config := MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "gh-aw": { Command: binaryPath, Args: []string{"mcp-server"}, diff --git a/pkg/awmg/gateway_integration_test.go b/pkg/awmg/gateway_integration_test.go index e47b0282fd6..180621928ac 100644 --- a/pkg/awmg/gateway_integration_test.go +++ b/pkg/awmg/gateway_integration_test.go @@ -10,6 +10,8 @@ import ( "path/filepath" "testing" "time" + + "github.com/githubnext/gh-aw/pkg/parser" ) func TestMCPGateway_BasicStartup(t *testing.T) { @@ -24,7 +26,7 @@ func TestMCPGateway_BasicStartup(t *testing.T) { configFile := filepath.Join(tmpDir, "gateway-config.json") config := MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "gh-aw": { Command: binaryPath, Args: []string{"mcp-server"}, diff --git a/pkg/awmg/gateway_rewrite_test.go b/pkg/awmg/gateway_rewrite_test.go index d402f05b8ee..ff71424ae17 100644 --- a/pkg/awmg/gateway_rewrite_test.go +++ b/pkg/awmg/gateway_rewrite_test.go @@ -5,6 +5,8 @@ import ( "os" "path/filepath" "testing" + + "github.com/githubnext/gh-aw/pkg/parser" ) // TestRewriteMCPConfigForGateway_PreservesNonProxiedServers tests that @@ -42,7 +44,7 @@ func TestRewriteMCPConfigForGateway_PreservesNonProxiedServers(t *testing.T) { // Gateway config only includes external server (github), not internal servers gatewayConfig := &MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "github": { Command: "docker", Args: []string{"run", "-i", "--rm", "ghcr.io/github-mcp-server"}, @@ -184,7 +186,7 @@ func TestRewriteMCPConfigForGateway_NoGatewaySection(t *testing.T) { } gatewayConfig := &MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "github": { Command: "gh", Args: []string{"aw", "mcp-server"}, diff --git a/pkg/awmg/gateway_streamable_http_test.go b/pkg/awmg/gateway_streamable_http_test.go index bbec08c96cf..df01d6d2555 100644 --- a/pkg/awmg/gateway_streamable_http_test.go +++ b/pkg/awmg/gateway_streamable_http_test.go @@ -15,6 +15,8 @@ import ( "testing" "time" + "github.com/githubnext/gh-aw/pkg/parser" + "github.com/modelcontextprotocol/go-sdk/mcp" ) @@ -38,7 +40,7 @@ func TestStreamableHTTPTransport_GatewayConnection(t *testing.T) { // Create gateway config with the gh-aw MCP server config := MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "gh-aw": { Command: binaryPath, Args: []string{"mcp-server"}, @@ -350,7 +352,7 @@ func TestStreamableHTTPTransport_URLConfigured(t *testing.T) { } // Create a session with URL configuration - serverConfig := MCPServerConfig{ + serverConfig := parser.MCPServerConfig{ URL: mockServer.URL, } diff --git a/pkg/awmg/gateway_test.go b/pkg/awmg/gateway_test.go index 8bad37e79e3..699e7fa91bf 100644 --- a/pkg/awmg/gateway_test.go +++ b/pkg/awmg/gateway_test.go @@ -5,6 +5,8 @@ import ( "os" "path/filepath" "testing" + + "github.com/githubnext/gh-aw/pkg/parser" ) func TestReadGatewayConfig_FromFile(t *testing.T) { @@ -13,7 +15,7 @@ func TestReadGatewayConfig_FromFile(t *testing.T) { configFile := filepath.Join(tmpDir, "gateway-config.json") config := MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "test-server": { Command: "test-command", Args: []string{"arg1", "arg2"}, @@ -83,7 +85,7 @@ func TestReadGatewayConfig_InvalidJSON(t *testing.T) { func TestMCPGatewayConfig_EmptyServers(t *testing.T) { config := &MCPGatewayConfig{ - MCPServers: make(map[string]MCPServerConfig), + MCPServers: make(map[string]parser.MCPServerConfig), Gateway: GatewaySettings{ Port: 8080, }, @@ -95,7 +97,7 @@ func TestMCPGatewayConfig_EmptyServers(t *testing.T) { } func TestMCPServerConfig_CommandType(t *testing.T) { - config := MCPServerConfig{ + config := parser.MCPServerConfig{ Command: "gh", Args: []string{"aw", "mcp-server"}, Env: map[string]string{ @@ -117,7 +119,7 @@ func TestMCPServerConfig_CommandType(t *testing.T) { } func TestMCPServerConfig_URLType(t *testing.T) { - config := MCPServerConfig{ + config := parser.MCPServerConfig{ URL: "http://localhost:3000", } @@ -131,7 +133,7 @@ func TestMCPServerConfig_URLType(t *testing.T) { } func TestMCPServerConfig_ContainerType(t *testing.T) { - config := MCPServerConfig{ + config := parser.MCPServerConfig{ Container: "mcp-server:latest", Args: []string{"--verbose"}, Env: map[string]string{ @@ -188,7 +190,7 @@ func TestReadGatewayConfig_EmptyServers(t *testing.T) { configFile := filepath.Join(tmpDir, "empty-servers.json") config := MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{}, + MCPServers: map[string]parser.MCPServerConfig{}, Gateway: GatewaySettings{ Port: 8080, }, @@ -237,7 +239,7 @@ func TestReadGatewayConfig_MultipleFiles(t *testing.T) { tmpDir := t.TempDir() baseConfig := filepath.Join(tmpDir, "base-config.json") baseConfigData := MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "server1": { Command: "command1", Args: []string{"arg1"}, @@ -263,7 +265,7 @@ func TestReadGatewayConfig_MultipleFiles(t *testing.T) { // Create override config file overrideConfig := filepath.Join(tmpDir, "override-config.json") overrideConfigData := MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "server2": { Command: "override-command2", Args: []string{"override-arg2"}, @@ -336,7 +338,7 @@ func TestReadGatewayConfig_MultipleFiles(t *testing.T) { func TestMergeConfigs(t *testing.T) { base := &MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "server1": { Command: "cmd1", }, @@ -351,7 +353,7 @@ func TestMergeConfigs(t *testing.T) { } override := &MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "server2": { Command: "override-cmd2", }, @@ -396,7 +398,7 @@ func TestMergeConfigs(t *testing.T) { func TestMergeConfigs_EmptyOverride(t *testing.T) { base := &MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "server1": { Command: "cmd1", }, @@ -407,7 +409,7 @@ func TestMergeConfigs_EmptyOverride(t *testing.T) { } override := &MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{}, + MCPServers: map[string]parser.MCPServerConfig{}, Gateway: GatewaySettings{}, } @@ -533,7 +535,7 @@ func TestRewriteMCPConfigForGateway(t *testing.T) { // Create a gateway config (after filtering) gatewayConfig := &MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "github": { Command: "gh", Args: []string{"aw", "mcp-server"}, @@ -634,7 +636,7 @@ func TestRewriteMCPConfigForGateway_WithAPIKey(t *testing.T) { // Create a gateway config with API key gatewayConfig := &MCPGatewayConfig{ - MCPServers: map[string]MCPServerConfig{ + MCPServers: map[string]parser.MCPServerConfig{ "github": { Command: "gh", Args: []string{"aw", "mcp-server"},