Skip to main content
Glama

remove_shared_labels

Remove shared labels from Todoist tasks to clean up task organization and maintain label clarity across projects.

Instructions

Remove a shared label in Todoist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYes

Implementation Reference

  • Registration of the 'remove_shared_labels' tool. Configures it as a batch API handler that sends POST requests to '/labels/shared/remove' with label names, using mode 'delete' but without idField, resulting in direct POST of name payload.
    createBatchApiHandler({
        name: 'remove_shared_labels',
        description: 'Remove a shared label in Todoist',
        itemSchema: {
            name: z.string(),
        },
        method: 'POST',
        path: '/labels/shared/remove',
        mode: 'delete',
    });
  • Zod schema definition for input items: an array of objects each containing a 'name' string field.
    itemSchema: {
        name: z.string(),
    },
  • Handler function generated by createBatchApiHandler that executes the tool: processes batch of label names, POSTs each to Todoist API endpoint '/labels/shared/remove', collects success/failure results with summary.
    const handler = async (args: z.infer<typeof batchSchema>): Promise<any> => {
        const { items } = args;
    
        // For modes other than create, check if name lookup is needed
        let allItems: any[] = [];
    
        const needsNameLookup =
            options.mode !== 'create' &&
            options.nameField &&
            options.findByName &&
            items.some(item => item[options.nameField!] && !item[options.idField!]);
    
        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, {});
        }
    
        const results = await Promise.all(
            items.map(async item => {
                if (options.validateItem) {
                    const validation = options.validateItem(item);
    
                    if (!validation.valid) {
                        return {
                            success: false,
                            error: validation.error || 'Validation failed',
                            item,
                        };
                    }
                }
    
                try {
                    let finalPath = '';
                    const apiParams = { ...item };
    
                    // For modes where need id
                    if (options.mode !== 'create' && options.idField) {
                        let itemId = item[options.idField];
                        let matchedName = null;
                        let matchedContent = null;
    
                        // If no ID but name is provided, search by name
                        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;
                        }
    
                        if (!itemId) {
                            return {
                                success: false,
                                error: `Either ${options.idField} or ${options.nameField} must be provided`,
                                item,
                            };
                        }
    
                        // Apply security validation to itemId before using in path
                        const safeItemId = validatePathParameter(itemId, options.idField || 'id');
    
                        if (options.basePath && options.pathSuffix) {
                            finalPath = `${options.basePath}${options.pathSuffix.replace('{id}', safeItemId)}`;
                        } else if (options.path) {
                            finalPath = options.path.replace('{id}', safeItemId);
                        }
    
                        delete apiParams[options.idField];
                        if (options.nameField) {
                            delete apiParams[options.nameField];
                        }
    
                        let result;
                        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;
                        }
    
                        const response: any = {
                            success: true,
                            id: itemId,
                            result,
                        };
    
                        if (matchedName) {
                            response.found_by_name = matchedName;
                            response.matched_content = matchedContent;
                        }
    
                        return response;
                    }
                    // Create mode
                    else {
                        finalPath = options.path || options.basePath || '';
    
                        let result;
                        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;
                        }
    
                        return {
                            success: true,
                            created_item: result,
                        };
                    }
                } catch (error) {
                    return {
                        success: false,
                        error: error instanceof Error ? error.message : String(error),
                        item,
                    };
                }
            })
        );
    
        const successCount = results.filter(r => r.success).length;
        return {
            success: successCount === items.length,
            summary: {
                total: items.length,
                succeeded: successCount,
                failed: items.length - successCount,
            },
            results,
        };
    };
  • Utility that registers the tool with the MCP server by calling server.tool, wraps the specific handler with standardized MCP response format and error handling.
    export function createHandler<T extends z.ZodRawShape>(
        name: string,
        description: string,
        paramsSchema: T,
        handler: (args: HandlerArgs<T>) => Promise<any>
    ): void {
        const mcpToolCallback = async (args: HandlerArgs<T>): Promise<CallToolResult> => {
            try {
                const result = await handler(args);
    
                return {
                    content: [
                        {
                            type: 'text',
                            text: JSON.stringify(result ?? null, null, 2).trim(),
                        },
                    ],
                };
            } catch (error) {
                const errorMessage = error instanceof Error ? error.message : String(error);
    
                console.error(`Error in tool ${name}:`, error);
    
                return {
                    isError: true,
                    content: [
                        {
                            type: 'text',
                            text: `Error executing tool '${name}': ${errorMessage}`,
                        },
                    ],
                };
            }
        };
    
        // Crazy cast, if you can do it better, please, let me knows
        server.tool(name, description, paramsSchema, mcpToolCallback as unknown as ToolCallback<T>);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. 'Remove' implies a destructive mutation, but there's no information about permissions required, whether removal is permanent/reversible, rate limits, or what happens to tasks using these labels. The description doesn't compensate for the lack of annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a simple operation and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive mutation tool with no annotations, 0% schema coverage, and no output schema, the description is inadequate. It doesn't explain what 'remove' entails operationally, what parameters are needed, what the response looks like, or error conditions. The agent lacks sufficient context to use this tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and 1 parameter ('items'), the description provides no parameter information. It doesn't explain that 'items' is an array of objects with 'name' properties, what format labels should be in, or whether multiple labels can be removed at once. The description fails to compensate for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Remove') and target resource ('a shared label in Todoist'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'delete_labels' or 'rename_shared_labels' - the agent must infer that this specifically handles shared labels versus regular labels.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives like 'delete_labels' or 'rename_shared_labels'. The description doesn't mention prerequisites (e.g., needing existing shared labels), exclusions, or appropriate contexts for this operation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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