Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions pkg/awmg/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))]))))
Expand All @@ -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,
}
Expand Down Expand Up @@ -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)))

Expand Down
2 changes: 1 addition & 1 deletion pkg/awmg/gateway_inspect_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/awmg/gateway_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/awmg/gateway_rewrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions pkg/awmg/gateway_streamable_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/awmg/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -350,7 +350,7 @@ func TestMergeConfigs(t *testing.T) {
},
}

override := &MCPGatewayConfig{
override := &MCPGatewayServersConfig{
MCPServers: map[string]MCPServerConfig{
"server2": {
Command: "override-cmd2",
Expand Down Expand Up @@ -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",
Expand All @@ -406,7 +406,7 @@ func TestMergeConfigs_EmptyOverride(t *testing.T) {
},
}

override := &MCPGatewayConfig{
override := &MCPGatewayServersConfig{
MCPServers: map[string]MCPServerConfig{},
Gateway: GatewaySettings{},
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
35 changes: 7 additions & 28 deletions pkg/parser/schemas/main_workflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,7 @@
},
{
"not": {
"anyOf": [
{ "required": ["branches"] },
{ "required": ["branches-ignore"] }
]
"anyOf": [{ "required": ["branches"] }, { "required": ["branches-ignore"] }]
}
}
],
Expand All @@ -305,10 +302,7 @@
},
{
"not": {
"anyOf": [
{ "required": ["paths"] },
{ "required": ["paths-ignore"] }
]
"anyOf": [{ "required": ["paths"] }, { "required": ["paths-ignore"] }]
}
}
]
Expand Down Expand Up @@ -431,10 +425,7 @@
},
{
"not": {
"anyOf": [
{ "required": ["branches"] },
{ "required": ["branches-ignore"] }
]
"anyOf": [{ "required": ["branches"] }, { "required": ["branches-ignore"] }]
}
}
],
Expand All @@ -451,10 +442,7 @@
},
{
"not": {
"anyOf": [
{ "required": ["paths"] },
{ "required": ["paths-ignore"] }
]
"anyOf": [{ "required": ["paths"] }, { "required": ["paths-ignore"] }]
}
}
]
Expand Down Expand Up @@ -669,10 +657,7 @@
},
{
"not": {
"anyOf": [
{ "required": ["branches"] },
{ "required": ["branches-ignore"] }
]
"anyOf": [{ "required": ["branches"] }, { "required": ["branches-ignore"] }]
}
}
]
Expand Down Expand Up @@ -996,10 +981,7 @@
},
{
"not": {
"anyOf": [
{ "required": ["branches"] },
{ "required": ["branches-ignore"] }
]
"anyOf": [{ "required": ["branches"] }, { "required": ["branches-ignore"] }]
}
}
],
Expand All @@ -1016,10 +998,7 @@
},
{
"not": {
"anyOf": [
{ "required": ["paths"] },
{ "required": ["paths-ignore"] }
]
"anyOf": [{ "required": ["paths"] }, { "required": ["paths-ignore"] }]
}
}
]
Expand Down
20 changes: 10 additions & 10 deletions pkg/workflow/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -49,7 +49,7 @@ func generateMCPGatewaySteps(workflowData *WorkflowData, mcpServersConfig map[st
return nil
}

config := getMCPGatewayConfig(workflowData)
config := getMCPGatewayRuntimeConfig(workflowData)
if config == nil {
return nil
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
Loading