Skip to main content
Glama

get_collaborators

Retrieve all collaborators for a Todoist project by providing the project ID to manage team access and permissions.

Instructions

Get all collaborators for a project in Todoist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • Registers the get_collaborators tool with MCP server via createApiHandler factory, defining its name, description, input schema (project id), HTTP method, and Todoist API endpoint path.
    createApiHandler({
        name: 'get_collaborators',
        description: 'Get all collaborators for a project in Todoist',
        schemaShape: {
            id: z.string(),
        },
        method: 'GET',
        path: '/projects/{id}/collaborators',
    });
  • Input schema for get_collaborators tool: requires a string 'id' parameter for the project.
        id: z.string(),
    },
  • Handler function executed for get_collaborators: parses path template '/projects/{id}/collaborators', validates and encodes the 'id' parameter, calls todoistApi.get on the constructed path with any additional params, and returns the result.
    const handler = async (args: z.infer<z.ZodObject<T>>): Promise<R> => {
        let finalPath = options.path;
        const pathParams: Record<string, string> = {};
    
        // Extract path parameters (e.g., {id}) and replace them with actual values
        const pathParamRegex = /{([^}]+)}/g;
        let match;
    
        while ((match = pathParamRegex.exec(options.path)) !== null) {
            const fullMatch = match[0]; // e.g., "{id}"
            const paramName = match[1]; // e.g., "id"
    
            if (args[paramName] === undefined) {
                throw new Error(`Path parameter ${paramName} is required but not provided`);
            }
    
            // Validate and encode path parameter using the centralized security function
            const safeParamValue = validatePathParameter(args[paramName], paramName);
            finalPath = finalPath.replace(fullMatch, safeParamValue);
            pathParams[paramName] = String(args[paramName]);
        }
    
        // Collect non-path parameters for query string or request body
        const otherParams = Object.entries(args).reduce(
            (acc, [key, value]) => {
                if (value !== undefined && !pathParams[key]) {
                    acc[key] = value;
                }
                return acc;
            },
            {} as Record<string, any>
        );
    
        // Apply custom parameter transformation if provided
        const finalParams = options.transformParams ? options.transformParams(args) : otherParams;
    
        // Execute the API request based on HTTP method
        let result;
        switch (options.method) {
            case 'GET':
                result = await todoistApi.get(finalPath, finalParams);
                break;
            case 'POST':
                log('POST', finalPath, finalParams);
                result = await todoistApi.post(finalPath, finalParams);
                break;
            case 'DELETE':
                result = await todoistApi.delete(finalPath);
                break;
        }
    
        // Apply result post-processing if provided
        return options.processResult ? options.processResult(result, args) : result;
    };
  • Final MCP tool registration via server.tool callback, which wraps the handler in error handling and JSON response formatting.
        server.tool(name, description, paramsSchema, mcpToolCallback as unknown as ToolCallback<T>);
    }

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