update_task
Modify existing tasks in the Task Manager MCP Server by updating titles, descriptions, priorities, categories, due dates, or statuses to keep task information current and accurate.
Instructions
Update an existing task
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | Task ID (use first 8 characters) | |
| title | No | New title | |
| description | No | New description | |
| priority | No | New priority | |
| category | No | New category | |
| dueDate | No | New due date (YYYY-MM-DD) | |
| status | No | New status |
Implementation Reference
- src/tools.ts:129-189 (handler)Executes the update_task tool: validates args with UpdateTaskSchema, loads tasks, finds task by partial ID, updates fields, saves, returns formatted response.export async function updateTask(args: unknown) { // Validate input const validated = UpdateTaskSchema.parse(args); // Load tasks const storage = await loadTasks(); // Find task by ID (partial match) const taskIndex = storage.tasks.findIndex((t) => t.id.startsWith(validated.taskId) ); if (taskIndex === -1) { return { content: [ { type: "text", text: `❌ Task with ID ${validated.taskId} not found.`, }, ], }; } const task = storage.tasks[taskIndex]!; // Update fields if provided if (validated.title !== undefined) { task.title = validated.title; } if (validated.description !== undefined) { task.description = validated.description; } if (validated.priority !== undefined) { task.priority = validated.priority as Priority; } if (validated.category !== undefined) { task.category = validated.category; } if (validated.dueDate !== undefined) { task.dueDate = validated.dueDate; } if (validated.status !== undefined) { task.status = validated.status as Status; if (validated.status === "completed" && !task.completedAt) { task.completedAt = new Date().toISOString(); } else if (validated.status !== "completed") { task.completedAt = undefined; } } await saveTasks(storage); return { content: [ { type: "text", text: `✅ Task updated successfully!\n\n${formatTask(task)}`, }, ], }; }
- src/types.ts:48-59 (schema)Zod schema defining the input validation for update_task tool arguments.export const UpdateTaskSchema = z.object({ taskId: z.string().min(8, "Task ID must be at least 8 characters"), title: z.string().optional(), description: z.string().optional(), priority: z.enum(["low", "medium", "high"]).optional(), category: z.string().optional(), dueDate: z .string() .regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be YYYY-MM-DD") .optional(), status: z.enum(["pending", "in_progress", "completed"]).optional(), });
- src/index.ts:84-125 (registration)Registers the update_task tool in the TOOLS array with name, description, and JSON inputSchema for MCP ListToolsRequest.{ name: "update_task", description: "Update an existing task", inputSchema: { type: "object", properties: { taskId: { type: "string", description: "Task ID (use first 8 characters)", minLength: 8, }, title: { type: "string", description: "New title", }, description: { type: "string", description: "New description", }, priority: { type: "string", enum: ["low", "medium", "high"], description: "New priority", }, category: { type: "string", description: "New category", }, dueDate: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "New due date (YYYY-MM-DD)", }, status: { type: "string", enum: ["pending", "in_progress", "completed"], description: "New status", }, }, required: ["taskId"], }, },
- src/index.ts:221-222 (registration)Dispatches calls to the updateTask handler function in the MCP CallToolRequest switch statement.case "update_task": return await updateTask(args);