generateCallWorkflowTool generates an MCP tool definition for a specific call-workflow target. The tool will be named after the workflow (normalized to underscores) and accept the workflow's defined workflow_call inputs as parameters. The agent calls this tool to select which worker to activate; the
(workflowName string, workflowInputs map[string]any)
| 64 | // The agent calls this tool to select which worker to activate; the handler writes |
| 65 | // call_workflow_name and call_workflow_payload outputs for the conditional `uses:` jobs. |
| 66 | func generateCallWorkflowTool(workflowName string, workflowInputs map[string]any) map[string]any { |
| 67 | safeOutputsCallWorkflowLog.Printf("Generating call-workflow tool: workflow=%s, inputs=%d", workflowName, len(workflowInputs)) |
| 68 | tool := generateWorkflowToolDefinition(workflowToolDefinitionOptions{ |
| 69 | workflowName: workflowName, |
| 70 | workflowInputs: workflowInputs, |
| 71 | descriptionFormat: "Call the '%s' reusable workflow via workflow_call. This workflow must support workflow_call and be in .github/workflows/ directory in the same repository.", |
| 72 | metadataKey: "_call_workflow_name", |
| 73 | }) |
| 74 | |
| 75 | inputSchema, _ := tool["inputSchema"].(map[string]any) |
| 76 | properties, _ := inputSchema["properties"].(map[string]any) |
| 77 | requiredCount := 0 |
| 78 | if required, ok := inputSchema["required"].([]string); ok { |
| 79 | requiredCount = len(required) |
| 80 | } |
| 81 | safeOutputsCallWorkflowLog.Printf("Generated call-workflow tool: name=%s, properties=%d, required=%d", tool["name"], len(properties), requiredCount) |
| 82 | return tool |
| 83 | } |