Skip to main content
Glama
kydycode

Enhanced Todoist MCP Server Extended

todoist_get_tasks

Retrieve Todoist tasks with filtering by project, section, label, or parent, and pagination support for efficient task management.

Instructions

Get tasks with comprehensive filtering and pagination support

Input Schema

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

Implementation Reference

  • Handler for todoist_get_tasks tool: validates args, constructs params, calls todoistClient.getTasks(), handles paginated or array response, formats output using formatTask, returns formatted task list with optional next cursor.
    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 definition object for todoist_get_tasks, including name, description, and detailed input schema for filtering, pagination, and specific task retrieval.
    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:1083-1121 (registration)
    Registration of all tools including todoist_get_tasks (as GET_TASKS_TOOL) in the ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ // Task tools CREATE_TASK_TOOL, QUICK_ADD_TASK_TOOL, GET_TASKS_TOOL, GET_TASK_TOOL, UPDATE_TASK_TOOL, DELETE_TASK_TOOL, COMPLETE_TASK_TOOL, REOPEN_TASK_TOOL, SEARCH_TASKS_TOOL, MOVE_TASK_TOOL, BULK_MOVE_TASKS_TOOL, // Project tools GET_PROJECTS_TOOL, GET_PROJECT_TOOL, CREATE_PROJECT_TOOL, UPDATE_PROJECT_TOOL, DELETE_PROJECT_TOOL, // Section tools GET_SECTIONS_TOOL, CREATE_SECTION_TOOL, UPDATE_SECTION_TOOL, DELETE_SECTION_TOOL, // Label tools CREATE_LABEL_TOOL, GET_LABEL_TOOL, GET_LABELS_TOOL, UPDATE_LABEL_TOOL, DELETE_LABEL_TOOL, // Comment tools CREATE_COMMENT_TOOL, GET_COMMENT_TOOL, GET_COMMENTS_TOOL, UPDATE_COMMENT_TOOL, DELETE_COMMENT_TOOL, ], }));
  • Type guard function isGetTasksArgs used to validate input arguments for the todoist_get_tasks handler.
    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 formatTask used by todoist_get_tasks (and other task tools) to format task details into a readable string.
    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