loadWorkflowMCPConfigs loads a workflow file and extracts MCP configurations. This is a shared helper used by multiple MCP commands to avoid code duplication. Parameters: - workflowPath: absolute path to the workflow file - serverFilter: optional server name to filter by (empty string for no filter
(workflowPath string, serverFilter string)
| 22 | // - []parser.RegistryMCPServerConfig: list of MCP server configurations |
| 23 | // - error: any error that occurred during loading or parsing |
| 24 | func loadWorkflowMCPConfigs(workflowPath string, serverFilter string) (*parser.FrontmatterResult, []parser.RegistryMCPServerConfig, error) { |
| 25 | mcpWorkflowLoaderLog.Printf("Loading MCP configs: path=%s, server_filter=%q", workflowPath, serverFilter) |
| 26 | |
| 27 | // Read the workflow file |
| 28 | content, err := os.ReadFile(workflowPath) |
| 29 | if err != nil { |
| 30 | return nil, nil, fmt.Errorf("failed to read workflow file: %w", err) |
| 31 | } |
| 32 | |
| 33 | // Parse the frontmatter |
| 34 | workflowData, err := parser.ExtractFrontmatterFromContent(string(content)) |
| 35 | if err != nil { |
| 36 | return nil, nil, fmt.Errorf("failed to parse workflow file: %w", err) |
| 37 | } |
| 38 | |
| 39 | // Extract MCP configurations |
| 40 | mcpConfigs, err := parser.ExtractMCPConfigurations(workflowData.Frontmatter, serverFilter) |
| 41 | if err != nil { |
| 42 | return nil, nil, fmt.Errorf("failed to extract MCP configurations: %w", err) |
| 43 | } |
| 44 | |
| 45 | mcpWorkflowLoaderLog.Printf("Loaded %d MCP configurations from workflow", len(mcpConfigs)) |
| 46 | return workflowData, mcpConfigs, nil |
| 47 | } |