get_comments_list
Retrieve comments from Todoist tasks or projects to track discussions, feedback, and updates. Filter by project or task to access relevant conversations.
Instructions
Get comments list from Todoist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No | Filter by project | |
| task_id | No | Filter by task |
Implementation Reference
- src/tools/comments.ts:4-13 (registration)Registration of the 'get_comments_list' tool using createApiHandler, specifying name, description, input schema, HTTP GET method, and Todoist API path '/comments'.createApiHandler({ name: 'get_comments_list', description: 'Get comments list from Todoist', schemaShape: { project_id: z.string().optional().describe('Filter by project'), task_id: z.string().optional().describe('Filter by task'), }, method: 'GET', path: '/comments', });
- src/tools/comments.ts:7-10 (schema)Zod input schema definition for optional project_id and task_id parameters used to filter the comments list.schemaShape: { project_id: z.string().optional().describe('Filter by project'), task_id: z.string().optional().describe('Filter by task'), },
- src/utils/handlers.ts:92-145 (handler)The core handler function generated by createApiHandler that executes the tool logic: constructs the API path, validates parameters, performs todoistApi.get('/comments', {project_id?, task_id?}) for get_comments_list, and returns the result.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; };