create_task
Add new tasks to your task management system by specifying title, description, priority, category, and due date for organized tracking.
Instructions
Create a new task
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Task title (required) | |
| description | No | Detailed description | |
| priority | No | Task priority | medium |
| category | No | Task category (work/personal/etc) | |
| dueDate | No | Due date in YYYY-MM-DD format |
Implementation Reference
- src/tools.ts:17-48 (handler)The core handler function for the 'create_task' tool. Validates input using CreateTaskSchema, generates a new task with UUID, adds it to storage, and returns a formatted success message.export async function createTask(args: unknown) { // Validate input const validated = CreateTaskSchema.parse(args); // Load existing tasks const storage = await loadTasks(); // Create new task const newTask: Task = { id: uuidv4(), title: validated.title, description: validated.description, priority: validated.priority as Priority, category: validated.category, dueDate: validated.dueDate, status: "pending", createdAt: new Date().toISOString(), }; // Add to storage storage.tasks.push(newTask); await saveTasks(storage); return { content: [ { type: "text", text: `✅ Task created successfully!\n\n${formatTask(newTask)}`, }, ], }; }
- src/types.ts:29-38 (schema)Zod schema used for input validation in the createTask handler.export const CreateTaskSchema = z.object({ title: z.string().min(1, "Title is required"), description: z.string().optional(), priority: z.enum(["low", "medium", "high"]).default("medium"), category: z.string().optional(), dueDate: z .string() .regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be YYYY-MM-DD") .optional(), });
- src/index.ts:26-57 (registration)Tool registration in the TOOLS array, defining name, description, and JSON inputSchema for the MCP ListTools request.{ name: "create_task", description: "Create a new task", inputSchema: { type: "object", properties: { title: { type: "string", description: "Task title (required)", }, description: { type: "string", description: "Detailed description", }, priority: { type: "string", enum: ["low", "medium", "high"], default: "medium", description: "Task priority", }, category: { type: "string", description: "Task category (work/personal/etc)", }, dueDate: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Due date in YYYY-MM-DD format", }, }, required: ["title"], },
- src/index.ts:215-216 (registration)Dispatch handler in the switch statement that routes 'create_task' calls to the createTask function.case "create_task": return await createTask(args);
- src/index.ts:13-14 (registration)Import of the createTask handler from './tools.js'.createTask, listTasks,