update-task
Modify task details in Google Tasks, including title, notes, status, and due date, using the task list and task IDs for precise updates.
Instructions
Update an existing task
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| due | No | Due date in RFC 3339 format (e.g., 2025-03-19T12:00:00Z) | |
| notes | No | New notes for the task | |
| status | No | Status of the task | |
| task | Yes | Task ID | |
| tasklist | Yes | Task list ID | |
| title | No | New title for the task |
Implementation Reference
- src/index.ts:676-737 (handler)The main handler function that checks authentication, fetches the current task, merges updates, calls Google Tasks API to update, and returns success or error response.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:662-675 (schema)Zod schema for input validation of the update-task tool parameters.{ 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-738 (registration)MCP server tool registration for 'update-task', specifying name, 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}`, }, ], }; } } );