Skip to main content
Glama
greirson

Todoist MCP Server

todoist_task_delete

Delete a Todoist task using its ID or by searching for a partial name match to remove completed or unwanted items from your task list.

Instructions

Delete a task found by ID or partial name search (case-insensitive)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idNoTask ID to delete (optional, takes precedence over task_name)
task_nameNoPartial task name to search for deletion (used if task_id not provided)

Implementation Reference

  • Core handler function that deletes a Todoist task by ID or partial name. Finds the task, calls the Todoist API deleteTask method, clears cache, handles dry-run mode, and returns confirmation message.
    export async function handleDeleteTask(
      todoistClient: TodoistApi,
      args: any
    ): Promise<string> {
      // Handle both snake_case and camelCase
      const { taskId, taskName } = extractTaskIdentifiers(args);
    
      // Validate that at least one identifier is provided
      validateTaskIdentifier(taskId, taskName);
    
      // Clear cache since we're deleting
      taskCache.clear();
    
      const matchingTask = await findTaskByIdOrName(todoistClient, args);
    
      await todoistClient.deleteTask(matchingTask.id);
    
      // Check if we're in dry-run mode
      const isDryRun = process.env.DRYRUN === "true";
      const prefix = isDryRun ? "[DRY-RUN] " : "";
    
      return `${prefix}Successfully deleted task: "${matchingTask.content}"`;
    }
  • Defines the MCP Tool schema for todoist_task_delete, including input validation for task_id or task_name.
    export const DELETE_TASK_TOOL: Tool = {
      name: "todoist_task_delete",
      description:
        "Delete a task found by ID or partial name search (case-insensitive)",
      inputSchema: {
        type: "object",
        properties: {
          task_id: {
            type: "string",
            description:
              "Task ID to delete (optional, takes precedence over task_name)",
          },
          task_name: {
            type: "string",
            description:
              "Partial task name to search for deletion (used if task_id not provided)",
          },
        },
        required: [],
      },
    };
  • src/index.ts:170-175 (registration)
    Registers and routes calls to the todoist_task_delete tool in the MCP server's CallToolRequest handler switch statement.
    case "todoist_task_delete":
      if (!isDeleteTaskArgs(args)) {
        throw new Error("Invalid arguments for todoist_task_delete");
      }
      result = await handleDeleteTask(apiClient, args);
      break;
  • Helper function to resolve task identifier (ID or partial name) to a concrete TodoistTask object, used by delete, update, and complete handlers.
    async function findTaskByIdOrName(
      todoistClient: TodoistApi,
      args: any
    ): Promise<TodoistTask> {
      // Handle both snake_case and camelCase from MCP framework
      const { taskId, taskName } = extractTaskIdentifiers(args);
    
      if (!taskId && !taskName) {
        throw new Error(
          "Either task_id/taskId or task_name/taskName must be provided"
        );
      }
    
      let task: TodoistTask | null = null;
    
      // Try to find by ID first if provided
      if (taskId) {
        try {
          const response = await todoistClient.getTask(taskId);
          task = response as TodoistTask;
        } catch {
          // If not found by ID, continue to try by name if provided
          if (!taskName) {
            ErrorHandler.handleTaskNotFound(`ID: ${taskId}`);
          }
        }
      }
    
      // If not found by ID or ID not provided, try by name
      if (!task && taskName) {
        const result = await todoistClient.getTasks();
        const tasks = extractArrayFromResponse<TodoistTask>(result);
        const matchingTask = tasks.find((t: TodoistTask) =>
          t.content.toLowerCase().includes(taskName.toLowerCase())
        );
    
        if (matchingTask) {
          task = matchingTask;
        } else {
          ErrorHandler.handleTaskNotFound(taskName);
        }
      }
    
      if (!task) {
        ErrorHandler.handleTaskNotFound(taskId ? `ID: ${taskId}` : taskName!);
      }
    
      return task!;
    }
  • Includes TASK_TOOLS (containing todoist_task_delete) in the complete list of tools served by the MCP server.
    export const ALL_TOOLS = [
      ...TASK_TOOLS,
      ...PROJECT_TOOLS,
      ...COMMENT_TOOLS,
      ...LABEL_TOOLS,
      ...SUBTASK_TOOLS,
      ...TEST_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