delete_task
Remove an uncompleted task from a specified request in a task management system using a queue-based protocol. Displays updated progress table after deletion.
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:648-666 (handler)Core handler method in TaskManagerServer that implements the deletion logic: loads data, finds and removes the uncompleted task from the request's tasks array, saves to file, generates progress table, and returns result.public async deleteTask(requestId: string, taskId: string) { await this.loadTasks(); const req = this.data.requests.find((r) => r.requestId === requestId); if (!req) return { status: "error", message: "Request not found" }; const taskIndex = req.tasks.findIndex((t) => t.id === taskId); if (taskIndex === -1) return { status: "error", message: "Task not found" }; if (req.tasks[taskIndex].done) return { status: "error", message: "Cannot delete completed task" }; req.tasks.splice(taskIndex, 1); await this.saveTasks(); const progressTable = this.formatTaskProgressTable(requestId); return { status: "task_deleted", message: `Task ${taskId} has been deleted.\n${progressTable}`, }; }
- index.ts:829-839 (handler)MCP tool dispatcher case for 'delete_task': parses input with schema, calls TaskManagerServer.deleteTask, and returns JSON stringified result as text content.case "delete_task": { const parsed = DeleteTaskSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments: ${parsed.error}`); } const { requestId, taskId } = parsed.data; const result = await taskManagerServer.deleteTask(requestId, taskId); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- index.ts:94-97 (schema)Zod schema used for input validation of delete_task tool arguments (requestId and taskId).const DeleteTaskSchema = z.object({ requestId: z.string(), taskId: z.string(), });
- index.ts:267-280 (registration)Tool object definition for 'delete_task', including name, description, and input schema; returned in listTools.const DELETE_TASK_TOOL: Tool = { name: "delete_task", description: "Delete a specific task from a request. Only uncompleted tasks can be deleted.\n\n" + "A progress table will be displayed showing the remaining tasks after deletion.", inputSchema: { type: "object", properties: { requestId: { type: "string" }, taskId: { type: "string" }, }, required: ["requestId", "taskId"], }, };
- index.ts:683-696 (registration)Registration of all tools including DELETE_TASK_TOOL in the ListToolsRequestSchema handler.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ REQUEST_PLANNING_TOOL, GET_NEXT_TASK_TOOL, MARK_TASK_DONE_TOOL, APPROVE_TASK_COMPLETION_TOOL, APPROVE_REQUEST_COMPLETION_TOOL, OPEN_TASK_DETAILS_TOOL, LIST_REQUESTS_TOOL, ADD_TASKS_TO_REQUEST_TOOL, UPDATE_TASK_TOOL, DELETE_TASK_TOOL, ], }));