google_tasks_delete_task
Removes a specific task from a Google Tasks list by providing its task ID. Optionally, specify the task list ID for targeted deletion within Google MCP server.
Instructions
Delete a task
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | ID of the task to delete | |
| taskListId | No | ID of the task list the task belongs to (uses default if not specified) |
Implementation Reference
- handlers/tasks.ts:128-141 (handler)The main handler function that validates the input arguments and invokes the GoogleTasks instance to delete the specified task.export async function handleTasksDeleteTask( args: any, googleTasksInstance: GoogleTasks ) { if (!isDeleteTaskArgs(args)) { throw new Error("Invalid arguments for google_tasks_delete_task"); } const { taskId, taskListId } = args; const result = await googleTasksInstance.deleteTask(taskId, taskListId); return { content: [{ type: "text", text: result }], isError: false, }; }
- tools/tasks/index.ts:151-169 (schema)The tool's schema definition, including input schema for parameters taskId (required) and optional taskListId.export const DELETE_TASK_TOOL: Tool = { name: "google_tasks_delete_task", description: "Delete a task", inputSchema: { type: "object", properties: { taskId: { type: "string", description: "ID of the task to delete", }, taskListId: { type: "string", description: "ID of the task list the task belongs to (uses default if not specified)", }, }, required: ["taskId"], }, };
- server-setup.ts:248-252 (registration)Registration in the server request handler's switch statement that dispatches calls to this tool to the appropriate handler function.case "google_tasks_delete_task": return await tasksHandlers.handleTasksDeleteTask( args, googleTasksInstance );
- utils/tasks.ts:200-217 (helper)Core helper method in the GoogleTasks class that calls the Google Tasks API to delete the task.async deleteTask(taskId: string, taskListId?: string) { try { const targetTaskList = taskListId || this.defaultTaskList; await this.tasks.tasks.delete({ tasklist: targetTaskList, task: taskId, }); return `Task ${taskId} deleted from task list ${targetTaskList}.`; } catch (error) { throw new Error( `Failed to delete task: ${ error instanceof Error ? error.message : String(error) }` ); } }
- utils/helper.ts:395-404 (schema)Type guard (schema validator) used in the handler to validate input arguments match the expected types.export function isDeleteTaskArgs(args: any): args is { taskId: string; taskListId?: string; } { return ( args && typeof args.taskId === "string" && (args.taskListId === undefined || typeof args.taskListId === "string") ); }