update-task
Modify existing Google Tasks by updating title, notes, status, or due date to keep task information current and accurate.
Instructions
Update an existing task
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tasklist | Yes | Task list ID | |
| task | Yes | Task ID | |
| title | No | New title for the task | |
| notes | No | New notes for the task | |
| status | No | Status of the task | |
| due | No | Due date in RFC 3339 format (e.g., 2025-03-19T12:00:00Z) |
Implementation Reference
- src/index.ts:676-736 (handler)The handler function that implements the logic for updating an existing task in a Google Tasks list. It fetches the current task, merges updates, and calls the Google Tasks API update method.async ({ tasklist, task, title, notes, status, due }) => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { // First, get the current task data const currentTask = await tasks.tasks.get({ tasklist, task, }); // Prepare the update request const requestBody: any = { ...currentTask.data, }; if (title !== undefined) requestBody.title = title; if (notes !== undefined) requestBody.notes = notes; if (status !== undefined) requestBody.status = status; if (due !== undefined) requestBody.due = due; const response = await tasks.tasks.update({ tasklist, task, requestBody, }); return { content: [ { type: "text", text: `Task updated successfully:\n\n${JSON.stringify( response.data, null, 2 )}`, }, ], }; } catch (error) { console.error("Error updating task:", error); return { isError: true, content: [ { type: "text", text: `Error updating task: ${error}`, }, ], }; } }
- src/index.ts:663-675 (schema)Zod input schema defining parameters for the update-task tool: required tasklist and task IDs, optional title, notes, status, and due date.tasklist: z.string().describe("Task list ID"), task: z.string().describe("Task ID"), title: z.string().optional().describe("New title for the task"), notes: z.string().optional().describe("New notes for the task"), status: z .enum(["needsAction", "completed"]) .optional() .describe("Status of the task"), due: z .string() .optional() .describe("Due date in RFC 3339 format (e.g., 2025-03-19T12:00:00Z)"), },
- src/index.ts:659-737 (registration)The server.tool registration call that defines and registers the 'update-task' tool with its description, input schema, and handler function.server.tool( "update-task", "Update an existing task", { tasklist: z.string().describe("Task list ID"), task: z.string().describe("Task ID"), title: z.string().optional().describe("New title for the task"), notes: z.string().optional().describe("New notes for the task"), status: z .enum(["needsAction", "completed"]) .optional() .describe("Status of the task"), due: z .string() .optional() .describe("Due date in RFC 3339 format (e.g., 2025-03-19T12:00:00Z)"), }, async ({ tasklist, task, title, notes, status, due }) => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { // First, get the current task data const currentTask = await tasks.tasks.get({ tasklist, task, }); // Prepare the update request const requestBody: any = { ...currentTask.data, }; if (title !== undefined) requestBody.title = title; if (notes !== undefined) requestBody.notes = notes; if (status !== undefined) requestBody.status = status; if (due !== undefined) requestBody.due = due; const response = await tasks.tasks.update({ tasklist, task, requestBody, }); return { content: [ { type: "text", text: `Task updated successfully:\n\n${JSON.stringify( response.data, null, 2 )}`, }, ], }; } catch (error) { console.error("Error updating task:", error); return { isError: true, content: [ { type: "text", text: `Error updating task: ${error}`, }, ], }; } } );