Skip to main content
Glama
guifelix

MCP Todo.txt Integration

complete-task

Mark a task as completed by its ID to update your Todo.txt file and track progress.

Instructions

Mark a task as completed by its 1-based ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdYes

Implementation Reference

  • Handler that loads the task list, converts 1-based ID to index, marks the task as completed with today's date if found, saves the list, or returns error if not found.
    async ({ taskId }) => {
        const tasks = await loadTasks();
        const idx = getTaskIndex(taskId, tasks);
        if (idx === null) {
            return {
                content: [
                    { type: "text", text: "Task not found." },
                ],
                isError: true,
            };
        }
        tasks[idx].setCompleted(new Date().toISOString().split("T")[0]);
        await saveTasks(tasks);
        return {
            content: [
                { type: "text", text: "Task marked as completed." },
            ],
        };
    }
  • Input schema defining taskId as a required number (1-based index).
    { taskId: z.number() },
  • src/tools.ts:59-82 (registration)
    Registers the complete-task tool on the MCP server with name, description, input schema, and handler function.
    server.tool(
        "complete-task",
        "Mark a task as completed 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: "Task not found." },
                    ],
                    isError: true,
                };
            }
            tasks[idx].setCompleted(new Date().toISOString().split("T")[0]);
            await saveTasks(tasks);
            return {
                content: [
                    { type: "text", text: "Task marked as completed." },
                ],
            };
        }
    );
  • Helper function to convert 1-based task ID to 0-based array index, returns 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;
    }
  • Helper function to persist the tasks list to the TODO file.
    async function saveTasks(tasks: Item[]) {
        const content = tasks.map((task) => task.toString()).join("\n");
        await fs.writeFile(TODO_FILE_PATH, content, "utf-8");
    }

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