todoist_label_get
Retrieve all labels from your Todoist account to organize and filter tasks effectively.
Instructions
Get all labels in Todoist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers/label-handlers.ts:34-69 (handler)The core handler function that implements the todoist_label_get tool. Fetches labels from Todoist API using getLabels(), uses caching, formats and returns a human-readable list.export async function handleGetLabels( todoistClient: TodoistApi ): Promise<string> { const cacheKey = "labels:all"; const cached = labelCache.get(cacheKey); let labels: TodoistLabel[]; if (cached) { labels = cached; } else { try { const response = await todoistClient.getLabels(); labels = extractArrayFromResponse(response) as TodoistLabel[]; labelCache.set(cacheKey, labels); } catch (error) { throw new TodoistAPIError( "Failed to fetch labels", error instanceof Error ? error : undefined ); } } if (labels.length === 0) { return "No labels found."; } const labelList = labels .map( (label) => `• ${label.name} (ID: ${label.id}${label.color ? `, Color: ${label.color}` : ""})` ) .join("\n"); return `Found ${labels.length} labels:\n${labelList}`; }
- src/tools/label-tools.ts:4-11 (schema)Tool schema definition for todoist_label_get, specifying name, description, and empty input schema (no parameters required).export const GET_LABELS_TOOL: Tool = { name: "todoist_label_get", description: "Get all labels in Todoist", inputSchema: { type: "object", properties: {}, }, };
- src/index.ts:254-259 (registration)Registration and dispatch logic in the main server request handler. Matches tool name, validates args with isGetLabelsArgs, and calls the handleGetLabels function.case "todoist_label_get": if (!isGetLabelsArgs(args)) { throw new Error("Invalid arguments for todoist_label_get"); } result = await handleGetLabels(apiClient); break;