complete-task
Mark specific tasks as completed in Google Tasks by providing the task list ID and task ID through the Google Tasks MCP Server interface.
Instructions
Mark a task as completed
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task | Yes | Task ID to mark as completed | |
| tasklist | Yes | Task list ID |
Implementation Reference
- src/index.ts:797-854 (handler)The main handler function for the 'complete-task' tool. It checks authentication, retrieves the task, updates its status to 'completed' with a timestamp, calls the tasks.update API, and returns success or error response.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 the input parameters: tasklist (string) and task (string).{ tasklist: z.string().describe("Task list ID"), task: z.string().describe("Task ID to mark as completed"), },
- src/index.ts:789-855 (registration)The server.tool registration call for the 'complete-task' tool, including name, description, schema, and inline handler.// 6. Complete a task 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}`, }, ], }; } } );