todoist_create_task
Create and manage tasks in Todoist with detailed options like subtasks, due dates, priorities, and labels for efficient task 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) | |
| dueString | No | Natural language due date like 'tomorrow', 'next Monday', 'Jan 23' (optional) | |
| labels | No | Array of label names to assign to the task (optional) | |
| parentId | No | Parent task ID to create this as a subtask (optional) | |
| priority | No | Task priority from 1 (normal) to 4 (urgent) (optional) | |
| projectId | No | Project ID to create the task in (optional) | |
| sectionId | No | Section ID to create the task in (optional) |
Implementation Reference
- src/index.ts:1132-1155 (handler)Handler logic for executing todoist_create_task: validates arguments using isCreateTaskArgs, builds task data object, calls todoistClient.addTask, formats and returns success response.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 name, description, and detailed JSON input schema with properties like content, projectId, dueString, etc.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 all tools including todoist_create_task (as CREATE_TASK_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, ], }));
- src/index.ts:745-761 (helper)Type guard helper function isCreateTaskArgs for validating input arguments to 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" ); }