delete_task
Archive a task by providing its ID, keeping historical data intact while rendering the task inactive.
Instructions
Delete (archive) a task. This action archives the task rather than permanently deleting it, preserving historical data while making it inactive.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | The ID of the task to delete |
Implementation Reference
- src/tools/tasks.ts:94-112 (handler)DeleteTaskHandler class implementing ToolHandler. Validates input (task_id as positive integer), calls harvestClient.deleteTask(), and returns a success message. Wraps errors via handleMCPToolError.
class DeleteTaskHandler implements ToolHandler { constructor(private readonly config: BaseToolConfig) {} async execute(args: Record<string, any>): Promise<CallToolResult> { try { const inputSchema = z.object({ task_id: z.number().int().positive() }); const { task_id } = validateInput(inputSchema, args, 'delete task'); logger.info('Deleting task via Harvest API', { taskId: task_id }); await this.config.harvestClient.deleteTask(task_id); return { content: [{ type: 'text', text: JSON.stringify({ message: `Task ${task_id} deleted successfully` }, null, 2) }], }; } catch (error) { return handleMCPToolError(error, 'delete_task'); } } } - src/tools/tasks.ts:188-201 (registration)Tool registration entry for 'delete_task' with name, description ('Delete (archive) a task...'), inputSchema (requires task_id number), and handler (new DeleteTaskHandler(config)).
tool: { name: 'delete_task', description: 'Delete (archive) a task. This action archives the task rather than permanently deleting it, preserving historical data while making it inactive.', inputSchema: { type: 'object', properties: { task_id: { type: 'number', description: 'The ID of the task to delete' }, }, required: ['task_id'], additionalProperties: false, }, }, handler: new DeleteTaskHandler(config), }, - src/client/tasks-client.ts:88-99 (helper)TasksClient.deleteTask() - low-level HTTP client method that sends a DELETE request to /tasks/{taskId}. Logs debug/info messages and re-throws errors.
async deleteTask(taskId: number): Promise<void> { try { this.logger.debug('Deleting task', { taskId }); await this.client.delete(`/tasks/${taskId}`); this.logger.info('Successfully deleted task', { taskId }); } catch (error) { this.logger.error('Failed to delete task:', error); throw error; } } - src/client/harvest-api.ts:188-190 (helper)HarvestAPIClient.deleteTask() - delegates to tasksClient.deleteTask(taskId) as a thin wrapper.
async deleteTask(taskId: number): Promise<void> { return this.tasksClient.deleteTask(taskId); } - src/server.ts:64-95 (registration)Tool registration orchestration: registerTaskTools(config) is called (line 79) and its returned registrations are stored in the tools and toolHandlers maps.
private registerAllTools() { // Create a config that always references the current client const self = this; const config: BaseToolConfig = { get harvestClient() { return self.harvestClient; }, logger: logger, }; // Register all modular tools const toolModules = [ registerCompanyTools(config), registerTimeEntryTools(config), registerProjectTools(config), registerTaskTools(config), registerClientTools(config), registerUserTools(config), registerInvoiceTools(config), registerExpenseTools(config), registerEstimateTools(config), registerReportTools(config), ]; // Flatten and register all tools toolModules.forEach(toolRegistrations => { toolRegistrations.forEach(({ tool, handler }) => { this.tools.set(tool.name, tool); this.toolHandlers.set(tool.name, handler); }); }); }