applyDefaultTools adds default read-only GitHub MCP tools, creating github tool if not present
(tools map[string]any, safeOutputs *SafeOutputsConfig, sandboxConfig *SandboxConfig, networkPermissions *NetworkPermissions)
| 508 | |
| 509 | // applyDefaultTools adds default read-only GitHub MCP tools, creating github tool if not present |
| 510 | func (c *Compiler) applyDefaultTools(tools map[string]any, safeOutputs *SafeOutputsConfig, sandboxConfig *SandboxConfig, networkPermissions *NetworkPermissions) map[string]any { |
| 511 | toolsLog.Printf("Applying default tools: existingToolCount=%d", len(tools)) |
| 512 | // Always apply default GitHub tools (create github section if it doesn't exist) |
| 513 | |
| 514 | if tools == nil { |
| 515 | tools = make(map[string]any) |
| 516 | } |
| 517 | |
| 518 | // Get existing github tool configuration |
| 519 | githubTool := tools["github"] |
| 520 | |
| 521 | // Check if github is explicitly disabled (github: false) |
| 522 | if githubTool == false { |
| 523 | // Remove the github tool entirely when set to false |
| 524 | delete(tools, "github") |
| 525 | } else { |
| 526 | // Process github tool configuration |
| 527 | var githubConfig map[string]any |
| 528 | |
| 529 | if toolConfig, ok := githubTool.(map[string]any); ok { |
| 530 | githubConfig = make(map[string]any) |
| 531 | maps.Copy(githubConfig, toolConfig) |
| 532 | } else { |
| 533 | githubConfig = make(map[string]any) |
| 534 | } |
| 535 | |
| 536 | // Parse the existing GitHub tool configuration for type safety |
| 537 | parsedConfig := parseGitHubTool(githubTool) |
| 538 | |
| 539 | // Create a set of existing tools for efficient lookup |
| 540 | existingToolsSet := make(map[string]struct{}) |
| 541 | if parsedConfig != nil { |
| 542 | for _, tool := range parsedConfig.Allowed { |
| 543 | existingToolsSet[string(tool)] = struct{}{} |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | // Only set allowed tools if explicitly configured |
| 548 | // Don't add default tools - let the MCP server use all available tools |
| 549 | if len(existingToolsSet) > 0 { |
| 550 | // Convert back to []any for the map |
| 551 | existingAllowed := make([]any, 0, len(parsedConfig.Allowed)) |
| 552 | for _, tool := range parsedConfig.Allowed { |
| 553 | existingAllowed = append(existingAllowed, string(tool)) |
| 554 | } |
| 555 | githubConfig["allowed"] = existingAllowed |
| 556 | } |
| 557 | tools["github"] = githubConfig |
| 558 | } |
| 559 | |
| 560 | // Enable edit and bash tools by default when sandbox is enabled |
| 561 | // The sandbox is enabled when: |
| 562 | // 1. Explicitly configured via sandbox.agent (awf) |
| 563 | // 2. Auto-enabled by firewall default enablement (when network restrictions are present) |
| 564 | if isSandboxEnabled(sandboxConfig, networkPermissions) { |
| 565 | toolsLog.Print("Sandbox enabled, applying default edit and bash tools") |
| 566 | |
| 567 | // Add edit tool if not present |