diff --git a/pkg/awmg/gateway.go b/pkg/awmg/gateway.go index 40fcdd1246..cf7275b8b3 100644 --- a/pkg/awmg/gateway.go +++ b/pkg/awmg/gateway.go @@ -33,8 +33,8 @@ func GetVersion() string { return version } -// MCPGatewayConfig represents the configuration for the MCP gateway. -type MCPGatewayConfig struct { +// MCPGatewayServersConfig represents the configuration for the MCP gateway. +type MCPGatewayServersConfig struct { MCPServers map[string]MCPServerConfig `json:"mcpServers"` Gateway GatewaySettings `json:"gateway,omitempty"` } @@ -56,7 +56,7 @@ type GatewaySettings struct { // MCPGatewayServer manages multiple MCP sessions and exposes them via HTTP type MCPGatewayServer struct { - config *MCPGatewayConfig + config *MCPGatewayServersConfig sessions map[string]*mcp.ClientSession servers map[string]*mcp.Server // Proxy servers for each session mu sync.RWMutex @@ -176,8 +176,8 @@ func runMCPGateway(configFiles []string, port int, logDir string) error { // readGatewayConfig reads the gateway configuration from files or stdin // Returns the config, the path to the first config file (for rewriting), and any error -func readGatewayConfig(configFiles []string) (*MCPGatewayConfig, string, error) { - var configs []*MCPGatewayConfig +func readGatewayConfig(configFiles []string) (*MCPGatewayServersConfig, string, error) { + var configs []*MCPGatewayServersConfig var originalConfigPath string if len(configFiles) > 0 { @@ -296,11 +296,11 @@ func readGatewayConfig(configFiles []string) (*MCPGatewayConfig, string, error) } // parseGatewayConfig parses raw JSON data into a gateway config -func parseGatewayConfig(data []byte) (*MCPGatewayConfig, error) { +func parseGatewayConfig(data []byte) (*MCPGatewayServersConfig, error) { gatewayLog.Printf("Parsing %d bytes of configuration data", len(data)) fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Parsing %d bytes of configuration data", len(data)))) - var config MCPGatewayConfig + var config MCPGatewayServersConfig if err := json.Unmarshal(data, &config); err != nil { fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Failed to parse JSON: %v", err))) fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Data received (first 500 chars): %s", string(data[:min(500, len(data))])))) @@ -327,8 +327,8 @@ 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{ +func mergeConfigs(base, override *MCPGatewayServersConfig) *MCPGatewayServersConfig { + result := &MCPGatewayServersConfig{ MCPServers: make(map[string]MCPServerConfig), Gateway: base.Gateway, } @@ -358,7 +358,7 @@ func mergeConfigs(base, override *MCPGatewayConfig) *MCPGatewayConfig { } // rewriteMCPConfigForGateway rewrites the MCP config file to point all servers to the gateway -func rewriteMCPConfigForGateway(configPath string, config *MCPGatewayConfig) error { +func rewriteMCPConfigForGateway(configPath string, config *MCPGatewayServersConfig) error { gatewayLog.Printf("Rewriting MCP config file: %s", configPath) fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Rewriting MCP config file: %s", configPath))) diff --git a/pkg/awmg/gateway_inspect_integration_test.go b/pkg/awmg/gateway_inspect_integration_test.go index 6e8bc1914b..b672fbec19 100644 --- a/pkg/awmg/gateway_inspect_integration_test.go +++ b/pkg/awmg/gateway_inspect_integration_test.go @@ -65,7 +65,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{ + config := MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "gh-aw": { Command: binaryPath, diff --git a/pkg/awmg/gateway_integration_test.go b/pkg/awmg/gateway_integration_test.go index e47b0282fd..a8eea48947 100644 --- a/pkg/awmg/gateway_integration_test.go +++ b/pkg/awmg/gateway_integration_test.go @@ -23,7 +23,7 @@ func TestMCPGateway_BasicStartup(t *testing.T) { tmpDir := t.TempDir() configFile := filepath.Join(tmpDir, "gateway-config.json") - config := MCPGatewayConfig{ + config := MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "gh-aw": { Command: binaryPath, diff --git a/pkg/awmg/gateway_rewrite_test.go b/pkg/awmg/gateway_rewrite_test.go index d402f05b8e..65164f20ef 100644 --- a/pkg/awmg/gateway_rewrite_test.go +++ b/pkg/awmg/gateway_rewrite_test.go @@ -41,7 +41,7 @@ func TestRewriteMCPConfigForGateway_PreservesNonProxiedServers(t *testing.T) { } // Gateway config only includes external server (github), not internal servers - gatewayConfig := &MCPGatewayConfig{ + gatewayConfig := &MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "github": { Command: "docker", @@ -183,7 +183,7 @@ func TestRewriteMCPConfigForGateway_NoGatewaySection(t *testing.T) { t.Fatalf("Failed to write config file: %v", err) } - gatewayConfig := &MCPGatewayConfig{ + gatewayConfig := &MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "github": { Command: "gh", diff --git a/pkg/awmg/gateway_streamable_http_test.go b/pkg/awmg/gateway_streamable_http_test.go index 8e55f13573..3b248be485 100644 --- a/pkg/awmg/gateway_streamable_http_test.go +++ b/pkg/awmg/gateway_streamable_http_test.go @@ -37,7 +37,7 @@ func TestStreamableHTTPTransport_GatewayConnection(t *testing.T) { configFile := filepath.Join(tmpDir, "gateway-config.json") // Create gateway config with the gh-aw MCP server - config := MCPGatewayConfig{ + config := MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "gh-aw": { Command: binaryPath, @@ -330,7 +330,7 @@ func TestStreamableHTTPTransport_URLConfigured(t *testing.T) { // Test that createMCPSession uses StreamableClientTransport for URL config gateway := &MCPGatewayServer{ - config: &MCPGatewayConfig{}, + config: &MCPGatewayServersConfig{}, sessions: make(map[string]*mcp.ClientSession), logDir: t.TempDir(), } diff --git a/pkg/awmg/gateway_test.go b/pkg/awmg/gateway_test.go index 8bad37e79e..e871591dce 100644 --- a/pkg/awmg/gateway_test.go +++ b/pkg/awmg/gateway_test.go @@ -12,7 +12,7 @@ func TestReadGatewayConfig_FromFile(t *testing.T) { tmpDir := t.TempDir() configFile := filepath.Join(tmpDir, "gateway-config.json") - config := MCPGatewayConfig{ + config := MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "test-server": { Command: "test-command", @@ -81,8 +81,8 @@ func TestReadGatewayConfig_InvalidJSON(t *testing.T) { } } -func TestMCPGatewayConfig_EmptyServers(t *testing.T) { - config := &MCPGatewayConfig{ +func TestMCPGatewayServersConfig_EmptyServers(t *testing.T) { + config := &MCPGatewayServersConfig{ MCPServers: make(map[string]MCPServerConfig), Gateway: GatewaySettings{ Port: 8080, @@ -187,7 +187,7 @@ func TestReadGatewayConfig_EmptyServers(t *testing.T) { tmpDir := t.TempDir() configFile := filepath.Join(tmpDir, "empty-servers.json") - config := MCPGatewayConfig{ + config := MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{}, Gateway: GatewaySettings{ Port: 8080, @@ -236,7 +236,7 @@ func TestReadGatewayConfig_MultipleFiles(t *testing.T) { // Create base config file tmpDir := t.TempDir() baseConfig := filepath.Join(tmpDir, "base-config.json") - baseConfigData := MCPGatewayConfig{ + baseConfigData := MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "server1": { Command: "command1", @@ -262,7 +262,7 @@ func TestReadGatewayConfig_MultipleFiles(t *testing.T) { // Create override config file overrideConfig := filepath.Join(tmpDir, "override-config.json") - overrideConfigData := MCPGatewayConfig{ + overrideConfigData := MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "server2": { Command: "override-command2", @@ -335,7 +335,7 @@ func TestReadGatewayConfig_MultipleFiles(t *testing.T) { } func TestMergeConfigs(t *testing.T) { - base := &MCPGatewayConfig{ + base := &MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "server1": { Command: "cmd1", @@ -350,7 +350,7 @@ func TestMergeConfigs(t *testing.T) { }, } - override := &MCPGatewayConfig{ + override := &MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "server2": { Command: "override-cmd2", @@ -395,7 +395,7 @@ func TestMergeConfigs(t *testing.T) { } func TestMergeConfigs_EmptyOverride(t *testing.T) { - base := &MCPGatewayConfig{ + base := &MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "server1": { Command: "cmd1", @@ -406,7 +406,7 @@ func TestMergeConfigs_EmptyOverride(t *testing.T) { }, } - override := &MCPGatewayConfig{ + override := &MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{}, Gateway: GatewaySettings{}, } @@ -532,7 +532,7 @@ func TestRewriteMCPConfigForGateway(t *testing.T) { } // Create a gateway config (after filtering) - gatewayConfig := &MCPGatewayConfig{ + gatewayConfig := &MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "github": { Command: "gh", @@ -633,7 +633,7 @@ func TestRewriteMCPConfigForGateway_WithAPIKey(t *testing.T) { } // Create a gateway config with API key - gatewayConfig := &MCPGatewayConfig{ + gatewayConfig := &MCPGatewayServersConfig{ MCPServers: map[string]MCPServerConfig{ "github": { Command: "gh", diff --git a/pkg/parser/schemas/main_workflow_schema.json b/pkg/parser/schemas/main_workflow_schema.json index 510479189b..0f5ed15ae2 100644 --- a/pkg/parser/schemas/main_workflow_schema.json +++ b/pkg/parser/schemas/main_workflow_schema.json @@ -285,10 +285,7 @@ }, { "not": { - "anyOf": [ - { "required": ["branches"] }, - { "required": ["branches-ignore"] } - ] + "anyOf": [{ "required": ["branches"] }, { "required": ["branches-ignore"] }] } } ], @@ -305,10 +302,7 @@ }, { "not": { - "anyOf": [ - { "required": ["paths"] }, - { "required": ["paths-ignore"] } - ] + "anyOf": [{ "required": ["paths"] }, { "required": ["paths-ignore"] }] } } ] @@ -431,10 +425,7 @@ }, { "not": { - "anyOf": [ - { "required": ["branches"] }, - { "required": ["branches-ignore"] } - ] + "anyOf": [{ "required": ["branches"] }, { "required": ["branches-ignore"] }] } } ], @@ -451,10 +442,7 @@ }, { "not": { - "anyOf": [ - { "required": ["paths"] }, - { "required": ["paths-ignore"] } - ] + "anyOf": [{ "required": ["paths"] }, { "required": ["paths-ignore"] }] } } ] @@ -669,10 +657,7 @@ }, { "not": { - "anyOf": [ - { "required": ["branches"] }, - { "required": ["branches-ignore"] } - ] + "anyOf": [{ "required": ["branches"] }, { "required": ["branches-ignore"] }] } } ] @@ -996,10 +981,7 @@ }, { "not": { - "anyOf": [ - { "required": ["branches"] }, - { "required": ["branches-ignore"] } - ] + "anyOf": [{ "required": ["branches"] }, { "required": ["branches-ignore"] }] } } ], @@ -1016,10 +998,7 @@ }, { "not": { - "anyOf": [ - { "required": ["paths"] }, - { "required": ["paths-ignore"] } - ] + "anyOf": [{ "required": ["paths"] }, { "required": ["paths-ignore"] }] } } ] diff --git a/pkg/workflow/gateway.go b/pkg/workflow/gateway.go index e31c95267f..71acefe5db 100644 --- a/pkg/workflow/gateway.go +++ b/pkg/workflow/gateway.go @@ -34,8 +34,8 @@ func isMCPGatewayEnabled(workflowData *WorkflowData) bool { return true } -// getMCPGatewayConfig extracts the MCPGatewayConfig from sandbox configuration -func getMCPGatewayConfig(workflowData *WorkflowData) *MCPGatewayConfig { +// getMCPGatewayRuntimeConfig extracts the MCPGatewayRuntimeConfig from sandbox configuration +func getMCPGatewayRuntimeConfig(workflowData *WorkflowData) *MCPGatewayRuntimeConfig { if workflowData == nil || workflowData.SandboxConfig == nil { return nil } @@ -49,7 +49,7 @@ func generateMCPGatewaySteps(workflowData *WorkflowData, mcpServersConfig map[st return nil } - config := getMCPGatewayConfig(workflowData) + config := getMCPGatewayRuntimeConfig(workflowData) if config == nil { return nil } @@ -85,7 +85,7 @@ func validateAndNormalizePort(port int) (int, error) { } // generateMCPGatewayStartStep generates the step that starts the MCP gateway -func generateMCPGatewayStartStep(config *MCPGatewayConfig, mcpServersConfig map[string]any) GitHubActionStep { +func generateMCPGatewayStartStep(config *MCPGatewayRuntimeConfig, mcpServersConfig map[string]any) GitHubActionStep { gatewayLog.Print("Generating MCP gateway start step") port, err := validateAndNormalizePort(config.Port) @@ -126,7 +126,7 @@ func generateMCPGatewayStartStep(config *MCPGatewayConfig, mcpServersConfig map[ } // generateContainerStartCommands generates shell commands to start the MCP gateway using a Docker container -func generateContainerStartCommands(config *MCPGatewayConfig, mcpConfigPath string, port int) []string { +func generateContainerStartCommands(config *MCPGatewayRuntimeConfig, mcpConfigPath string, port int) []string { var lines []string // Build environment variables @@ -184,7 +184,7 @@ func generateContainerStartCommands(config *MCPGatewayConfig, mcpConfigPath stri } // generateCommandStartCommands generates shell commands to start the MCP gateway using a custom command -func generateCommandStartCommands(config *MCPGatewayConfig, mcpConfigPath string, port int) []string { +func generateCommandStartCommands(config *MCPGatewayRuntimeConfig, mcpConfigPath string, port int) []string { var lines []string // Build the command with args @@ -230,7 +230,7 @@ func generateCommandStartCommands(config *MCPGatewayConfig, mcpConfigPath string } // generateDefaultAWMGCommands generates shell commands to start the MCP gateway using the default awmg binary -func generateDefaultAWMGCommands(config *MCPGatewayConfig, mcpConfigPath string, port int) []string { +func generateDefaultAWMGCommands(config *MCPGatewayRuntimeConfig, mcpConfigPath string, port int) []string { var lines []string // Detect action mode at compile time @@ -326,7 +326,7 @@ func generateDefaultAWMGCommands(config *MCPGatewayConfig, mcpConfigPath string, } // generateMCPGatewayHealthCheckStep generates the step that pings the gateway to verify it's running -func generateMCPGatewayHealthCheckStep(config *MCPGatewayConfig) GitHubActionStep { +func generateMCPGatewayHealthCheckStep(config *MCPGatewayRuntimeConfig) GitHubActionStep { gatewayLog.Print("Generating MCP gateway health check step") port, err := validateAndNormalizePort(config.Port) @@ -420,7 +420,7 @@ func generateMCPGatewayHealthCheckStep(config *MCPGatewayConfig) GitHubActionSte } // getMCPGatewayURL returns the HTTP URL for the MCP gateway -func getMCPGatewayURL(config *MCPGatewayConfig) string { +func getMCPGatewayURL(config *MCPGatewayRuntimeConfig) string { port, err := validateAndNormalizePort(config.Port) if err != nil { // In case of validation error, log and use default port @@ -433,7 +433,7 @@ func getMCPGatewayURL(config *MCPGatewayConfig) string { // transformMCPConfigForGateway transforms the MCP server configuration to use the gateway URL // instead of individual server configurations -func transformMCPConfigForGateway(mcpServers map[string]any, gatewayConfig *MCPGatewayConfig) map[string]any { +func transformMCPConfigForGateway(mcpServers map[string]any, gatewayConfig *MCPGatewayRuntimeConfig) map[string]any { if gatewayConfig == nil { return mcpServers } diff --git a/pkg/workflow/gateway_test.go b/pkg/workflow/gateway_test.go index 36cac25757..20401980ad 100644 --- a/pkg/workflow/gateway_test.go +++ b/pkg/workflow/gateway_test.go @@ -13,7 +13,7 @@ func TestParseMCPGatewayTool(t *testing.T) { tests := []struct { name string input any - expected *MCPGatewayConfig + expected *MCPGatewayRuntimeConfig }{ { name: "nil input returns nil", @@ -30,7 +30,7 @@ func TestParseMCPGatewayTool(t *testing.T) { input: map[string]any{ "port": 8080, }, - expected: &MCPGatewayConfig{ + expected: &MCPGatewayRuntimeConfig{ Port: 8080, }, }, @@ -45,7 +45,7 @@ func TestParseMCPGatewayTool(t *testing.T) { "DEBUG": "true", }, }, - expected: &MCPGatewayConfig{ + expected: &MCPGatewayRuntimeConfig{ Port: 8888, APIKey: "${{ secrets.API_KEY }}", Args: []string{"-v", "--debug"}, @@ -56,7 +56,7 @@ func TestParseMCPGatewayTool(t *testing.T) { { name: "empty config", input: map[string]any{}, - expected: &MCPGatewayConfig{ + expected: &MCPGatewayRuntimeConfig{ Port: DefaultMCPGatewayPort, }, }, @@ -65,7 +65,7 @@ func TestParseMCPGatewayTool(t *testing.T) { input: map[string]any{ "port": 8888.0, }, - expected: &MCPGatewayConfig{ + expected: &MCPGatewayRuntimeConfig{ Port: 8888, }, }, @@ -121,7 +121,7 @@ func TestIsMCPGatewayEnabled(t *testing.T) { name: "sandbox.mcp configured", data: &WorkflowData{ SandboxConfig: &SandboxConfig{ - MCP: &MCPGatewayConfig{ + MCP: &MCPGatewayRuntimeConfig{ Port: 8080, }, }, @@ -132,7 +132,7 @@ func TestIsMCPGatewayEnabled(t *testing.T) { name: "sandbox.mcp with empty config", data: &WorkflowData{ SandboxConfig: &SandboxConfig{ - MCP: &MCPGatewayConfig{}, + MCP: &MCPGatewayRuntimeConfig{}, }, }, expected: true, @@ -147,7 +147,7 @@ func TestIsMCPGatewayEnabled(t *testing.T) { } } -func TestGetMCPGatewayConfig(t *testing.T) { +func TestGetMCPGatewayRuntimeConfig(t *testing.T) { tests := []struct { name string data *WorkflowData @@ -171,7 +171,7 @@ func TestGetMCPGatewayConfig(t *testing.T) { name: "valid sandbox.mcp config", data: &WorkflowData{ SandboxConfig: &SandboxConfig{ - MCP: &MCPGatewayConfig{ + MCP: &MCPGatewayRuntimeConfig{ Port: 9090, }, }, @@ -182,7 +182,7 @@ func TestGetMCPGatewayConfig(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - result := getMCPGatewayConfig(tt.data) + result := getMCPGatewayRuntimeConfig(tt.data) if tt.hasConfig { require.NotNil(t, result) assert.Equal(t, 9090, result.Port) @@ -210,7 +210,7 @@ func TestGenerateMCPGatewaySteps(t *testing.T) { name: "gateway enabled returns two steps", data: &WorkflowData{ SandboxConfig: &SandboxConfig{ - MCP: &MCPGatewayConfig{ + MCP: &MCPGatewayRuntimeConfig{ Port: 8080, }, }, @@ -234,7 +234,7 @@ func TestGenerateMCPGatewaySteps(t *testing.T) { } func TestGenerateMCPGatewayStartStep(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Port: 8080, } mcpServers := map[string]any{ @@ -253,7 +253,7 @@ func TestGenerateMCPGatewayStartStep(t *testing.T) { } func TestGenerateMCPGatewayHealthCheckStep(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Port: 8080, } @@ -284,17 +284,17 @@ func TestGenerateMCPGatewayHealthCheckStep(t *testing.T) { func TestGetMCPGatewayURL(t *testing.T) { tests := []struct { name string - config *MCPGatewayConfig + config *MCPGatewayRuntimeConfig expected string }{ { name: "default port", - config: &MCPGatewayConfig{}, + config: &MCPGatewayRuntimeConfig{}, expected: "http://localhost:8080", }, { name: "custom port", - config: &MCPGatewayConfig{ + config: &MCPGatewayRuntimeConfig{ Port: 9090, }, expected: "http://localhost:9090", @@ -313,7 +313,7 @@ func TestTransformMCPConfigForGateway(t *testing.T) { tests := []struct { name string mcpServers map[string]any - config *MCPGatewayConfig + config *MCPGatewayRuntimeConfig expected map[string]any }{ { @@ -332,7 +332,7 @@ func TestTransformMCPConfigForGateway(t *testing.T) { "github": map[string]any{}, "playwright": map[string]any{}, }, - config: &MCPGatewayConfig{ + config: &MCPGatewayRuntimeConfig{ Port: 8080, }, expected: map[string]any{ @@ -351,7 +351,7 @@ func TestTransformMCPConfigForGateway(t *testing.T) { mcpServers: map[string]any{ "github": map[string]any{}, }, - config: &MCPGatewayConfig{ + config: &MCPGatewayRuntimeConfig{ Port: 8080, APIKey: "secret", }, @@ -380,7 +380,7 @@ func TestSandboxConfigWithMCP(t *testing.T) { Agent: &AgentSandboxConfig{ Type: SandboxTypeAWF, }, - MCP: &MCPGatewayConfig{ + MCP: &MCPGatewayRuntimeConfig{ Container: "test-image", Port: 9000, }, @@ -395,7 +395,7 @@ func TestSandboxConfigWithMCP(t *testing.T) { } func TestGenerateContainerStartCommands(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Container: "ghcr.io/githubnext/gh-aw-mcpg:latest", Args: []string{"--rm", "-i", "-v", "/var/run/docker.sock:/var/run/docker.sock", "-p", "8000:8000", "--entrypoint", "/app/flowguard-go"}, EntrypointArgs: []string{"--routed", "--listen", "0.0.0.0:8000", "--config-stdin"}, @@ -439,7 +439,7 @@ func TestGenerateContainerStartCommands(t *testing.T) { } func TestGenerateCommandStartCommands(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Command: "/usr/local/bin/mcp-gateway", Args: []string{"--port", "8080", "--verbose"}, Port: 8080, @@ -470,7 +470,7 @@ func TestGenerateCommandStartCommands(t *testing.T) { } func TestGenerateDefaultAWMGCommands(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Port: 8080, } @@ -489,7 +489,7 @@ func TestGenerateDefaultAWMGCommands(t *testing.T) { } func TestGenerateMCPGatewayStartStep_ContainerMode(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Container: "ghcr.io/githubnext/gh-aw-mcpg:latest", Args: []string{"--rm", "-i"}, EntrypointArgs: []string{"--config-stdin"}, @@ -510,7 +510,7 @@ func TestGenerateMCPGatewayStartStep_ContainerMode(t *testing.T) { } func TestGenerateMCPGatewayStartStep_CommandMode(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Command: "/usr/local/bin/custom-gateway", Args: []string{"--debug"}, Port: 9000, @@ -530,7 +530,7 @@ func TestGenerateMCPGatewayStartStep_CommandMode(t *testing.T) { } func TestGenerateMCPGatewayStartStep_DefaultMode(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Port: 8080, } mcpServers := map[string]any{ @@ -639,7 +639,7 @@ func TestGenerateMCPGatewayStartStepWithInvalidPort(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Port: tt.port, } mcpServers := map[string]any{ @@ -676,7 +676,7 @@ func TestGenerateMCPGatewayHealthCheckStepWithInvalidPort(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Port: tt.port, } @@ -720,7 +720,7 @@ func TestGetMCPGatewayURLWithInvalidPort(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Port: tt.port, } diff --git a/pkg/workflow/sandbox.go b/pkg/workflow/sandbox.go index 169500a040..da55779c06 100644 --- a/pkg/workflow/sandbox.go +++ b/pkg/workflow/sandbox.go @@ -43,8 +43,8 @@ const ( // Legacy format: "default"|"sandbox-runtime" or { type, config } type SandboxConfig struct { // New fields - Agent *AgentSandboxConfig `yaml:"agent,omitempty"` // Agent sandbox configuration - MCP *MCPGatewayConfig `yaml:"mcp,omitempty"` // MCP gateway configuration + Agent *AgentSandboxConfig `yaml:"agent,omitempty"` // Agent sandbox configuration + MCP *MCPGatewayRuntimeConfig `yaml:"mcp,omitempty"` // MCP gateway configuration // Legacy fields (for backward compatibility) Type SandboxType `yaml:"type,omitempty"` // Sandbox type: "default" or "sandbox-runtime" diff --git a/pkg/workflow/sandbox_test.go b/pkg/workflow/sandbox_test.go index 9ae41678bd..7396951af9 100644 --- a/pkg/workflow/sandbox_test.go +++ b/pkg/workflow/sandbox_test.go @@ -296,7 +296,7 @@ func TestValidateSandboxConfig(t *testing.T) { name: "MCP gateway with both command and container fails", data: &WorkflowData{ SandboxConfig: &SandboxConfig{ - MCP: &MCPGatewayConfig{ + MCP: &MCPGatewayRuntimeConfig{ Command: "/usr/bin/gateway", Container: "ghcr.io/gateway:latest", }, @@ -309,7 +309,7 @@ func TestValidateSandboxConfig(t *testing.T) { name: "MCP gateway with entrypointArgs without container fails", data: &WorkflowData{ SandboxConfig: &SandboxConfig{ - MCP: &MCPGatewayConfig{ + MCP: &MCPGatewayRuntimeConfig{ Command: "/usr/bin/gateway", EntrypointArgs: []string{"--config-stdin"}, }, @@ -322,7 +322,7 @@ func TestValidateSandboxConfig(t *testing.T) { name: "MCP gateway with container only is valid", data: &WorkflowData{ SandboxConfig: &SandboxConfig{ - MCP: &MCPGatewayConfig{ + MCP: &MCPGatewayRuntimeConfig{ Container: "ghcr.io/gateway:latest", EntrypointArgs: []string{"--config-stdin"}, }, @@ -334,7 +334,7 @@ func TestValidateSandboxConfig(t *testing.T) { name: "MCP gateway with command only is valid", data: &WorkflowData{ SandboxConfig: &SandboxConfig{ - MCP: &MCPGatewayConfig{ + MCP: &MCPGatewayRuntimeConfig{ Command: "/usr/bin/gateway", Args: []string{"--port", "8080"}, }, @@ -346,7 +346,7 @@ func TestValidateSandboxConfig(t *testing.T) { name: "MCP gateway with neither command nor container is valid", data: &WorkflowData{ SandboxConfig: &SandboxConfig{ - MCP: &MCPGatewayConfig{ + MCP: &MCPGatewayRuntimeConfig{ Port: 8080, }, }, diff --git a/pkg/workflow/tools_parser.go b/pkg/workflow/tools_parser.go index 44e890cd54..0257cc8c4c 100644 --- a/pkg/workflow/tools_parser.go +++ b/pkg/workflow/tools_parser.go @@ -417,7 +417,7 @@ func parseRepoMemoryTool(val any) *RepoMemoryToolConfig { } // parseMCPGatewayTool converts raw mcp-gateway tool configuration -func parseMCPGatewayTool(val any) *MCPGatewayConfig { +func parseMCPGatewayTool(val any) *MCPGatewayRuntimeConfig { if val == nil { return nil } @@ -427,7 +427,7 @@ func parseMCPGatewayTool(val any) *MCPGatewayConfig { return nil } - config := &MCPGatewayConfig{ + config := &MCPGatewayRuntimeConfig{ Port: DefaultMCPGatewayPort, } diff --git a/pkg/workflow/tools_types.go b/pkg/workflow/tools_types.go index 4484fcb96c..50a829b3cc 100644 --- a/pkg/workflow/tools_types.go +++ b/pkg/workflow/tools_types.go @@ -230,9 +230,9 @@ type CacheMemoryToolConfig struct { Raw any `yaml:"-"` } -// MCPGatewayConfig represents the configuration for the MCP gateway +// MCPGatewayRuntimeConfig represents the configuration for the MCP gateway // The gateway routes MCP server calls through a unified HTTP endpoint -type MCPGatewayConfig struct { +type MCPGatewayRuntimeConfig struct { Command string `yaml:"command,omitempty"` // Custom command to execute (mutually exclusive with Container) Container string `yaml:"container,omitempty"` // Container image for the gateway (mutually exclusive with Command) Version string `yaml:"version,omitempty"` // Optional version/tag for the container diff --git a/specs/mcp-gateway.md b/specs/mcp-gateway.md index 333d086f9c..05feb30968 100644 --- a/specs/mcp-gateway.md +++ b/specs/mcp-gateway.md @@ -17,10 +17,10 @@ The problem statement requested: ## Implementation Details -### 1. Command Structure (`pkg/cli/mcp_gateway_command.go`) +### 1. Command Structure (`pkg/awmg/gateway.go`) **Core Components**: -- `MCPGatewayConfig`: Configuration structure matching Claude/Copilot/Codex format +- `MCPGatewayServersConfig`: Configuration structure matching Claude/Copilot/Codex format - `MCPServerConfig`: Individual server configuration (command, args, env, url, container) - `GatewaySettings`: Gateway-specific settings (port, API key) - `MCPGatewayServer`: Main server managing multiple MCP sessions