get_tasks_list
Retrieve tasks from Todoist with filtering options for projects, sections, labels, or custom queries to manage your to-do list.
Instructions
Get tasks list from Todoist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No | Filter by project | |
| section_id | No | Filter by section | |
| label | No | Filter by label | |
| filter | No | Natural language english filter like "search: keyword", "today", "date before: +4 hours", "date after: May 5", "no date", "no time", "overdue", "7 days & @waiting", "created before: -365 days", "assigned to: person", "added by: me", "#Project & !assigned", "subtask", "!subtask", "P1 | P2", "today & @email", "@work | @office", "(today | overdue) & #Work", "all & 7 days", "!assigned", "Today & !#Work" | |
| ids | No | Comma-separated list of task IDs | |
| limit | No |
Implementation Reference
- src/tools/tasks.ts:65-83 (registration)Registration and schema definition for the 'get_tasks_list' tool, specifying input parameters for filtering Todoist tasks and mapping to GET /tasks API endpoint.createApiHandler({ name: 'get_tasks_list', description: 'Get tasks list from Todoist', schemaShape: { project_id: z.string().optional().describe('Filter by project'), section_id: z.string().optional().describe('Filter by section'), label: z.string().optional().describe('Filter by label'), filter: z .string() .optional() .describe( 'Natural language english filter like "search: keyword", "today", "date before: +4 hours", "date after: May 5", "no date", "no time", "overdue", "7 days & @waiting", "created before: -365 days", "assigned to: person", "added by: me", "#Project & !assigned", "subtask", "!subtask", "P1 | P2", "today & @email", "@work | @office", "(today | overdue) & #Work", "all & 7 days", "!assigned", "Today & !#Work"' ), ids: z.string().optional().describe('Comma-separated list of task IDs'), limit: z.number().optional().default(50), }, method: 'GET', path: '/tasks', });
- src/utils/handlers.ts:92-146 (handler)Core handler logic for API-based tools like get_tasks_list: processes arguments into path and query params, validates path parameters, and calls todoistApi.get('/tasks', finalParams) for GET requests.const handler = async (args: z.infer<z.ZodObject<T>>): Promise<R> => { let finalPath = options.path; const pathParams: Record<string, string> = {}; // Extract path parameters (e.g., {id}) and replace them with actual values const pathParamRegex = /{([^}]+)}/g; let match; while ((match = pathParamRegex.exec(options.path)) !== null) { const fullMatch = match[0]; // e.g., "{id}" const paramName = match[1]; // e.g., "id" if (args[paramName] === undefined) { throw new Error(`Path parameter ${paramName} is required but not provided`); } // Validate and encode path parameter using the centralized security function const safeParamValue = validatePathParameter(args[paramName], paramName); finalPath = finalPath.replace(fullMatch, safeParamValue); pathParams[paramName] = String(args[paramName]); } // Collect non-path parameters for query string or request body const otherParams = Object.entries(args).reduce( (acc, [key, value]) => { if (value !== undefined && !pathParams[key]) { acc[key] = value; } return acc; }, {} as Record<string, any> ); // Apply custom parameter transformation if provided const finalParams = options.transformParams ? options.transformParams(args) : otherParams; // Execute the API request based on HTTP method let result; switch (options.method) { case 'GET': result = await todoistApi.get(finalPath, finalParams); break; case 'POST': log('POST', finalPath, finalParams); result = await todoistApi.post(finalPath, finalParams); break; case 'DELETE': result = await todoistApi.delete(finalPath); break; } // Apply result post-processing if provided return options.processResult ? options.processResult(result, args) : result; };
- src/utils/TodoistClient.ts:51-74 (helper)TodoistClient.get method that executes the HTTP GET request to Todoist REST API /tasks endpoint with query parameters, handling auth and response.async get(endpoint: string, params: Record<string, string> = {}): Promise<any> { let url = `${API_BASE_URL}${endpoint}`; const queryParams = new URLSearchParams(); for (const [key, value] of Object.entries(params)) { if (value) { queryParams.append(key, value); } } const queryString = queryParams.toString(); if (queryString) { url += `?${queryString}`; } log(`Making GET request to: ${url}`); const response = await fetch(url, { method: 'GET', headers: this.getHeaders(), }); return this.handleResponse(response); }