google_tasks_list_tasks
Retrieve tasks from a specified Google task list, with options to include or exclude completed tasks, for integration and management within AI-driven workflows.
Instructions
List tasks from a task list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| showCompleted | No | Whether to include completed tasks | |
| taskListId | No | ID of the task list to retrieve tasks from (uses default if not specified) |
Implementation Reference
- handlers/tasks.ts:44-57 (handler)Main handler function that validates arguments and delegates to GoogleTasks.listTasks to execute the tool.export async function handleTasksListTasks( args: any, googleTasksInstance: GoogleTasks ) { if (!isListTasksArgs(args)) { throw new Error("Invalid arguments for google_tasks_list_tasks"); } const { taskListId, showCompleted } = args; const result = await googleTasksInstance.listTasks(taskListId, showCompleted); return { content: [{ type: "text", text: result }], isError: false, }; }
- tools/tasks/index.ts:27-44 (schema)Defines the Tool object with inputSchema for google_tasks_list_tasks.export const LIST_TASKS_TOOL: Tool = { name: "google_tasks_list_tasks", description: "List tasks from a task list", inputSchema: { type: "object", properties: { taskListId: { type: "string", description: "ID of the task list to retrieve tasks from (uses default if not specified)", }, showCompleted: { type: "boolean", description: "Whether to include completed tasks", }, }, }, };
- server-setup.ts:223-227 (registration)Dispatches tool calls to the specific handler in the main server request handler.case "google_tasks_list_tasks": return await tasksHandlers.handleTasksListTasks( args, googleTasksInstance );
- utils/tasks.ts:39-77 (helper)Core implementation in GoogleTasks class that calls Google Tasks API to list tasks and formats the output.async listTasks(taskListId?: string, showCompleted: boolean = false) { try { const targetTaskList = taskListId || this.defaultTaskList; const response = await this.tasks.tasks.list({ tasklist: targetTaskList, showCompleted: showCompleted, maxResults: 100, }); if (!response.data.items || response.data.items.length === 0) { return `No tasks found in task list: ${targetTaskList}`; } // Format the tasks return response.data.items .map((task: any, index: number) => { const due = task.due ? `Due: ${new Date(task.due).toLocaleString()}` : ""; const completed = task.completed ? `Completed: ${new Date(task.completed).toLocaleString()}` : ""; const status = task.status || ""; return `[${index + 1}] ${task.title} - ID: ${task.id} Status: ${status} ${due} ${completed} ${task.notes ? `Notes: ${task.notes}` : ""}`; }) .join("\n\n"); } catch (error) { throw new Error( `Failed to list tasks: ${ error instanceof Error ? error.message : String(error) }` ); } }
- utils/helper.ts:327-337 (schema)Input validation type guard matching the tool's input schema.export function isListTasksArgs(args: any): args is { taskListId?: string; showCompleted?: boolean; } { return ( args && (args.taskListId === undefined || typeof args.taskListId === "string") && (args.showCompleted === undefined || typeof args.showCompleted === "boolean") ); }