complete-task
Mark tasks as completed in Google Tasks to track progress and manage task lists through Claude.
Instructions
Mark a task as completed
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tasklist | Yes | Task list ID | |
| task | Yes | Task ID to mark as completed |
Implementation Reference
- src/index.ts:797-854 (handler)Handler function that authenticates the user, fetches the task, updates its status to 'completed' with a timestamp, and returns the updated task details or an error.async ({ tasklist, task }) => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { // Get the current task const currentTask = await tasks.tasks.get({ tasklist, task, }); // Update the status to completed const requestBody = { ...currentTask.data, status: "completed", completed: new Date().toISOString(), }; const response = await tasks.tasks.update({ tasklist, task, requestBody, }); return { content: [ { type: "text", text: `Task marked as completed:\n\n${JSON.stringify( response.data, null, 2 )}`, }, ], }; } catch (error) { console.error("Error completing task:", error); return { isError: true, content: [ { type: "text", text: `Error completing task: ${error}`, }, ], }; } }
- src/index.ts:793-796 (schema)Zod schema defining input parameters: tasklist ID and task ID.{ tasklist: z.string().describe("Task list ID"), task: z.string().describe("Task ID to mark as completed"), },
- src/index.ts:790-855 (registration)Registration of the 'complete-task' tool using server.tool, including name, description, input schema, and handler function.server.tool( "complete-task", "Mark a task as completed", { tasklist: z.string().describe("Task list ID"), task: z.string().describe("Task ID to mark as completed"), }, async ({ tasklist, task }) => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { // Get the current task const currentTask = await tasks.tasks.get({ tasklist, task, }); // Update the status to completed const requestBody = { ...currentTask.data, status: "completed", completed: new Date().toISOString(), }; const response = await tasks.tasks.update({ tasklist, task, requestBody, }); return { content: [ { type: "text", text: `Task marked as completed:\n\n${JSON.stringify( response.data, null, 2 )}`, }, ], }; } catch (error) { console.error("Error completing task:", error); return { isError: true, content: [ { type: "text", text: `Error completing task: ${error}`, }, ], }; } } );