Skip to main content
Glama
kydycode

Enhanced Todoist MCP Server Extended

todoist_get_tasks

Retrieve tasks from Todoist with advanced filtering and pagination options, allowing users to fetch specific tasks by project, section, parent ID, label, or task IDs for precise task management.

Instructions

Get tasks with comprehensive filtering and pagination support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorNoPagination cursor for next page (optional)
idsNoArray of task IDs to retrieve (optional)
labelNoFilter tasks by label name (optional)
limitNoMaximum number of tasks to return (default: 50, max: 200) (optional)
parentIdNoFilter tasks by parent ID (get subtasks) (optional)
projectIdNoFilter tasks by project ID (optional)
sectionIdNoFilter tasks by section ID (optional)

Implementation Reference

  • Handler for todoist_get_tasks tool: validates arguments, constructs query parameters for Todoist API, fetches tasks handling both array and paginated responses, formats output using formatTask, and returns formatted task list with pagination info.
    if (name === "todoist_get_tasks") { if (!isGetTasksArgs(args)) { throw new Error("Invalid arguments for todoist_get_tasks"); } const params: any = {}; if (args.projectId) params.projectId = args.projectId; if (args.sectionId) params.sectionId = args.sectionId; if (args.parentId) params.parentId = args.parentId; if (args.label) params.label = args.label; if (args.ids && args.ids.length > 0) params.ids = args.ids; if (args.cursor) params.cursor = args.cursor; if (args.limit) params.limit = args.limit; const tasks = await todoistClient.getTasks(Object.keys(params).length > 0 ? params : {}); // Handle both array and paginated response formats let taskList: string; let nextCursor: string = ''; if (Array.isArray(tasks)) { taskList = tasks.map(formatTask).join('\n\n'); } else { const paginatedTasks = tasks as any; taskList = paginatedTasks.results?.map(formatTask).join('\n\n') || 'No tasks found'; nextCursor = paginatedTasks.nextCursor ? `\n\nNext cursor: ${paginatedTasks.nextCursor}` : ''; } return { content: [{ type: "text", text: `Tasks:\n${taskList}${nextCursor}` }], isError: false, }; }
  • Tool schema definition including name, description, and inputSchema with properties for filtering tasks by project, section, parent, label, specific IDs, pagination (cursor, limit).
    const GET_TASKS_TOOL: Tool = { name: "todoist_get_tasks", description: "Get tasks with comprehensive filtering and pagination support", inputSchema: { type: "object", properties: { projectId: { type: "string", description: "Filter tasks by project ID (optional)" }, sectionId: { type: "string", description: "Filter tasks by section ID (optional)" }, parentId: { type: "string", description: "Filter tasks by parent ID (get subtasks) (optional)" }, label: { type: "string", description: "Filter tasks by label name (optional)" }, ids: { type: "array", items: { type: "string" }, description: "Array of task IDs to retrieve (optional)" }, cursor: { type: "string", description: "Pagination cursor for next page (optional)" }, limit: { type: "number", description: "Maximum number of tasks to return (default: 50, max: 200) (optional)", default: 50 } } } };
  • src/index.ts:1088-1088 (registration)
    Registration of the todoist_get_tasks tool (GET_TASKS_TOOL) in the array returned by ListToolsRequestSchema handler.
    GET_TASKS_TOOL,
  • Type guard function to validate arguments for todoist_get_tasks.
    function isGetTasksArgs(args: unknown): args is { projectId?: string; sectionId?: string; parentId?: string; label?: string; ids?: string[]; cursor?: string; limit?: number; } { return typeof args === "object" && args !== null; }
  • Helper function to format individual task details into a readable string used in the handler output.
    // Helper function to format task output function formatTask(task: any): string { let taskDetails = `- ID: ${task.id}\n Content: ${task.content}`; if (task.description) taskDetails += `\n Description: ${task.description}`; if (task.due) taskDetails += `\n Due: ${task.due.string}`; if (task.priority && task.priority > 1) taskDetails += `\n Priority: ${task.priority}`; if (task.labels && task.labels.length > 0) taskDetails += `\n Labels: ${task.labels.join(', ')}`; if (task.projectId) taskDetails += `\n Project ID: ${task.projectId}`; if (task.sectionId) taskDetails += `\n Section ID: ${task.sectionId}`; if (task.parentId) taskDetails += `\n Parent ID: ${task.parentId}`; if (task.url) taskDetails += `\n URL: ${task.url}`; if (task.commentCount > 0) taskDetails += `\n Comments: ${task.commentCount}`; if (task.createdAt) taskDetails += `\n Created At: ${task.createdAt}`; if (task.creatorId) taskDetails += `\n Creator ID: ${task.creatorId}`; return taskDetails; }

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