delete_todo
Remove a specific task from your Todo List MCP Server by providing its unique UUID, ensuring efficient task management and organization.
Instructions
Delete a todo item
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | UUID of the todo to delete |
Implementation Reference
- src/handlers/toolHandlers.ts:132-159 (handler)The main handler function for the 'delete_todo' tool. Validates input using DeleteTodoSchema, calls todoService.deleteTodo, and returns success or error response.async handleDeleteTodo(request: CallToolRequest): Promise<CallToolResult> { try { const sanitizedArgs = sanitizeInput(request.params.arguments); const validatedRequest = validateData(DeleteTodoSchema, sanitizedArgs); const deleted = this.todoService.deleteTodo(validatedRequest.id); return { content: [ { type: "text", text: deleted ? `✅ Todo com ID ${validatedRequest.id} deletado com sucesso` : `❌ Todo com ID ${validatedRequest.id} não encontrado`, }, ], }; } catch (error) { const errorResponse = createErrorResponse(error, "deletar todo"); return { content: [ { type: "text", text: `❌ ${errorResponse.error}\n${errorResponse.details || ""}`, }, ], }; } }
- src/schemas/todo.schemas.ts:35-37 (schema)Zod schema for validating the input parameters of the delete_todo tool (requires 'id' as UUID). Used in the handler for validation.export const DeleteTodoSchema = z.object({ id: UuiSchema });
- src/config/toolDefinitions.ts:78-91 (registration)Tool registration in the TOOL_DEFINITIONS array, defining name, description, and input schema for MCP server advertisement.name: "delete_todo", description: "Delete a todo item", inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid", description: "UUID of the todo to delete", }, }, required: ["id"], }, },
- Core service method that performs the actual deletion from the in-memory todos Map after UUID validation.deleteTodo(id: string): boolean { try { validateData(TodoSchema.shape.id, id); return this.todos.delete(id); } catch (error) { if (error instanceof ValidationError) { throw error; } return false; } }