Skip to main content
Glama
guifelix

MCP Todo.txt Integration

delete-task

Remove a task from your Todo.txt file by specifying its ID. This tool helps maintain an organized task list by deleting completed or unnecessary entries.

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 tasks, validates the task ID using getTaskIndex, deletes the task by splicing it from the array if valid, saves the updated tasks, and returns success or error message.
    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 using server.tool(), including name, description, schema, and handler.
    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 taskId 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;
    }

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