Skip to main content
Glama

complete-task

Mark tasks as completed using their ID in Todo.txt files via the MCP server, enabling efficient task management without manual editing.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdYes

Implementation Reference

  • Handler function that implements the core logic for completing a task: loads tasks, validates task ID via helper, marks task as completed with current date, saves changes, or returns error if task 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 definition using Zod: requires a single numeric 'taskId' parameter (1-based index).
    { taskId: z.number() },
  • src/tools.ts:59-82 (registration)
    Registration of the 'complete-task' tool on the McpServer instance, including name, description, schema, and inline 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 taskId to 0-based array index, returns null if invalid, used by complete-task and other task tools.
    // Helper: Convert 1-based taskId to 0-based index, return null if out of bounds 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