ExtractMCPConfigurations extracts MCP server configurations from workflow frontmatter
(frontmatter map[string]any, serverFilter string)
| 58 | |
| 59 | // ExtractMCPConfigurations extracts MCP server configurations from workflow frontmatter |
| 60 | func ExtractMCPConfigurations(frontmatter map[string]any, serverFilter string) ([]RegistryMCPServerConfig, error) { |
| 61 | mcpLog.Printf("Extracting MCP configurations with filter: %s", serverFilter) |
| 62 | var configs []RegistryMCPServerConfig |
| 63 | |
| 64 | addSafeOutputsConfig(frontmatter, serverFilter, &configs) |
| 65 | addSafeJobsConfig(frontmatter, serverFilter, &configs) |
| 66 | addMCPScriptsConfig(frontmatter, serverFilter, &configs) |
| 67 | |
| 68 | // Get mcp-servers section from frontmatter |
| 69 | mcpServersSection, hasMCPServers := frontmatter["mcp-servers"] |
| 70 | if !hasMCPServers { |
| 71 | mcpLog.Print("No mcp-servers section found, checking for built-in tools") |
| 72 | // Process built-in MCP tools from tools section (github, playwright) |
| 73 | if err := extractBuiltinMCPTools(frontmatter, serverFilter, &configs); err != nil { |
| 74 | return nil, err |
| 75 | } |
| 76 | mcpLog.Printf("Extracted %d MCP configurations total", len(configs)) |
| 77 | return configs, nil // No mcp-servers configured, but we might have safe-outputs and built-in tools |
| 78 | } |
| 79 | |
| 80 | mcpServers, ok := mcpServersSection.(map[string]any) |
| 81 | if !ok { |
| 82 | return nil, fmt.Errorf("mcp-servers section must be a map, got %T. Example:\nmcp-servers:\n my-server:\n command: \"npx @my/tool\"\n args: [\"--port\", \"3000\"]", mcpServersSection) |
| 83 | } |
| 84 | |
| 85 | // Process built-in MCP tools from tools section (github, playwright) |
| 86 | if err := extractBuiltinMCPTools(frontmatter, serverFilter, &configs); err != nil { |
| 87 | return nil, err |
| 88 | } |
| 89 | |
| 90 | // Process custom MCP servers from mcp-servers section |
| 91 | mcpLog.Printf("Processing %d custom MCP servers", len(mcpServers)) |
| 92 | customConfigs, err := parseCustomMCPServerConfigs(mcpServers, serverFilter) |
| 93 | if err != nil { |
| 94 | return nil, err |
| 95 | } |
| 96 | configs = append(configs, customConfigs...) |
| 97 | |
| 98 | mcpLog.Printf("Extracted %d MCP configurations total", len(configs)) |
| 99 | return configs, nil |
| 100 | } |
| 101 | |
| 102 | func addSafeOutputsConfig(frontmatter map[string]any, serverFilter string, configs *[]RegistryMCPServerConfig) { |
| 103 | safeOutputsSection, hasSafeOutputs := frontmatter["safe-outputs"] |