delete_task
Moves a task to trash by its dart_id; recoverable via Dart web UI.
Instructions
Delete a task (moves to trash - recoverable via Dart web UI)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dart_id | Yes | Task dart_id (also accepts "id" or "task_id") |
Implementation Reference
- src/tools/delete_task.ts:33-93 (handler)Core handler for the delete_task tool. Validates input, resolves dart_id (accepting aliases), calls DartClient.deleteTask() API, and returns deletion confirmation with recoverability info.
export async function handleDeleteTask(input: DeleteTaskInput): Promise<DeleteTaskOutput> { const DART_TOKEN = process.env.DART_TOKEN; if (!DART_TOKEN) { throw new DartAPIError( 'DART_TOKEN environment variable is required. Get your token from: https://app.dartai.com/?settings=account', 401 ); } // ============================================================================ // Step 1: Validate input and dart_id // ============================================================================ if (!input || typeof input !== 'object') { throw new ValidationError( 'input is required and must be an object', 'input' ); } // Accept id, task_id, or taskId as aliases for dart_id input.dart_id = resolveDartId(input as unknown as Record<string, unknown>); // ============================================================================ // Step 2: Call DartClient.deleteTask() // ============================================================================ const client = new DartClient({ token: DART_TOKEN }); let deleteResult: { success: boolean; dart_id: string }; try { deleteResult = await client.deleteTask(input.dart_id); } catch (error) { // Handle 404 errors specifically if (error instanceof DartAPIError && error.statusCode === 404) { throw new DartAPIError( `Task not found: No task with dart_id "${input.dart_id}" exists in workspace`, 404, error.response ); } // Re-throw other errors with enhanced context if (error instanceof DartAPIError) { throw new DartAPIError( `Failed to delete task: ${error.message}`, error.statusCode, error.response ); } throw error; } // ============================================================================ // Step 3: Return deletion confirmation // ============================================================================ return { dart_id: deleteResult.dart_id, deleted: true, recoverable: true, message: `Task "${input.dart_id}" has been moved to trash. You can restore it from the Dart web UI at https://app.dartai.com/`, }; } - src/types/index.ts:403-405 (schema)Input type definition for delete_task: requires a dart_id string.
export interface DeleteTaskInput { dart_id: string; } - src/types/index.ts:407-412 (schema)Output type definition for delete_task: includes dart_id, deletion status, recoverability flag, and user-facing message.
export interface DeleteTaskOutput { dart_id: string; deleted: boolean; recoverable: boolean; message: string; } - src/index.ts:480-493 (registration)MCP tool registration for delete_task with name, description, and JSON Schema input validation (requires dart_id).
{ name: 'delete_task', description: 'Delete a task (moves to trash - recoverable via Dart web UI)', inputSchema: { type: 'object', properties: { dart_id: { type: 'string', description: 'Task dart_id (also accepts "id" or "task_id")', }, }, required: ['dart_id'], }, }, - src/index.ts:1040-1050 (registration)Request dispatch routing: the 'delete_task' case in the CallToolRequestSchema handler calls handleDeleteTask and returns the result as JSON text.
case 'delete_task': { const result = await handleDeleteTask((args || {}) as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }