Skip to main content
Glama

update_sections

Modify existing sections in Todoist projects to reorganize tasks and improve workflow structure.

Instructions

Update sections in Todoist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYes

Implementation Reference

  • Executes the update logic for the update_sections tool: validates item ID, secures path parameter, removes ID from body, performs POST to Todoist API /sections/{id} with update params (e.g. name), returns per-item result.
    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;
    }
  • Zod input schema for individual items in update_sections batch call: requires section ID, optional new name.
    itemSchema: {
        id: z.string(),
        name: z.string().optional(),
    },
  • Registers the MCP tool 'update_sections' with batch handler creator, defining name, description, schema, API endpoint, method, mode, and ID field.
    createBatchApiHandler({
        name: 'update_sections',
        description: 'Update sections in Todoist',
        itemSchema: {
            id: z.string(),
            name: z.string().optional(),
        },
        method: 'POST',
        path: '/sections/{id}',
        mode: 'update',
        idField: 'id',
    });
  • TodoistClient.post method invoked to perform the actual HTTP POST request to update the section in Todoist API.
    async post(endpoint: string, data: Record<string, any> = {}): Promise<any> {
        const url = `${API_BASE_URL}${endpoint}`;
    
        log(`Making POST request to: ${url} with data:`, JSON.stringify(data, null, 2));
    
        const response = await fetch(url, {
            method: 'POST',
            headers: this.getHeaders(true),
            body: JSON.stringify(data),
        });
    
        return this.handleResponse(response);
    }

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