todoist_create_task
Create new Todoist tasks with detailed options like subtasks, due dates, priorities, labels, and project organization.
Instructions
Create a new task in Todoist with comprehensive options including subtasks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The content/title of the task | |
| description | No | Detailed description of the task (optional) | |
| projectId | No | Project ID to create the task in (optional) | |
| sectionId | No | Section ID to create the task in (optional) | |
| parentId | No | Parent task ID to create this as a subtask (optional) | |
| dueString | No | Natural language due date like 'tomorrow', 'next Monday', 'Jan 23' (optional) | |
| priority | No | Task priority from 1 (normal) to 4 (urgent) (optional) | |
| labels | No | Array of label names to assign to the task (optional) |
Implementation Reference
- src/index.ts:1132-1155 (handler)Handler for todoist_create_task: validates input with isCreateTaskArgs, builds task data object, calls todoistClient.addTask(taskData), and returns formatted success response with task details.if (name === "todoist_create_task") { if (!isCreateTaskArgs(args)) { throw new Error("Invalid arguments for todoist_create_task"); } const taskData: any = { content: args.content, }; if (args.description) taskData.description = args.description; if (args.projectId) taskData.projectId = args.projectId; if (args.sectionId) taskData.sectionId = args.sectionId; if (args.parentId) taskData.parentId = args.parentId; if (args.dueString) taskData.dueString = args.dueString; if (args.priority) taskData.priority = args.priority; if (args.labels && args.labels.length > 0) taskData.labels = args.labels; const task = await todoistClient.addTask(taskData); return { content: [{ type: "text", text: `Task created successfully:\nID: ${task.id}\n${formatTask(task)}` }], isError: false, }; }
- src/index.ts:23-66 (schema)Tool schema definition for todoist_create_task, including input schema with properties like content (required), description, projectId, sectionId, parentId, dueString, priority, and labels.const CREATE_TASK_TOOL: Tool = { name: "todoist_create_task", description: "Create a new task in Todoist with comprehensive options including subtasks", inputSchema: { type: "object", properties: { content: { type: "string", description: "The content/title of the task" }, description: { type: "string", description: "Detailed description of the task (optional)" }, projectId: { type: "string", description: "Project ID to create the task in (optional)" }, sectionId: { type: "string", description: "Section ID to create the task in (optional)" }, parentId: { type: "string", description: "Parent task ID to create this as a subtask (optional)" }, dueString: { type: "string", description: "Natural language due date like 'tomorrow', 'next Monday', 'Jan 23' (optional)" }, priority: { type: "number", description: "Task priority from 1 (normal) to 4 (urgent) (optional)", enum: [1, 2, 3, 4] }, labels: { type: "array", items: { type: "string" }, description: "Array of label names to assign to the task (optional)" } }, required: ["content"] } };
- src/index.ts:1083-1121 (registration)Registration of the todoist_create_task tool (as CREATE_TASK_TOOL) in the ListToolsRequestSchema handler, making it discoverable by clients.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, ], }));
- src/index.ts:745-761 (helper)Type guard helper function isCreateTaskArgs used to validate input arguments for the todoist_create_task handler.function isCreateTaskArgs(args: unknown): args is { content: string; description?: string; projectId?: string; sectionId?: string; parentId?: string; dueString?: string; priority?: number; labels?: string[]; } { return ( typeof args === "object" && args !== null && "content" in args && typeof (args as { content: string }).content === "string" ); }
- src/index.ts:705-719 (helper)Shared helper function formatTask used to format task details in responses, including for todoist_create_task.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; }