todoist_label_update
Modify existing Todoist labels by updating their name, color, order, or favorite status using either label ID or name.
Instructions
Update an existing label in Todoist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label_id | No | ID of the label to update (provide this OR label_name) | |
| label_name | No | Name of the label to update (provide this OR label_id) | |
| name | No | New name for the label (optional) | |
| color | No | New color for the label (optional) | |
| order | No | New order position for the label (optional) | |
| is_favorite | No | Whether the label should be marked as favorite (optional) |
Implementation Reference
- src/handlers/label-handlers.ts:146-184 (handler)Core handler function that finds the label by ID or name, validates updates, calls Todoist API to update the label, clears caches, and returns a success message with changes.export async function handleUpdateLabel( todoistClient: TodoistApi, args: UpdateLabelArgs ): Promise<string> { const label = await findLabel(todoistClient, { label_id: args.label_id, label_name: args.label_name, }); const validatedUpdates = validateLabelUpdate(args); try { await todoistClient.updateLabel(label.id, { name: validatedUpdates.name, color: validatedUpdates.color, order: validatedUpdates.order, isFavorite: validatedUpdates.is_favorite, }); labelCache.clear(); labelStatsCache.clear(); const changes: string[] = []; if (validatedUpdates.name) changes.push(`name: "${validatedUpdates.name}"`); if (validatedUpdates.color) changes.push(`color: "${validatedUpdates.color}"`); if (validatedUpdates.order !== undefined) changes.push(`order: ${validatedUpdates.order}`); if (validatedUpdates.is_favorite !== undefined) changes.push(`favorite: ${validatedUpdates.is_favorite}`); return `Label "${label.name}" updated successfully${changes.length > 0 ? ` (${changes.join(", ")})` : ""}`; } catch (error) { throw new TodoistAPIError( `Failed to update label "${label.name}"`, error instanceof Error ? error : undefined ); } }
- src/tools/label-tools.ts:42-75 (schema)Tool schema definition including name, description, and input schema for validating arguments.export const UPDATE_LABEL_TOOL: Tool = { name: "todoist_label_update", description: "Update an existing label in Todoist", inputSchema: { type: "object", properties: { label_id: { type: "string", description: "ID of the label to update (provide this OR label_name)", }, label_name: { type: "string", description: "Name of the label to update (provide this OR label_id)", }, name: { type: "string", description: "New name for the label (optional)", }, color: { type: "string", description: "New color for the label (optional)", }, order: { type: "number", description: "New order position for the label (optional)", }, is_favorite: { type: "boolean", description: "Whether the label should be marked as favorite (optional)", }, }, }, };
- src/index.ts:268-273 (registration)Switch case in main server request handler that validates arguments using type guard and dispatches to the handleUpdateLabel function.case "todoist_label_update": if (!isUpdateLabelArgs(args)) { throw new Error("Invalid arguments for todoist_label_update"); } result = await handleUpdateLabel(apiClient, args); break;