deleteTask
Delete a task from Teamwork by providing its task ID. Removes the specified task permanently.
Instructions
Delete a task from Teamwork
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | The ID of the task to delete |
Implementation Reference
- src/tools/tasks/deleteTask.ts:33-55 (handler)Tool handler that receives input, validates taskId, calls teamworkService.deleteTask(), and returns the result in MCP content format.
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) { return createErrorResponse(error, 'Deleting task'); } } - src/tools/tasks/deleteTask.ts:10-30 (schema)Tool definition/schema with name 'deleteTask', description, inputSchema (taskId as integer, required), and annotations marking it destructive.
// Tool definition 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 deleteTask in the tools index: maps definition and handler.
{ definition: deleteTask, handler: handleDeleteTask }, - Service layer function that actually performs the HTTP DELETE request to Teamwork API at /tasks/{taskId}.json.
import logger from '../../utils/logger.js'; import { ensureApiClient } from '../core/apiClient.js'; /** * Deletes a task from Teamwork * @param taskId The ID of the task to delete * @returns True if the task was successfully deleted */ 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}`); } }; export default deleteTask;