update_todo
Modify an existing task by updating its title, description, completion status, priority, or tags using the UUID for identification in the Todo List MCP Server.
Instructions
Update an existing todo item
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| completed | No | Mark as completed or not | |
| description | No | New description | |
| id | Yes | UUID of the todo to update | |
| priority | No | New priority level | |
| tags | No | New tags | |
| title | No | New title |
Implementation Reference
- src/handlers/toolHandlers.ts:94-130 (handler)The handler function for the 'update_todo' tool. It sanitizes and validates the input using UpdateTodoSchema, calls the todoService.updateTodo method, and returns a formatted success or error response.async handleUpdateTodo(request: CallToolRequest): Promise<CallToolResult> { try { const sanitizedArgs = sanitizeInput(request.params.arguments); const validatedRequest = validateData(UpdateTodoSchema, sanitizedArgs); const todo = this.todoService.updateTodo(validatedRequest); if (!todo) { return { content: [ { type: "text", text: `❌ Todo com ID ${validatedRequest.id} não encontrado`, }, ], }; } return { content: [ { type: "text", text: `✅ Todo atualizado com sucesso!\n\n${JSON.stringify(todo, null, 2)}`, }, ], }; } catch (error) { const errorResponse = createErrorResponse(error, "atualizar todo"); return { content: [ { type: "text", text: `❌ ${errorResponse.error}\n${errorResponse.details || ""}`, }, ], }; } }
- src/schemas/todo.schemas.ts:26-33 (schema)Zod schema defining the input structure and validation rules for the 'update_todo' tool parameters.export const UpdateTodoSchema = z.object({ id: UuiSchema, title: NonEmptyStringSchema.max(200, 'Título não pode exceder 200 caracteres').optional(), description: z.string().max(500).optional(), completed: z.boolean().optional(), priority: z.enum(['low', 'medium', 'high']).optional(), tags: z.array(z.string().min(1).max(50)).max(10).optional() });
- src/config/toolDefinitions.ts:36-76 (registration)Tool registration definition for 'update_todo' including name, description, and JSON schema for input validation in MCP.{ name: "update_todo", description: "Update an existing todo item", inputSchema: { type: "object", properties: { id: { type: "string", format: "uuid", description: "UUID of the todo to update", }, title: { type: "string", minLength: 1, maxLength: 200, description: "New title", }, description: { type: "string", maxLength: 1000, description: "New description", }, completed: { type: "boolean", description: "Mark as completed or not", }, priority: { type: "string", enum: ["low", "medium", "high"], description: "New priority level", }, tags: { type: "array", items: { type: "string", minLength: 1, maxLength: 50 }, maxItems: 10, description: "New tags", }, }, required: ["id"], }, },
- Service method implementing the core update logic: validates input, finds the todo by ID, applies partial updates, and persists to in-memory store.updateTodo(request: UpdateTodoRequest): Todo | null { // Validar entrada const validatedRequest = validateData(UpdateTodoSchema, request); const existingTodo = this.todos.get(validatedRequest.id); if (!existingTodo) { return null; } const updatedTodo: Todo = { ...existingTodo, ...(validatedRequest.title !== undefined && { title: validatedRequest.title }), ...(validatedRequest.description !== undefined && { description: validatedRequest.description }), ...(validatedRequest.priority !== undefined && { priority: validatedRequest.priority }), ...(validatedRequest.tags !== undefined && { tags: validatedRequest.tags }), ...(validatedRequest.completed !== undefined && { completed: validatedRequest.completed, completedAt: validatedRequest.completed ? new Date() : undefined }) }; this.todos.set(validatedRequest.id, updatedTodo); return updatedTodo; }