Skip to content
Merged
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
16 changes: 15 additions & 1 deletion pkg/parser/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
46 changes: 46 additions & 0 deletions pkg/parser/mcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
15 changes: 13 additions & 2 deletions pkg/workflow/mcp_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
29 changes: 28 additions & 1 deletion pkg/workflow/version_field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"},
Expand Down