list-tasks
Retrieve and display all tasks from a specified task list, with options to include completed, hidden, or deleted tasks, using the Google Tasks MCP Server integration.
Instructions
List all tasks in a task list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| showCompleted | No | Whether to include completed tasks | |
| showDeleted | No | Whether to include deleted tasks | |
| showHidden | No | Whether to include hidden tasks | |
| tasklist | Yes | Task list ID |
Implementation Reference
- src/index.ts:470-538 (handler)Handler function that authenticates the user, fetches tasks from Google Tasks API using tasks.tasks.list(), formats them, and returns as JSON or error messages.async ({ tasklist, showCompleted = true, showHidden = false, showDeleted = false, }) => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { const response: any = await tasks.tasks.list({ tasklist, showCompleted, showHidden, showDeleted, }); const tasksResponse = response.data.items || []; if (tasksResponse.length === 0) { return { content: [ { type: "text", text: "No tasks found in this list.", }, ], }; } const formattedTasks = tasksResponse.map((task: any) => ({ id: task.id, title: task.title, status: task.status, due: task.due, notes: task.notes, completed: task.completed, })); return { content: [ { type: "text", text: JSON.stringify(formattedTasks, null, 2), }, ], }; } catch (error) { console.error("Error listing tasks:", error); return { isError: true, content: [ { type: "text", text: `Error listing tasks: ${error}`, }, ], }; } }
- src/index.ts:455-469 (schema)Zod input schema defining parameters for the list-tasks tool: required tasklist ID and optional flags for showing completed, hidden, and deleted tasks.{ tasklist: z.string().describe("Task list ID"), showCompleted: z .boolean() .optional() .describe("Whether to include completed tasks"), showHidden: z .boolean() .optional() .describe("Whether to include hidden tasks"), showDeleted: z .boolean() .optional() .describe("Whether to include deleted tasks"), },
- src/index.ts:452-539 (registration)Full registration of the 'list-tasks' tool on the MCP server using server.tool(), including name, description, input schema, and inline handler function.server.tool( "list-tasks", "List all tasks in a task list", { tasklist: z.string().describe("Task list ID"), showCompleted: z .boolean() .optional() .describe("Whether to include completed tasks"), showHidden: z .boolean() .optional() .describe("Whether to include hidden tasks"), showDeleted: z .boolean() .optional() .describe("Whether to include deleted tasks"), }, async ({ tasklist, showCompleted = true, showHidden = false, showDeleted = false, }) => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { const response: any = await tasks.tasks.list({ tasklist, showCompleted, showHidden, showDeleted, }); const tasksResponse = response.data.items || []; if (tasksResponse.length === 0) { return { content: [ { type: "text", text: "No tasks found in this list.", }, ], }; } const formattedTasks = tasksResponse.map((task: any) => ({ id: task.id, title: task.title, status: task.status, due: task.due, notes: task.notes, completed: task.completed, })); return { content: [ { type: "text", text: JSON.stringify(formattedTasks, null, 2), }, ], }; } catch (error) { console.error("Error listing tasks:", error); return { isError: true, content: [ { type: "text", text: `Error listing tasks: ${error}`, }, ], }; } } );