delete_task
Remove an uncompleted task from a request in MCP TaskManager. Displays remaining tasks post-deletion for progress tracking. Requires requestId and taskId as inputs.
Instructions
Delete a specific task from a request. Only uncompleted tasks can be deleted.
A progress table will be displayed showing the remaining tasks after deletion.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| requestId | Yes | ||
| taskId | Yes |
Implementation Reference
- index.ts:563-587 (handler)The main handler function that implements the delete_task tool logic: finds the request and task, checks if deletable, removes the task from the array, saves, and returns a success message with progress table.public async deleteTask(requestId: string, taskId: string) { const request = this.data.requests.find((r) => r.requestId === requestId); if (!request) { throw new Error("Request not found"); } const taskIndex = request.tasks.findIndex((t) => t.id === taskId); if (taskIndex === -1) { throw new Error("Task not found"); } const task = request.tasks[taskIndex]; if (task.done || task.approved) { throw new Error("Cannot delete completed or approved tasks"); } request.tasks.splice(taskIndex, 1); await this.saveTasks(); return { message: "Task deleted successfully.\n" + this.formatTaskProgressTable(requestId), }; }
- index.ts:85-88 (schema)Zod schema defining the input parameters for the delete_task tool: requestId and taskId.const DeleteTaskSchema = z.object({ requestId: z.string(), taskId: z.string(), });
- index.ts:190-194 (registration)Registration of the delete_task tool in the listTools method, including name, description, and input schema.{ name: "delete_task", description: "Delete a task from a request.", inputSchema: DeleteTaskSchema, },
- index.ts:278-284 (handler)Dispatch handler in callTool method that parses input using the schema and invokes the deleteTask method.case "delete_task": { const parsed = DeleteTaskSchema.safeParse(parameters); if (!parsed.success) { throw new Error(`Invalid parameters: ${parsed.error}`); } return this.deleteTask(parsed.data.requestId, parsed.data.taskId); }