MCPcopy Create free account
hub / github.com/github/gh-aw / buildGitHubBuiltinConfig

Function buildGitHubBuiltinConfig

pkg/parser/mcp.go:276–318  ·  view source on GitHub ↗
(toolValue any)

Source from the content-addressed store, hash-verified

274}
275
276func buildGitHubBuiltinConfig(toolValue any) RegistryMCPServerConfig {
277 useRemote, customToken, toolConfig := githubBuiltinMode(toolValue)
278 var config RegistryMCPServerConfig
279 if useRemote {
280 config = RegistryMCPServerConfig{
281 BaseMCPServerConfig: types.BaseMCPServerConfig{
282 Type: "http",
283 URL: "https://api.githubcopilot.com/mcp/",
284 Headers: make(map[string]string),
285 Env: make(map[string]string),
286 },
287 Name: "github",
288 }
289 if customToken != "" {
290 config.Env["GITHUB_TOKEN"] = customToken
291 }
292 config.Headers["X-MCP-Readonly"] = "true"
293 } else {
294 config = RegistryMCPServerConfig{
295 BaseMCPServerConfig: types.BaseMCPServerConfig{
296 Type: "docker",
297 Command: "docker",
298 Args: []string{
299 "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
300 "-e", "GITHUB_READ_ONLY=1",
301 "ghcr.io/github/github-mcp-server:" + string(constants.DefaultGitHubMCPServerVersion),
302 },
303 Env: make(map[string]string),
304 },
305 Name: "github",
306 }
307 if githubToken, err := GetGitHubToken(); err == nil {
308 config.Env["GITHUB_PERSONAL_ACCESS_TOKEN"] = githubToken
309 } else {
310 config.Env["GITHUB_PERSONAL_ACCESS_TOKEN"] = "${GITHUB_TOKEN_REQUIRED}"
311 }
312 }
313 appendBuiltinAllowedTools(&config, toolConfig)
314 if !useRemote {
315 applyGitHubBuiltinOverrides(&config, toolConfig)
316 }
317 return config
318}
319
320func githubBuiltinMode(toolValue any) (bool, string, map[string]any) {
321 toolConfig, ok := toolValue.(map[string]any)

Callers 1

processBuiltinMCPToolFunction · 0.85

Calls 4

githubBuiltinModeFunction · 0.85
GetGitHubTokenFunction · 0.70

Tested by

no test coverage detected