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
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Title of the todo (1-200 characters) | |
| description | No | Optional description (max 1000 characters) | |
| priority | No | Priority level | medium |
| tags | No | Tags for categorization |
Implementation Reference
- src/handlers/toolHandlers.ts:62-92 (handler)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 || ""}`, }, ], }; } }
- src/config/toolDefinitions.ts:2-35 (registration)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"], }, },
- src/schemas/todo.schemas.ts:19-24 (schema)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; }