listWorkflowsWithMCPServers shows available workflow files that contain MCP configurations with optional interactive selection
(workflowsDir string, verbose bool)
| 131 | // listWorkflowsWithMCPServers shows available workflow files that contain MCP configurations |
| 132 | // with optional interactive selection |
| 133 | func listWorkflowsWithMCPServers(workflowsDir string, verbose bool) error { |
| 134 | // Scan workflows for MCP configurations |
| 135 | results, err := ScanWorkflowsForMCP(workflowsDir, "", verbose) |
| 136 | if err != nil { |
| 137 | return err |
| 138 | } |
| 139 | |
| 140 | var workflowData []struct { |
| 141 | name string |
| 142 | serverCount int |
| 143 | serverNames []string |
| 144 | } |
| 145 | var totalMCPCount int |
| 146 | |
| 147 | for _, result := range results { |
| 148 | serverNames := sliceutil.Map(result.MCPConfigs, func(config parser.RegistryMCPServerConfig) string { return config.Name }) |
| 149 | |
| 150 | workflowData = append(workflowData, struct { |
| 151 | name string |
| 152 | serverCount int |
| 153 | serverNames []string |
| 154 | }{ |
| 155 | name: result.BaseName, |
| 156 | serverCount: len(result.MCPConfigs), |
| 157 | serverNames: serverNames, |
| 158 | }) |
| 159 | totalMCPCount += len(result.MCPConfigs) |
| 160 | } |
| 161 | |
| 162 | if len(workflowData) == 0 { |
| 163 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No workflows with MCP servers found")) |
| 164 | return nil |
| 165 | } |
| 166 | |
| 167 | // Try interactive selection first in TTY mode |
| 168 | selectedWorkflow, err := showInteractiveMCPWorkflowSelection(workflowData, verbose) |
| 169 | if err == nil && selectedWorkflow != "" { |
| 170 | // User selected a workflow, show its details |
| 171 | mcpListLog.Printf("User selected workflow: %s", selectedWorkflow) |
| 172 | return ListWorkflowMCP(selectedWorkflow, verbose) |
| 173 | } |
| 174 | |
| 175 | // If interactive selection failed or was cancelled, fall back to table display |
| 176 | mcpListLog.Printf("Interactive selection failed or cancelled, showing table: %v", err) |
| 177 | |
| 178 | // Display results in table format |
| 179 | if verbose { |
| 180 | // Detailed table with server names |
| 181 | headers := []string{"Workflow", "Server Count", "MCP Servers"} |
| 182 | rows := make([][]string, 0, len(workflowData)) |
| 183 | |
| 184 | for _, workflow := range workflowData { |
| 185 | serverList := strings.Join(workflow.serverNames, ", ") |
| 186 | // Truncate if too long |
| 187 | serverList = stringutil.Truncate(serverList, 50) |
| 188 | |
| 189 | rows = append(rows, []string{ |
| 190 | workflow.name, |