Skip to main content
Glama
glaucia86
by glaucia86

delete_todo

Remove a specific task from your todo list by providing its unique ID to manage your tasks effectively.

Instructions

Delete a todo item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesUUID of the todo to delete

Implementation Reference

  • Main handler method for delete_todo tool. Validates input using DeleteTodoSchema, calls todoService.deleteTodo, and returns success/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 || ""}`,
            },
          ],
        };
      }
  • Zod schema defining input for delete_todo: requires 'id' field validated as UUID.
    export const DeleteTodoSchema = z.object({
      id: UuiSchema
    });
  • Tool registration in TOOL_DEFINITIONS array, defining name, description, and input schema for MCP tool server.
    {
      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 validating ID.
    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;
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/glaucia86/todo-list-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server