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
19 changes: 16 additions & 3 deletions pkg/workflow/copilot_github_mcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func TestRenderGitHubCopilotMCPConfig_AllowedTools(t *testing.T) {
`"github": {`,
`"type": "stdio"`,
`"container": "ghcr.io/github/github-mcp-server:v0.30.3"`,
`"tools": [`,
`"list_workflows"`,
`"list_workflow_runs"`,
`"list_workflow_run_artifacts"`,
`"env": {`,
`"GITHUB_PERSONAL_ACCESS_TOKEN": "\${GITHUB_MCP_SERVER_TOKEN}"`,
},
Expand All @@ -40,7 +44,9 @@ func TestRenderGitHubCopilotMCPConfig_AllowedTools(t *testing.T) {
`"container": "ghcr.io/github/github-mcp-server:v0.30.3"`,
`"env": {`,
},
unexpectedContent: []string{},
unexpectedContent: []string{
`"tools":`, // Should not include tools field when no allowed tools specified
},
},
{
name: "GitHub with empty allowed array (defaults to all)",
Expand All @@ -54,7 +60,9 @@ func TestRenderGitHubCopilotMCPConfig_AllowedTools(t *testing.T) {
`"container": "ghcr.io/github/github-mcp-server:v0.30.3"`,
`"env": {`,
},
unexpectedContent: []string{},
unexpectedContent: []string{
`"tools":`, // Should not include tools field when allowed array is empty
},
},
{
name: "GitHub remote mode with specific allowed tools",
Expand All @@ -67,6 +75,9 @@ func TestRenderGitHubCopilotMCPConfig_AllowedTools(t *testing.T) {
`"github": {`,
`"type": "http"`,
`"url": "https://api.githubcopilot.com/mcp/"`,
`"tools": [`,
`"get_repository"`,
`"list_commits"`,
},
unexpectedContent: []string{},
},
Expand All @@ -81,7 +92,9 @@ func TestRenderGitHubCopilotMCPConfig_AllowedTools(t *testing.T) {
`"type": "http"`,
`"url": "https://api.githubcopilot.com/mcp/"`,
},
unexpectedContent: []string{},
unexpectedContent: []string{
`"tools":`, // Should not include tools field when no allowed tools specified
},
},
}

Expand Down
18 changes: 15 additions & 3 deletions pkg/workflow/mcp_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,21 @@ func RenderGitHubMCPDockerConfig(yaml *strings.Builder, options GitHubMCPDockerO
yaml.WriteString(" ],\n")
}

// Note: tools field is NOT included here - the converter script adds it back
// for Copilot (see convert_gateway_config_copilot.sh). This keeps the gateway
// config compatible with the schema which doesn't have the tools field.
// Add tools field if requested (Copilot needs it to specify allowed tools)
// This prevents the converter script from adding a wildcard ["*"] when specific tools are configured
if options.IncludeTypeField && len(options.AllowedTools) > 0 {
yaml.WriteString(" \"tools\": [\n")
for i, tool := range options.AllowedTools {
yaml.WriteString(" \"")
yaml.WriteString(tool)
yaml.WriteString("\"")
if i < len(options.AllowedTools)-1 {
yaml.WriteString(",")
}
yaml.WriteString("\n")
}
yaml.WriteString(" ],\n")
}

// Add env section for GitHub MCP server environment variables
yaml.WriteString(" \"env\": {\n")
Expand Down