generateDispatchWorkflowTool generates an MCP tool definition for a specific workflow. The tool will be named after the workflow (normalized to underscores) and accept the workflow's defined workflow_dispatch inputs as parameters.
(workflowName string, workflowInputs map[string]any)
| 95 | // The tool will be named after the workflow (normalized to underscores) and accept |
| 96 | // the workflow's defined workflow_dispatch inputs as parameters. |
| 97 | func generateDispatchWorkflowTool(workflowName string, workflowInputs map[string]any) map[string]any { |
| 98 | safeOutputsDispatchWorkflowLog.Printf("Generating dispatch-workflow tool: workflow=%s, inputs=%d", workflowName, len(workflowInputs)) |
| 99 | tool := generateWorkflowToolDefinition(workflowToolDefinitionOptions{ |
| 100 | workflowName: workflowName, |
| 101 | workflowInputs: workflowInputs, |
| 102 | descriptionFormat: "Dispatch the '%s' workflow with workflow_dispatch trigger. This workflow must support workflow_dispatch and be in .github/workflows/ directory in the same repository.", |
| 103 | metadataKey: "_workflow_name", |
| 104 | }) |
| 105 | |
| 106 | inputSchema, _ := tool["inputSchema"].(map[string]any) |
| 107 | properties, _ := inputSchema["properties"].(map[string]any) |
| 108 | requiredCount := 0 |
| 109 | if required, ok := inputSchema["required"].([]string); ok { |
| 110 | requiredCount = len(required) |
| 111 | } |
| 112 | safeOutputsDispatchWorkflowLog.Printf("Generated dispatch-workflow tool: name=%s, properties=%d, required=%d", tool["name"], len(properties), requiredCount) |
| 113 | return tool |
| 114 | } |