Skip to main content
Glama
glaucia86
by glaucia86

create_todo

Add a new task with title, description, priority, and tags to organize your to-do list effectively.

Instructions

Create a new todo item with validation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesTitle of the todo (1-200 characters)
descriptionNoOptional description (max 1000 characters)
priorityNoPriority levelmedium
tagsNoTags for categorization

Implementation Reference

  • The handleCreateTodo method implements the core logic for the create_todo tool: sanitizes and validates input using CreateTodoSchema, creates the todo via TodoService, and returns a success response.
    private async handleCreateTodo(request: CallToolRequest): Promise<CallToolResult> {
      try {
        const sanitizedArgs = sanitizeInput(request.params.arguments);
        const validatedRequest = validateData(CreateTodoSchema, sanitizedArgs);
        
        const todo = this.todoService.createTodo({
          ...validatedRequest,
          priority: validatedRequest.priority || "medium",
          tags: validatedRequest.tags || [],
        });
    
        return {
          content: [
            {
              type: "text",
              text: `✅ Todo criado com sucesso!\n\n${JSON.stringify(todo, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        const errorResponse = createErrorResponse(error, "criar todo");
        return {
          content: [
            {
              type: "text",
              text: `❌ ${errorResponse.error}\n${errorResponse.details || ""}`,
            },
          ],
        };
      }
    }
  • Tool definition and registration in TOOL_DEFINITIONS array, including name, description, and inputSchema.
    {
      name: "create_todo",
      description: "Create a new todo item with validation",
      inputSchema: {
        type: "object",
        properties: {
          title: {
            type: "string",
            description: "Title of the todo (1-200 characters)",
            minLength: 1,
            maxLength: 200,
          },
          description: {
            type: "string",
            description: "Optional description (max 1000 characters)",
            maxLength: 1000,
          },
          priority: {
            type: "string",
            enum: ["low", "medium", "high"],
            description: "Priority level",
            default: "medium",
          },
          tags: {
            type: "array",
            items: { type: "string", minLength: 1, maxLength: 50 },
            maxItems: 10,
            description: "Tags for categorization",
            default: [],
          },
        },
        required: ["title"],
      },
    },
  • Zod schema definition for CreateTodoSchema used in validation for create_todo input.
    export const CreateTodoSchema = z.object({
      title: NonEmptyStringSchema.max(200, 'Título não pode exceder 200 caracteres'),
      description: z.string().max(500, 'Descrição não pode exceder 500 caracteres').optional(),
      priority: z.enum(['low', 'medium', 'high']).default('medium'),
      tags: z.array(z.string().min(1).max(50)).max(10).default([])
    });
  • TodoService.createTodo method that generates UUID, sets defaults, validates with CreateTodoSchema, stores the todo in an in-memory Map, and returns the new Todo object.
    createTodo(request: CreateTodoRequest): Todo {
      // Validar entrada
      const validatedRequest = validateData(CreateTodoSchema, request);
      
      const todo: Todo = {
        id: randomUUID(),
        title: validatedRequest.title,
        description: validatedRequest.description,
        completed: false,
        createdAt: new Date(),
        priority: validatedRequest.priority || 'medium',
        tags: validatedRequest.tags || []
      };
    
      this.todos.set(todo.id, todo);
      
      return todo;
    }

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