run_workflow
Execute security workflows in Kubernetes and cloud environments with customizable parameters to analyze and address security findings through the RAD Security platform.
Instructions
Run a workflow with optional argument overrides
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflow_id | Yes | ID of the workflow to run | |
| async | No | If true, run asynchronously and return immediately. If false, wait for the workflow to finish. | |
| args | No | Optional arguments to override when running the workflow |
Implementation Reference
- src/operations/workflows.ts:76-128 (handler)Core handler function that executes the run_workflow tool: POSTs to start workflow run, handles async immediate return or sync polling until completion.export async function runWorkflow( client: RadSecurityClient, workflowId: string, async: boolean = true, args?: Record<string, any> ): Promise<any> { const body: Record<string, any> = {}; if (args) { body.args = args; } const response = await client.makeRequest( `/accounts/${client.getAccountId()}/workflows/${workflowId}/runs`, {}, { method: "POST", body: args??{} } ); if (!response || !response.id) { throw new Error(`Failed to run workflow ${workflowId}: no id in response`); } const runId = response.id; // If async, return immediately with the run_id if (async) { return { run_id: runId, status: "running", message: "Workflow started asynchronously" }; } // Otherwise, poll until the workflow is finished const pollInterval = 2000; // 2 seconds const maxWaitTime = 300000; // 5 minutes const startTime = Date.now(); while (true) { const runDetails = await getWorkflowRun(client, workflowId, runId); // Check if the workflow has finished const status = runDetails.status; if (status === "completed" || status === "failed" || status === "cancelled") { return runDetails; } // Check if we've exceeded the max wait time if (Date.now() - startTime > maxWaitTime) { throw new Error( `Workflow ${workflowId} run ${runId} did not finish within ${maxWaitTime / 1000} seconds. Last status: ${status}` ); } // Wait before polling again await new Promise(resolve => setTimeout(resolve, pollInterval)); } }
- src/operations/workflows.ts:13-17 (schema)Input schema validation using Zod for the run_workflow tool parameters.export const RunWorkflowSchema = z.object({ workflow_id: z.string().describe("ID of the workflow to run"), async: z.boolean().default(true).describe("If true, run asynchronously and return immediately. If false, wait for the workflow to finish."), args: z.record(z.any()).optional().describe("Optional arguments to override when running the workflow"), });
- src/index.ts:531-534 (registration)Tool registration in the list_tools response, defining name, description, and input schema.name: "run_workflow", description: "Run a workflow with optional argument overrides", inputSchema: zodToJsonSchema(workflows.RunWorkflowSchema), },
- src/index.ts:1438-1452 (registration)Dispatch handler in call_tool request that parses args with schema and invokes the runWorkflow function.case "run_workflow": { const args = workflows.RunWorkflowSchema.parse( request.params.arguments ); const response = await workflows.runWorkflow( client, args.workflow_id, args.async, args.args ); return { content: [ { type: "text", text: JSON.stringify(response, null, 2) }, ], };