update_tasks
Modify multiple tasks by updating descriptions, statuses, priorities, due dates, or tags in a single operation using structured input. Streamlines task management for enhanced productivity.
Instructions
Update multiple tasks with new values.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| updates | Yes | List of task updates to apply |
Implementation Reference
- src/tasks/tools.ts:198-258 (handler)The main handler function for the 'update_tasks' tool. It validates input using UpdateTasksSchema, iterates over updates, checks task existence and dependencies, updates via taskStorage.update, collects results, and returns JSON with success/failure counts.execute: async (params: any) => { try { // Validate input parameters const validatedParams = UpdateTasksSchema.parse(params); const results = []; for (const { id, ...changes } of validatedParams.updates) { try { // Verify task exists const task = taskStorage.get(id); if (!task) { results.push({ id, success: false, error: `Task with ID ${id} not found` }); continue; } // Validate dependencies if they exist if (changes.dependsOn) { const missingDependencies = changes.dependsOn.filter(depId => !taskStorage.get(depId)); if (missingDependencies.length > 0) { results.push({ id, success: false, error: `Dependencies not found: ${missingDependencies.join(', ')}` }); continue; } } // Update task const updatedTask = taskStorage.update(id, changes); results.push({ id, success: true, task: updatedTask }); } catch (error) { results.push({ id, success: false, error: `Error updating task: ${error instanceof Error ? error.message : String(error)}` }); } } return JSON.stringify({ updates: results, success: results.filter((r: any) => r.success).length, failed: results.filter((r: any) => !r.success).length }); } catch (error) { return JSON.stringify({ error: `Invalid update_tasks parameters: ${error instanceof Error ? error.message : String(error)}` }); } }
- src/tasks/tools.ts:37-50 (schema)Zod schema definition for validating the input parameters of the update_tasks tool, defining an array of updates each with id and optional fields.// Schema for update_tasks parameters const UpdateTasksSchema = z.object({ updates: z.array( z.object({ id: z.string().uuid(), description: z.string().min(3, "Description must be at least 3 characters").optional(), status: TaskStatusEnum.optional(), priority: TaskPriorityEnum.optional(), due: z.string().datetime().optional(), tags: z.array(z.string()).optional(), dependsOn: z.array(z.string().uuid()).optional() }) ) });
- src/tasks/tools.ts:195-259 (registration)The server.addTool call that registers the update_tasks tool within the registerTaskTools function.server.addTool({ name: "update_tasks", description: "Update multiple tasks with new values.", execute: async (params: any) => { try { // Validate input parameters const validatedParams = UpdateTasksSchema.parse(params); const results = []; for (const { id, ...changes } of validatedParams.updates) { try { // Verify task exists const task = taskStorage.get(id); if (!task) { results.push({ id, success: false, error: `Task with ID ${id} not found` }); continue; } // Validate dependencies if they exist if (changes.dependsOn) { const missingDependencies = changes.dependsOn.filter(depId => !taskStorage.get(depId)); if (missingDependencies.length > 0) { results.push({ id, success: false, error: `Dependencies not found: ${missingDependencies.join(', ')}` }); continue; } } // Update task const updatedTask = taskStorage.update(id, changes); results.push({ id, success: true, task: updatedTask }); } catch (error) { results.push({ id, success: false, error: `Error updating task: ${error instanceof Error ? error.message : String(error)}` }); } } return JSON.stringify({ updates: results, success: results.filter((r: any) => r.success).length, failed: results.filter((r: any) => !r.success).length }); } catch (error) { return JSON.stringify({ error: `Invalid update_tasks parameters: ${error instanceof Error ? error.message : String(error)}` }); } } });
- src/core/tools.ts:24-24 (registration)Higher-level call to registerTaskTools from registerAllTools, which includes the update_tasks tool registration.registerTaskTools(server);