Skip to main content
Glama

delete-task

Remove a task from your Todo.txt file by specifying its 1-based ID using a server-integrated tool for task management.

Instructions

Delete a task by its 1-based ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdYes

Implementation Reference

  • The handler function for the 'delete-task' tool. It loads the tasks, converts the 1-based taskId to index, validates it, removes the task using splice, saves the tasks, and returns a success message or error if invalid ID.
    async ({ taskId }) => { const tasks = await loadTasks(); const idx = getTaskIndex(taskId, tasks); if (idx === null) { return { content: [ { type: "text", text: "Invalid task ID." }, ], isError: true, }; } tasks.splice(idx, 1); await saveTasks(tasks); return { content: [ { type: "text", text: "Task deleted successfully." }, ], }; }
  • Input schema for the 'delete-task' tool, requiring a numeric taskId.
    { taskId: z.number() },
  • src/tools.ts:84-107 (registration)
    Registration of the 'delete-task' tool on the MCP server within the registerTools function.
    server.tool( "delete-task", "Delete a task by its 1-based ID.", { taskId: z.number() }, async ({ taskId }) => { const tasks = await loadTasks(); const idx = getTaskIndex(taskId, tasks); if (idx === null) { return { content: [ { type: "text", text: "Invalid task ID." }, ], isError: true, }; } tasks.splice(idx, 1); await saveTasks(tasks); return { content: [ { type: "text", text: "Task deleted successfully." }, ], }; } );
  • Helper function used by delete-task (and others) to convert 1-based task ID to 0-based array index, returning null if invalid.
    function getTaskIndex(taskId: number, tasks: Item[]): number | null { const idx = taskId - 1; if (idx < 0 || idx >= tasks.length) return null; return idx; }

Other Tools

Related 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/guifelix/mcp-server-todotxt'

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