Skip to main content
Glama
aafsar
by aafsar

update_task

Modify existing task details including title, description, priority, category, due date, and status to keep task information current and accurate.

Instructions

Update an existing task

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoNew category
descriptionNoNew description
dueDateNoNew due date (YYYY-MM-DD)
priorityNoNew priority
statusNoNew status
taskIdYesTask ID (use first 8 characters)
titleNoNew title

Implementation Reference

  • The main handler function that executes the update_task tool logic: parses arguments with UpdateTaskSchema, loads tasks from storage, finds task by partial ID, updates specified fields, handles status changes including completedAt timestamp, saves changes, and returns a formatted success message with the updated task.
    export async function updateTask(args: unknown) { // Validate input const validated = UpdateTaskSchema.parse(args); // Load tasks const storage = await loadTasks(); // Find task by ID (partial match) const taskIndex = storage.tasks.findIndex((t) => t.id.startsWith(validated.taskId) ); if (taskIndex === -1) { return { content: [ { type: "text", text: `❌ Task with ID ${validated.taskId} not found.`, }, ], }; } const task = storage.tasks[taskIndex]!; // Update fields if provided if (validated.title !== undefined) { task.title = validated.title; } if (validated.description !== undefined) { task.description = validated.description; } if (validated.priority !== undefined) { task.priority = validated.priority as Priority; } if (validated.category !== undefined) { task.category = validated.category; } if (validated.dueDate !== undefined) { task.dueDate = validated.dueDate; } if (validated.status !== undefined) { task.status = validated.status as Status; if (validated.status === "completed" && !task.completedAt) { task.completedAt = new Date().toISOString(); } else if (validated.status !== "completed") { task.completedAt = undefined; } } await saveTasks(storage); return { content: [ { type: "text", text: `✅ Task updated successfully!\n\n${formatTask(task)}`, }, ], }; }
  • Zod schema defining the input shape and validation rules for the update_task tool, used internally in the handler to parse and validate arguments.
    export const UpdateTaskSchema = z.object({ taskId: z.string().min(8, "Task ID must be at least 8 characters"), title: z.string().optional(), description: z.string().optional(), priority: z.enum(["low", "medium", "high"]).optional(), category: z.string().optional(), dueDate: z .string() .regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be YYYY-MM-DD") .optional(), status: z.enum(["pending", "in_progress", "completed"]).optional(), });
  • src/index.ts:84-125 (registration)
    Tool registration in the MCP server's TOOLS array, providing name, description, and inputSchema for the update_task tool to be discoverable and callable by clients.
    { name: "update_task", description: "Update an existing task", inputSchema: { type: "object", properties: { taskId: { type: "string", description: "Task ID (use first 8 characters)", minLength: 8, }, title: { type: "string", description: "New title", }, description: { type: "string", description: "New description", }, priority: { type: "string", enum: ["low", "medium", "high"], description: "New priority", }, category: { type: "string", description: "New category", }, dueDate: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "New due date (YYYY-MM-DD)", }, status: { type: "string", enum: ["pending", "in_progress", "completed"], description: "New status", }, }, required: ["taskId"], }, },
  • src/index.ts:221-222 (registration)
    Dispatch case in the server's CallToolRequestHandler switch statement that routes 'update_task' calls to the updateTask handler function.
    case "update_task": return await updateTask(args);

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/aafsar/task-manager-mcp-server'

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