deleteTask
Remove a task from Teamwork projects by specifying its unique ID. Simplifies task management through direct interaction with the Teamwork API.
Instructions
Delete a task from Teamwork
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | The ID of the task to delete |
Implementation Reference
- src/tools/tasks/deleteTask.ts:32-60 (handler)The handler function that implements the logic for the deleteTask tool. It processes input, calls the service, handles errors, and formats the response.export async function handleDeleteTask(input: any) { logger.info('Calling teamworkService.deleteTask()'); logger.info(`Task ID: ${input?.taskId}`); try { const taskId = String(input?.taskId); if (!taskId) { throw new Error("Task ID is required"); } const result = await teamworkService.deleteTask(taskId); logger.info(`Task deleted successfully for task ID: ${taskId}`); return { content: [{ type: "text", text: JSON.stringify({ success: result }, null, 2) }] }; } catch (error: any) { logger.error(`Error in deleteTask handler: ${error.message}`); return { content: [{ type: "text", text: `Error deleting task: ${error.message}` }] }; } }
- src/tools/tasks/deleteTask.ts:10-29 (schema)The schema definition for the deleteTask tool, including input schema and annotations.export const deleteTaskDefinition = { name: "deleteTask", description: "Delete a task from Teamwork", inputSchema: { type: "object", properties: { taskId: { type: "integer", description: "The ID of the task to delete" } }, required: ["taskId"] }, annotations: { title: "Delete a Task", readOnlyHint: false, destructiveHint: true, openWorldHint: false } };
- src/tools/index.ts:77-77 (registration)Registration of the deleteTask tool in the toolPairs array in src/tools/index.ts, associating the definition and handler.{ definition: deleteTask, handler: handleDeleteTask },
- Helper service function that performs the actual API deletion of the task via Teamwork API.export const deleteTask = async (taskId: string) => { try { const api = ensureApiClient(); await api.delete(`/tasks/${taskId}.json`); return true; } catch (error: any) { logger.error(`Error deleting task ${taskId}: ${error.message}`); throw new Error(`Failed to delete task ${taskId}`); } };