Skip to main content
Glama
greirson

Todoist MCP Server

todoist_comment_create

Add comments to Todoist tasks or projects by providing task ID, name, or project ID. Supports markdown and file attachments.

Instructions

Add a comment to a task or project in Todoist. For task comments, provide task_id or task_name. For project comments, provide project_id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idNoID of the task to comment on (provide this OR task_name for task comments)
task_nameNoName/content of the task to comment on (provide this OR task_id for task comments)
project_idNoID of the project to comment on (use this for project-level comments instead of task_id/task_name)
contentYesContent of the comment (supports markdown)
attachmentNoOptional file attachment

Implementation Reference

  • Main handler function that creates a comment on a task or project in Todoist. It validates content, resolves task by ID or name, supports project comments, optional attachments, and returns a formatted success message.
    export async function handleCreateComment(
      todoistClient: TodoistApi,
      args: CreateCommentArgs
    ): Promise<string> {
      return ErrorHandler.wrapAsync("create comment", async () => {
        // Validate and sanitize content
        const sanitizedContent = validateCommentContent(args.content);
    
        const commentData: ExtendedCommentCreationData = {
          content: sanitizedContent,
        };
    
        // Determine if this is a project comment or task comment
        if (args.project_id) {
          // Project-level comment
          commentData.projectId = args.project_id;
        } else if (args.task_id) {
          // Task comment by ID
          commentData.taskId = args.task_id;
        } else if (args.task_name) {
          // Search for task by name
          const result = await todoistClient.getTasks();
          const tasks = extractArrayFromResponse<TodoistTask>(result);
          const matchingTask = tasks.find((task: TodoistTask) =>
            task.content.toLowerCase().includes(args.task_name!.toLowerCase())
          );
    
          if (!matchingTask) {
            ErrorHandler.handleTaskNotFound(args.task_name!);
          }
    
          commentData.taskId = matchingTask.id;
        } else {
          throw new Error(
            "Either task_id, task_name, or project_id must be provided"
          );
        }
    
        if (args.attachment) {
          commentData.attachment = {
            fileName: args.attachment.file_name,
            fileUrl: args.attachment.file_url,
            fileType: args.attachment.file_type,
          };
        }
    
        const comment = await todoistClient.addComment(
          commentData as CommentCreationData
        );
    
        // Clear cache after creating comment
        commentCache.clear();
    
        // Use defensive typing for comment response
        const commentResponse = comment as CommentResponse;
    
        const targetType = args.project_id ? "project" : "task";
        return `Comment added to ${targetType}:\nContent: ${commentResponse.content}${
          commentResponse.attachment
            ? `\nAttachment: ${commentResponse.attachment.fileName} (${commentResponse.attachment.fileType})`
            : ""
        }\nPosted at: ${commentResponse.postedAt || new Date().toISOString()}`;
      });
    }
  • TypeScript interface defining the input arguments for creating a comment: optional task_id, task_name, project_id, required content, and optional attachment.
    export interface CreateCommentArgs {
      task_id?: string;
      task_name?: string;
      project_id?: string;
      content: string;
      attachment?: {
        file_name: string;
        file_url: string;
        file_type: string;
      };
    }
  • Tool definition registration with name 'todoist_comment_create', description, and inputSchema specifying properties/validation rules.
    export const CREATE_COMMENT_TOOL: Tool = {
      name: "todoist_comment_create",
      description:
        "Add a comment to a task or project in Todoist. For task comments, provide task_id or task_name. For project comments, provide project_id.",
      inputSchema: {
        type: "object",
        properties: {
          task_id: {
            type: "string",
            description:
              "ID of the task to comment on (provide this OR task_name for task comments)",
          },
          task_name: {
            type: "string",
            description:
              "Name/content of the task to comment on (provide this OR task_id for task comments)",
          },
          project_id: {
            type: "string",
            description:
              "ID of the project to comment on (use this for project-level comments instead of task_id/task_name)",
          },
          content: {
            type: "string",
            description: "Content of the comment (supports markdown)",
          },
          attachment: {
            type: "object",
            description: "Optional file attachment",
            properties: {
              file_name: {
                type: "string",
                description: "Name of the attached file",
              },
              file_url: {
                type: "string",
                description: "URL of the attached file",
              },
              file_type: {
                type: "string",
                description: "MIME type of the attached file",
              },
            },
            required: ["file_name", "file_url", "file_type"],
          },
        },
        required: ["content"],
      },
    };
  • Router case that dispatches to handleCreateComment after validating arguments with isCreateCommentArgs type guard.
    case "todoist_comment_create":
      if (!isCreateCommentArgs(args)) {
        throw new Error("Invalid arguments for todoist_comment_create");
      }
      return await handleCreateComment(client, args);
  • Type guard function that validates the structure of arguments for the comment creation tool, ensuring content is a string and at least one of task_id, task_name, or project_id is provided.
    export function isCreateCommentArgs(args: unknown): args is CreateCommentArgs {
      if (typeof args !== "object" || args === null) return false;
    
      const obj = args as Record<string, unknown>;
      // Must have content and at least one of: task_id, task_name, or project_id
      return (
        "content" in obj &&
        typeof obj.content === "string" &&
        (obj.task_id === undefined || typeof obj.task_id === "string") &&
        (obj.task_name === undefined || typeof obj.task_name === "string") &&
        (obj.project_id === undefined || typeof obj.project_id === "string") &&
        (obj.task_id !== undefined ||
          obj.task_name !== undefined ||
          obj.project_id !== undefined)
      );
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided; description only mentions markdown support and optional attachment. Does not disclose rate limits, notifications, character limits, success response, or error conditions. Significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded purpose, efficient. Every word adds value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a tool with rich schema and no output schema, but missing behavioral context and return value info. Could be improved with notes on notifications or error handling.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers all parameters with descriptions (100% coverage). Description adds value by clarifying the task_id vs task_name vs project_id distinction but does not add much beyond schema for content or attachment.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the verb 'Add' and resource 'comment', and distinguishes between task and project comments. It is distinct from sibling tools like comment_get, comment_update, and comment_delete.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit guidance on when to use task_id/task_name vs project_id for task vs project comments. Lacks exclusion criteria (e.g., when not to use) but clearly directs the agent on parameter choice.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/greirson/mcp-todoist'

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