Skip to main content
Glama
kydycode

Enhanced Todoist MCP Server Extended

todoist_get_labels

Retrieve all labels from Todoist with pagination support to manage tasks, projects, and sections efficiently. Adjust the limit or cursor for precise control over label retrieval.

Instructions

Get all labels. Supports pagination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorNoPagination cursor for next page (optional).
limitNoMaximum number of labels to return (default: 50) (optional).

Implementation Reference

  • The handler logic for the 'todoist_get_labels' tool. It validates input arguments using isGetLabelsArgs, calls todoistClient.getLabels with optional pagination parameters (cursor, limit), formats the labels using formatLabel, includes pagination info, and returns formatted text response.
    if (name === "todoist_get_labels") { if (!isGetLabelsArgs(args)) { return { content: [{ type: "text", text: "Invalid arguments for get_labels. This tool takes an optional cursor and limit." }], isError: true }; } try { const params: any = {}; if (args.cursor) params.cursor = args.cursor; if (args.limit) params.limit = args.limit; const labelsResponse = await todoistClient.getLabels(params); const labelList = labelsResponse.results?.map(formatLabel).join('\n\n') || 'No labels found'; const nextCursor = labelsResponse.nextCursor ? `\n\nNext cursor for more labels: ${labelsResponse.nextCursor}` : ''; return { content: [{ type: "text", text: `Labels:\n${labelList}${nextCursor}` }], isError: false }; } catch (error: any) { return { content: [{ type: "text", text: `Error getting labels: ${error.message}` }], isError: true }; } }
  • The Tool object definition for 'todoist_get_labels', including name, description, and inputSchema for optional cursor and limit parameters.
    const GET_LABELS_TOOL: Tool = { name: "todoist_get_labels", description: "Get all labels. Supports pagination.", inputSchema: { type: "object", properties: { cursor: { type: "string", description: "Pagination cursor for next page (optional)." }, limit: { type: "number", description: "Maximum number of labels to return (default: 50) (optional)." } } } };
  • src/index.ts:1108-1114 (registration)
    Registration of the todoist_get_labels tool (as GET_LABELS_TOOL) in the list of tools returned by ListToolsRequestHandler.
    // Label tools CREATE_LABEL_TOOL, GET_LABEL_TOOL, GET_LABELS_TOOL, UPDATE_LABEL_TOOL, DELETE_LABEL_TOOL, // Comment tools
  • Helper function formatLabel used in the handler to format label objects for output.
    function formatLabel(label: any): string { return `- ${label.name} (ID: ${label.id})${label.color ? `\n Color: ${label.color}` : ''}${label.isFavorite ? `\n Favorite: Yes` : ''}${label.order ? `\n Order: ${label.order}`: ''}`; }
  • Type guard helper isGetLabelsArgs used in the handler to validate input arguments.
    function isGetLabelsArgs(args: unknown): args is { cursor?: string; limit?: number; } { return typeof args === "object" && args !== null; }

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

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