google_tasks_complete_task
Mark a specific task as completed in Google Tasks by providing its task ID and optional task list ID to manage tasks efficiently.
Instructions
Mark a task as completed
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | ID of the task to complete | |
| taskListId | No | ID of the task list the task belongs to (uses default if not specified) |
Implementation Reference
- handlers/tasks.ts:113-126 (handler)The primary handler function that validates input arguments using isCompleteTaskArgs and calls the GoogleTasks.completeTask method to mark the task as completed.
export async function handleTasksCompleteTask( args: any, googleTasksInstance: GoogleTasks ) { if (!isCompleteTaskArgs(args)) { throw new Error("Invalid arguments for google_tasks_complete_task"); } const { taskId, taskListId } = args; const result = await googleTasksInstance.completeTask(taskId, taskListId); return { content: [{ type: "text", text: result }], isError: false, }; } - tools/tasks/index.ts:131-149 (schema)Defines the tool's metadata, description, and input schema specifying required taskId and optional taskListId.
export const COMPLETE_TASK_TOOL: Tool = { name: "google_tasks_complete_task", description: "Mark a task as completed", inputSchema: { type: "object", properties: { taskId: { type: "string", description: "ID of the task to complete", }, taskListId: { type: "string", description: "ID of the task list the task belongs to (uses default if not specified)", }, }, required: ["taskId"], }, }; - server-setup.ts:243-247 (registration)Dispatches calls to 'google_tasks_complete_task' to the corresponding handler function within the MCP server's CallToolRequest handler.
case "google_tasks_complete_task": return await tasksHandlers.handleTasksCompleteTask( args, googleTasksInstance ); - utils/helper.ts:384-393 (schema)Type guard for validating input arguments match the expected shape: required taskId (string) and optional taskListId (string).
export function isCompleteTaskArgs(args: any): args is { taskId: string; taskListId?: string; } { return ( args && typeof args.taskId === "string" && (args.taskListId === undefined || typeof args.taskListId === "string") ); } - utils/tasks.ts:184-198 (helper)Core implementation in GoogleTasks class that marks a task as completed by calling updateTask with status 'completed', using Google Tasks API.
async completeTask(taskId: string, taskListId?: string) { try { const targetTaskList = taskListId || this.defaultTaskList; await this.updateTask(taskId, { status: "completed" }, targetTaskList); return `Task ${taskId} marked as completed.`; } catch (error) { throw new Error( `Failed to complete task: ${ error instanceof Error ? error.message : String(error) }` ); } }