Skip to main content
Glama

delete_labels

Remove personal labels from Todoist tasks by specifying label IDs or names to clean up your task organization system.

Instructions

Delete a personal label in Todoist Either 'id' or the 'name' to identify the target.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYes

Implementation Reference

  • Registers the delete_labels MCP tool with batch API handler factory, defining schema, path, method, and name lookup logic.
    createBatchApiHandler({
        name: 'delete_labels',
        description: 'Delete a personal label in Todoist',
        itemSchema: {
            id: z.string().optional().describe('ID of the label to delete (preferred over name)'),
            name: z.string().optional().describe('Name of the label to delete'),
        },
        method: 'DELETE',
        path: '/labels/{id}',
        idField: 'id',
        nameField: 'name',
        mode: 'delete',
        findByName: (name, items) =>
            items.find(item => item.name.toLowerCase().includes(name.toLowerCase())),
    });
  • Zod schema for input items: array of objects with optional 'id' or 'name' for the label to delete.
    itemSchema: {
        id: z.string().optional().describe('ID of the label to delete (preferred over name)'),
        name: z.string().optional().describe('Name of the label to delete'),
    },
  • Executes the DELETE request to Todoist API at constructed path (e.g., /labels/{id}) within the batch handler for delete_labels.
    switch (options.method) {
        case 'GET':
            result = await todoistApi.get(finalPath, apiParams);
            break;
        case 'POST':
            result = await todoistApi.post(finalPath, apiParams);
            break;
        case 'DELETE':
            result = await todoistApi.delete(finalPath);
            break;
    }
  • Fetches list of all labels (/labels) if name lookup needed (derives path from tool's path '/labels/{id}') for delete_labels.
    if (needsNameLookup) {
        // Determine the base path for fetching all items
        // Example: /tasks from /tasks/{id}
        const lookupPath =
            options.basePath || (options.path ? options.path.split('/{')[0] : '');
        allItems = await todoistApi.get(lookupPath, {});
    }
  • Name-to-ID resolution logic using tool-provided findByName on fetched labels list for delete_labels.
    if (!itemId && item[options.nameField!] && options.findByName) {
        const searchName = item[options.nameField!];
        const matchedItem = options.findByName(searchName, allItems);
    
        if (!matchedItem) {
            return {
                success: false,
                error: `Item not found with name: ${searchName}`,
                item,
            };
        }
    
        itemId = matchedItem.id;
        matchedName = searchName;
        matchedContent = matchedItem.content;
    }

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/stanislavlysenko0912/todoist-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server