Skip to main content
Glama

update-task

Modify existing tasks in Todo.txt files by updating descriptions, priorities, contexts, projects, or metadata using task IDs.

Instructions

Update a task's fields (description, priority, contexts, projects, metadata) by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdYes
updatesYes

Implementation Reference

  • Executes the update-task tool: loads tasks, validates task ID, updates description, priority, replaces contexts and projects, sets extensions, saves, and returns success or error.
    async ({ taskId, updates }) => { const tasks = await loadTasks(); const idx = getTaskIndex(taskId, tasks); if (idx === null) { return { content: [ { type: "text", text: "Invalid task ID." }, ], isError: true, }; } const task = tasks[idx]; if (updates.description) task.setBody(updates.description); if (updates.priority) task.setPriority(updates.priority); if (updates.contexts) { task.contexts().forEach((context: string) => task.removeContext(context)); updates.contexts.forEach((context: string) => task.addContext(context)); } if (updates.projects) { task.projects().forEach((project: string) => task.removeProject(project)); updates.projects.forEach((project: string) => task.addProject(project)); } if (updates.extensions) { Object.entries(updates.extensions).forEach(([key, value]) => task.setExtension(key as string, value as string)); } await saveTasks(tasks); return { content: [ { type: "text", text: "Task updated successfully." }, ], }; }
  • Zod input schema defining parameters for update-task: required taskId (number), optional updates object with description, priority, contexts array, projects array, extensions record.
    { taskId: z.number(), updates: z.object({ description: z.string().optional(), priority: z.string().optional(), contexts: z.array(z.string()).optional(), projects: z.array(z.string()).optional(), extensions: z.record(z.string(), z.string()).optional(), }), },
  • src/tools.ts:368-413 (registration)
    Registers the 'update-task' tool on the MCP server with name, description, input schema, and handler function.
    server.tool( "update-task", "Update a task's fields (description, priority, contexts, projects, metadata) by ID.", { taskId: z.number(), updates: z.object({ description: z.string().optional(), priority: z.string().optional(), contexts: z.array(z.string()).optional(), projects: z.array(z.string()).optional(), extensions: z.record(z.string(), z.string()).optional(), }), }, async ({ taskId, updates }) => { const tasks = await loadTasks(); const idx = getTaskIndex(taskId, tasks); if (idx === null) { return { content: [ { type: "text", text: "Invalid task ID." }, ], isError: true, }; } const task = tasks[idx]; if (updates.description) task.setBody(updates.description); if (updates.priority) task.setPriority(updates.priority); if (updates.contexts) { task.contexts().forEach((context: string) => task.removeContext(context)); updates.contexts.forEach((context: string) => task.addContext(context)); } if (updates.projects) { task.projects().forEach((project: string) => task.removeProject(project)); updates.projects.forEach((project: string) => task.addProject(project)); } if (updates.extensions) { Object.entries(updates.extensions).forEach(([key, value]) => task.setExtension(key as string, value as string)); } await saveTasks(tasks); return { content: [ { type: "text", text: "Task updated successfully." }, ], }; } );
  • Helper utility used by update-task (and others) to map 1-based taskId 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; }

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