list-tasklists
Retrieve and display all task lists from Google Tasks. Ideal for managing and organizing tasks efficiently through the MCP server interface.
Instructions
List all task lists
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:188-242 (handler)The handler function for the "list-tasklists" tool. It checks authentication, fetches all task lists from Google Tasks API using tasks.tasklists.list(), formats them, and returns as JSON. Handles errors and empty lists.server.tool("list-tasklists", "List all task lists", {}, async () => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { const response = await tasks.tasklists.list(); const taskLists = response.data.items || []; if (taskLists.length === 0) { return { content: [ { type: "text", text: "No task lists found.", }, ], }; } const formattedLists = taskLists.map((list) => ({ id: list.id, title: list.title, updated: list.updated, })); return { content: [ { type: "text", text: JSON.stringify(formattedLists, null, 2), }, ], }; } catch (error) { console.error("Error listing task lists:", error); return { isError: true, content: [ { type: "text", text: `Error listing task lists: ${error}`, }, ], }; } });
- src/index.ts:47-49 (helper)Helper function used by the tool to check if the user is authenticated with Google OAuth.function isAuthenticated() { return credentials !== null; }
- src/index.ts:188-242 (registration)Registers the "list-tasklists" tool with MCP server, providing description, empty input schema, and the handler function.server.tool("list-tasklists", "List all task lists", {}, async () => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { const response = await tasks.tasklists.list(); const taskLists = response.data.items || []; if (taskLists.length === 0) { return { content: [ { type: "text", text: "No task lists found.", }, ], }; } const formattedLists = taskLists.map((list) => ({ id: list.id, title: list.title, updated: list.updated, })); return { content: [ { type: "text", text: JSON.stringify(formattedLists, null, 2), }, ], }; } catch (error) { console.error("Error listing task lists:", error); return { isError: true, content: [ { type: "text", text: `Error listing task lists: ${error}`, }, ], }; } });