update_workflow
Modify existing workflows by applying changes to their configuration and optionally incrementing version numbers for version control.
Instructions
Update an existing workflow with optional version increment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| updates | Yes | ||
| increment_version | No |
Implementation Reference
- src/index.ts:412-470 (handler)The primary handler function for the 'update_workflow' tool. Parses input arguments, retrieves the existing workflow from storage, validates partial updates, merges updates while preserving ID and updating metadata, optionally increments the semantic version, fully validates the updated workflow, saves it, and returns a JSON success response with the workflow ID and new version.private async updateWorkflow(args: unknown) { const parsed = UpdateWorkflowSchema.parse(args); const workflow = await this.storage.get(parsed.id); if (!workflow) { throw new Error(`Workflow not found: ${parsed.id}`); } // Validate partial update const validation = WorkflowValidator.validatePartialWorkflow(parsed.updates); if (!validation.success) { throw new Error(`Validation failed: ${validation.error}`); } // Apply updates const updatedWorkflow = { ...workflow, ...parsed.updates, id: workflow.id, // Prevent ID change metadata: { created_at: workflow.metadata?.created_at || new Date().toISOString(), updated_at: new Date().toISOString(), times_run: workflow.metadata?.times_run || 0, created_by: workflow.metadata?.created_by, average_duration_ms: workflow.metadata?.average_duration_ms, success_rate: workflow.metadata?.success_rate, last_run_at: workflow.metadata?.last_run_at, }, }; // Increment version if requested if (parsed.increment_version) { const [major, minor, patch] = updatedWorkflow.version.split('.').map(Number); updatedWorkflow.version = `${major}.${minor}.${patch + 1}`; } // Validate complete workflow const fullValidation = WorkflowValidator.validateWorkflow(updatedWorkflow); if (!fullValidation.success) { throw new Error(`Validation failed: ${fullValidation.error}`); } // Save await this.storage.save(updatedWorkflow); return { content: [ { type: 'text', text: JSON.stringify({ success: true, workflow_id: parsed.id, version: updatedWorkflow.version, message: `Workflow "${updatedWorkflow.name}" updated successfully`, }, null, 2), }, ], }; }
- src/index.ts:55-59 (schema)Zod input validation schema for the 'update_workflow' tool, requiring a workflow 'id' (string), 'updates' as a flexible record/object of changes, and optional 'increment_version' boolean flag.const UpdateWorkflowSchema = z.object({ id: z.string(), updates: z.record(z.any()), increment_version: z.boolean().optional(), });
- src/index.ts:268-271 (registration)MCP tool registration object in the getTools() array, specifying the tool name, description, and input schema converted to JSON schema format for the Model Context Protocol.name: 'update_workflow', description: 'Update an existing workflow with optional version increment', inputSchema: zodToJsonSchema(UpdateWorkflowSchema), },
- src/index.ts:128-129 (registration)Switch case dispatcher in the CallToolRequestSchema handler that routes incoming 'update_workflow' tool calls to the private updateWorkflow method.case 'update_workflow': return await this.updateWorkflow(args);