From f59a8f854fdf31a69fb5ff5553b0e1ab9fe360fd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 01:17:11 +0000 Subject: [PATCH 1/2] Initial plan From 41c1f2c2e0f84165e9ec75b452bef0934c5521dc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 01:31:13 +0000 Subject: [PATCH 2/2] Fix GitHub MCP version field to accept numeric types - Updated pkg/parser/mcp.go to handle numeric version types (int, int64, uint64, float64) - Updated pkg/workflow/mcp_servers.go getGitHubDockerImageVersion() to handle numeric types - Added test cases for integer and float versions in mcp_test.go - Added test cases for numeric versions in version_field_test.go - All tests pass successfully - Manual testing confirms integer (20) and float (3.11) versions work correctly Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- pkg/parser/mcp.go | 16 ++++++++++- pkg/parser/mcp_test.go | 46 ++++++++++++++++++++++++++++++ pkg/workflow/mcp_servers.go | 15 ++++++++-- pkg/workflow/version_field_test.go | 29 ++++++++++++++++++- 4 files changed, 102 insertions(+), 4 deletions(-) diff --git a/pkg/parser/mcp.go b/pkg/parser/mcp.go index 06fb278c04..c416906259 100644 --- a/pkg/parser/mcp.go +++ b/pkg/parser/mcp.go @@ -369,7 +369,21 @@ func processBuiltinMCPTool(toolName string, toolValue any, serverFilter string) // Check for custom Docker image version (only applicable in local/Docker mode) if !useRemote { if version, exists := toolConfig["version"]; exists { - if versionStr, ok := version.(string); ok { + var versionStr string + switch v := version.(type) { + case string: + versionStr = v + case int: + versionStr = fmt.Sprintf("%d", v) + case int64: + versionStr = fmt.Sprintf("%d", v) + case uint64: + versionStr = fmt.Sprintf("%d", v) + case float64: + // Use %g to avoid trailing zeros and scientific notation for simple numbers + versionStr = fmt.Sprintf("%g", v) + } + if versionStr != "" { dockerImage := "ghcr.io/github/github-mcp-server:" + versionStr // Update the Docker image in args for i, arg := range config.Args { diff --git a/pkg/parser/mcp_test.go b/pkg/parser/mcp_test.go index 658ece30e8..00337cb868 100644 --- a/pkg/parser/mcp_test.go +++ b/pkg/parser/mcp_test.go @@ -208,6 +208,52 @@ func TestExtractMCPConfigurations(t *testing.T) { }, }, }, + { + name: "GitHub tool with integer version", + frontmatter: map[string]any{ + "tools": map[string]any{ + "github": map[string]any{ + "version": 20, + }, + }, + }, + expected: []MCPServerConfig{ + { + Name: "github", + Type: "docker", + Command: "docker", + Args: []string{ + "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", + "ghcr.io/github/github-mcp-server:20", + }, + Env: map[string]string{"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN_REQUIRED}"}, + Allowed: []string{}, + }, + }, + }, + { + name: "GitHub tool with float version", + frontmatter: map[string]any{ + "tools": map[string]any{ + "github": map[string]any{ + "version": 3.11, + }, + }, + }, + expected: []MCPServerConfig{ + { + Name: "github", + Type: "docker", + Command: "docker", + Args: []string{ + "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", + "ghcr.io/github/github-mcp-server:3.11", + }, + Env: map[string]string{"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN_REQUIRED}"}, + Allowed: []string{}, + }, + }, + }, { name: "Playwright tool default configuration", frontmatter: map[string]any{ diff --git a/pkg/workflow/mcp_servers.go b/pkg/workflow/mcp_servers.go index 10f4369ecb..617f1631d0 100644 --- a/pkg/workflow/mcp_servers.go +++ b/pkg/workflow/mcp_servers.go @@ -445,8 +445,19 @@ func getGitHubDockerImageVersion(githubTool any) string { // Extract version setting from tool properties if toolConfig, ok := githubTool.(map[string]any); ok { if versionSetting, exists := toolConfig["version"]; exists { - if stringValue, ok := versionSetting.(string); ok { - githubDockerImageVersion = stringValue + // Handle different version types + switch v := versionSetting.(type) { + case string: + githubDockerImageVersion = v + case int: + githubDockerImageVersion = fmt.Sprintf("%d", v) + case int64: + githubDockerImageVersion = fmt.Sprintf("%d", v) + case uint64: + githubDockerImageVersion = fmt.Sprintf("%d", v) + case float64: + // Use %g to avoid trailing zeros and scientific notation for simple numbers + githubDockerImageVersion = fmt.Sprintf("%g", v) } } } diff --git a/pkg/workflow/version_field_test.go b/pkg/workflow/version_field_test.go index 7d5db064a9..7119577218 100644 --- a/pkg/workflow/version_field_test.go +++ b/pkg/workflow/version_field_test.go @@ -11,7 +11,7 @@ import ( func TestVersionField(t *testing.T) { // Test GitHub tool version extraction t.Run("GitHub version field extraction", func(t *testing.T) { - // Test "version" field + // Test "version" field with string githubTool := map[string]any{ "allowed": []any{"create_issue"}, "version": "v2.0.0", @@ -21,6 +21,33 @@ func TestVersionField(t *testing.T) { t.Errorf("Expected v2.0.0, got %s", result) } + // Test "version" field with integer + githubToolInt := map[string]any{ + "version": 20, + } + result = getGitHubDockerImageVersion(githubToolInt) + if result != "20" { + t.Errorf("Expected 20, got %s", result) + } + + // Test "version" field with uint64 (as YAML parser returns) + githubToolUint64 := map[string]any{ + "version": uint64(42), + } + result = getGitHubDockerImageVersion(githubToolUint64) + if result != "42" { + t.Errorf("Expected 42, got %s", result) + } + + // Test "version" field with float + githubToolFloat := map[string]any{ + "version": 3.11, + } + result = getGitHubDockerImageVersion(githubToolFloat) + if result != "3.11" { + t.Errorf("Expected 3.11, got %s", result) + } + // Test default value when version field is not present githubToolDefault := map[string]any{ "allowed": []any{"create_issue"},