Skip to main content
Glama
kydycode

Enhanced Todoist MCP Server Extended

todoist_get_comments

Retrieve comments for Todoist tasks or projects with pagination support to view and manage discussion threads.

Instructions

Get comments for a task or project with pagination support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdNoTask ID to get comments for (provide either taskId or projectId, not both)
projectIdNoProject ID to get comments for (provide either taskId or projectId, not both)
cursorNoPagination cursor for next page (optional)
limitNoMaximum number of comments to return (optional)

Implementation Reference

  • The main handler function for the todoist_get_comments tool. Validates arguments with isCommentsArgs, calls todoistClient.getComments with taskId/projectId/cursor/limit, formats results using formatComment, and handles pagination and errors.
    if (name === "todoist_get_comments") { if (!isCommentsArgs(args)) { return { content: [{ type: "text", text: "Invalid arguments for get_comments. Provide either taskId or projectId, not both." }], isError: true }; } try { const params: any = {}; if (args.taskId) params.taskId = args.taskId; if (args.projectId) params.projectId = args.projectId; if (args.cursor) params.cursor = args.cursor; if (args.limit) params.limit = args.limit; const commentsResponse = await todoistClient.getComments(params); const commentList = commentsResponse.results?.map(formatComment).join('\n\n') || 'No comments found'; const nextCursor = commentsResponse.nextCursor ? `\n\nNext cursor for more comments: ${commentsResponse.nextCursor}` : ''; return { content: [{ type: "text", text: `Comments:\n${commentList}${nextCursor}` }], isError: false }; } catch (error: any) { return { content: [{ type: "text", text: `Error getting comments: ${error.message}` }], isError: true }; } }
  • Tool schema definition including name, description, and inputSchema for validating parameters like taskId/projectId (mutually exclusive), cursor, and limit.
    const GET_COMMENTS_TOOL: Tool = { name: "todoist_get_comments", description: "Get comments for a task or project with pagination support", inputSchema: { type: "object", properties: { taskId: { type: "string", description: "Task ID to get comments for (provide either taskId or projectId, not both)" }, projectId: { type: "string", description: "Project ID to get comments for (provide either taskId or projectId, not both)" }, cursor: { type: "string", description: "Pagination cursor for next page (optional)" }, limit: { type: "number", description: "Maximum number of comments to return (optional)" } } } };
  • src/index.ts:1083-1121 (registration)
    Registration of the todoist_get_comments tool (as GET_COMMENTS_TOOL) in the list of available tools returned by ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ // Task tools CREATE_TASK_TOOL, QUICK_ADD_TASK_TOOL, GET_TASKS_TOOL, GET_TASK_TOOL, UPDATE_TASK_TOOL, DELETE_TASK_TOOL, COMPLETE_TASK_TOOL, REOPEN_TASK_TOOL, SEARCH_TASKS_TOOL, MOVE_TASK_TOOL, BULK_MOVE_TASKS_TOOL, // Project tools GET_PROJECTS_TOOL, GET_PROJECT_TOOL, CREATE_PROJECT_TOOL, UPDATE_PROJECT_TOOL, DELETE_PROJECT_TOOL, // Section tools GET_SECTIONS_TOOL, CREATE_SECTION_TOOL, UPDATE_SECTION_TOOL, DELETE_SECTION_TOOL, // Label tools CREATE_LABEL_TOOL, GET_LABEL_TOOL, GET_LABELS_TOOL, UPDATE_LABEL_TOOL, DELETE_LABEL_TOOL, // Comment tools CREATE_COMMENT_TOOL, GET_COMMENT_TOOL, GET_COMMENTS_TOOL, UPDATE_COMMENT_TOOL, DELETE_COMMENT_TOOL, ], }));
  • Type guard function isCommentsArgs used in the handler to validate input arguments, ensuring exactly one of taskId or projectId is provided.
    function isCommentsArgs(args: unknown): args is { taskId?: string; projectId?: string; cursor?: string; limit?: number; } { if (typeof args !== "object" || args === null) { return false; } const { taskId, projectId } = args as any; const targets = [taskId, projectId]; const providedTargets = targets.filter(target => target !== undefined && target !== null && String(target).trim() !== ''); // Exactly one target must be provided and be a non-empty string, or no targets (for all comments) return providedTargets.length <= 1 && providedTargets.every(target => typeof target === 'string'); }
  • Helper function formatComment used to format comment objects for output in the tool response.
    function formatComment(comment: any): string { let commentDetails = `- ID: ${comment.id}\n Content: ${comment.content}`; if (comment.postedAt) commentDetails += `\n Posted At: ${comment.postedAt}`; if (comment.taskId) commentDetails += `\n Task ID: ${comment.taskId}`; if (comment.projectId) commentDetails += `\n Project ID: ${comment.projectId}`; if (comment.attachment) { commentDetails += `\n Attachment: ${comment.attachment.fileName || 'File'} (${comment.attachment.fileType})`; if (comment.attachment.fileUrl) commentDetails += `\n File URL: ${comment.attachment.fileUrl}`; } return commentDetails; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kydycode/todoist-mcp-server-ext'

If you have feedback or need assistance with the MCP directory API, please join our Discord server