delete_task
Remove tasks from the Task Manager MCP Server by specifying the task ID to clear completed or unwanted items and maintain an organized task list.
Instructions
Delete a task by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | Task ID (use first 8 characters) |
Implementation Reference
- src/tools.ts:194-229 (handler)The primary handler function for the 'delete_task' MCP tool. It validates the input arguments using TaskIdSchema, loads the task storage, finds the task by prefix-matching the ID, removes it from the array using splice, persists the changes, and returns a formatted text response indicating success or failure.export async function deleteTask(args: unknown) { // Validate input const validated = TaskIdSchema.parse(args); // Load tasks const storage = await loadTasks(); // Find task index const taskIndex = storage.tasks.findIndex((t) => t.id.startsWith(validated.taskId) ); if (taskIndex === -1) { return { content: [ { type: "text", text: `β Task with ID ${validated.taskId} not found.`, }, ], }; } // Remove task const deletedTask = storage.tasks.splice(taskIndex, 1)[0]!; await saveTasks(storage); return { content: [ { type: "text", text: `ποΈ Task "${deletedTask.title}" deleted successfully.`, }, ], }; }
- src/types.ts:61-63 (schema)Zod schema (TaskIdSchema) used for input validation within the delete_task handler.export const TaskIdSchema = z.object({ taskId: z.string().min(8, "Task ID must be at least 8 characters"), });
- src/index.ts:127-139 (schema)JSON Schema definition for the 'delete_task' tool provided to MCP clients via the tools list.name: "delete_task", description: "Delete a task by ID", inputSchema: { type: "object", properties: { taskId: { type: "string", description: "Task ID (use first 8 characters)", minLength: 8, }, }, required: ["taskId"], },
- src/index.ts:224-225 (registration)Dispatch logic in the MCP CallToolRequest handler that routes 'delete_task' calls to the deleteTask function.case "delete_task": return await deleteTask(args);
- src/index.ts:13-21 (registration)Import statement registering the deleteTask handler function from tools.ts into the main index module.createTask, listTasks, updateTask, deleteTask, completeTask, searchTasks, getTaskStats, clearCompleted, } from "./tools.js";