todoist_update_task
Modify existing tasks in Todoist by updating content, description, due date, priority, or labels using task ID for precise task management.
Instructions
Update an existing task by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | No | New content/title for the task (optional) | |
| description | No | New description for the task (optional) | |
| dueString | No | New due date in natural language (optional) | |
| labels | No | New array of label names (optional) | |
| priority | No | New priority level from 1 (normal) to 4 (urgent) (optional) | |
| taskId | Yes | The ID of the task to update |
Implementation Reference
- src/index.ts:1228-1249 (handler)The main handler logic for the todoist_update_task tool. Validates arguments using isUpdateTaskArgs, builds the updateData object from optional fields, calls todoistClient.updateTask, and returns a formatted success response with the updated task details.if (name === "todoist_update_task") { if (!isUpdateTaskArgs(args)) { throw new Error("Invalid arguments for todoist_update_task"); } const updateData: any = {}; if (args.content) updateData.content = args.content; if (args.description) updateData.description = args.description; if (args.dueString) updateData.dueString = args.dueString; if (args.priority) updateData.priority = args.priority; if (args.labels) updateData.labels = args.labels; const updatedTask = await todoistClient.updateTask(args.taskId, updateData); return { content: [{ type: "text", text: `Task updated successfully:\nID: ${updatedTask.id}\n${formatTask(updatedTask)}` }], isError: false, }; }
- src/index.ts:146-181 (schema)The Tool object definition including name, description, and JSON inputSchema for parameter validation (requires taskId, optional content, description, dueString, priority, labels).const UPDATE_TASK_TOOL: Tool = { name: "todoist_update_task", description: "Update an existing task by its ID", inputSchema: { type: "object", properties: { taskId: { type: "string", description: "The ID of the task to update" }, content: { type: "string", description: "New content/title for the task (optional)" }, description: { type: "string", description: "New description for the task (optional)" }, dueString: { type: "string", description: "New due date in natural language (optional)" }, priority: { type: "number", description: "New priority level from 1 (normal) to 4 (urgent) (optional)", enum: [1, 2, 3, 4] }, labels: { type: "array", items: { type: "string" }, description: "New array of label names (optional)" } }, required: ["taskId"] } };
- src/index.ts:1083-1121 (registration)The ListToolsRequestSchema handler that returns the list of all available tools, including UPDATE_TASK_TOOL (line ~1090), effectively registering todoist_update_task as an available tool.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ // Task tools CREATE_TASK_TOOL, QUICK_ADD_TASK_TOOL, GET_TASKS_TOOL, GET_TASK_TOOL, UPDATE_TASK_TOOL, DELETE_TASK_TOOL, COMPLETE_TASK_TOOL, REOPEN_TASK_TOOL, SEARCH_TASKS_TOOL, MOVE_TASK_TOOL, BULK_MOVE_TASKS_TOOL, // Project tools GET_PROJECTS_TOOL, GET_PROJECT_TOOL, CREATE_PROJECT_TOOL, UPDATE_PROJECT_TOOL, DELETE_PROJECT_TOOL, // Section tools GET_SECTIONS_TOOL, CREATE_SECTION_TOOL, UPDATE_SECTION_TOOL, DELETE_SECTION_TOOL, // Label tools CREATE_LABEL_TOOL, GET_LABEL_TOOL, GET_LABELS_TOOL, UPDATE_LABEL_TOOL, DELETE_LABEL_TOOL, // Comment tools CREATE_COMMENT_TOOL, GET_COMMENT_TOOL, GET_COMMENTS_TOOL, UPDATE_COMMENT_TOOL, DELETE_COMMENT_TOOL, ], }));
- src/index.ts:799-813 (helper)Type guard helper function used in the handler to validate and narrow the type of input arguments for todoist_update_task.function isUpdateTaskArgs(args: unknown): args is { taskId: string; content?: string; description?: string; dueString?: string; priority?: number; labels?: string[]; } { return ( typeof args === "object" && args !== null && "taskId" in args && typeof (args as { taskId: string }).taskId === "string" ); }
- src/index.ts:705-719 (helper)General helper function used by the handler to format task details for the response output.function formatTask(task: any): string { let taskDetails = `- ID: ${task.id}\n Content: ${task.content}`; if (task.description) taskDetails += `\n Description: ${task.description}`; if (task.due) taskDetails += `\n Due: ${task.due.string}`; if (task.priority && task.priority > 1) taskDetails += `\n Priority: ${task.priority}`; if (task.labels && task.labels.length > 0) taskDetails += `\n Labels: ${task.labels.join(', ')}`; if (task.projectId) taskDetails += `\n Project ID: ${task.projectId}`; if (task.sectionId) taskDetails += `\n Section ID: ${task.sectionId}`; if (task.parentId) taskDetails += `\n Parent ID: ${task.parentId}`; if (task.url) taskDetails += `\n URL: ${task.url}`; if (task.commentCount > 0) taskDetails += `\n Comments: ${task.commentCount}`; if (task.createdAt) taskDetails += `\n Created At: ${task.createdAt}`; if (task.creatorId) taskDetails += `\n Creator ID: ${task.creatorId}`; return taskDetails; }