Skip to main content
Glama

taskUpdate

Modify existing task details, including title, description, tags, due date, priority, and status, to keep project information up-to-date and organized.

Instructions

更新現有任務信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
updatesYes

Implementation Reference

  • main.ts:647-684 (registration)
    Registration of the 'taskUpdate' MCP tool, including description, Zod input schema, and asynchronous handler function that delegates to TaskManagerTool.updateTask and formats the response.
    server.tool("taskUpdate", "更新現有任務信息", { id: z.string(), updates: z.object({ title: z.string().optional(), description: z.string().optional(), tags: z.array(z.string()).optional(), dueDate: z.string().optional(), priority: z.number().optional(), status: z.enum([ TaskStatus.PENDING, TaskStatus.IN_PROGRESS, TaskStatus.COMPLETED, TaskStatus.CANCELLED ]).optional() }) }, async ({ id, updates }) => { try { const updatedTask = await TaskManagerTool.updateTask(id, updates); if (!updatedTask) { return { content: [{ type: "text", text: `未找到ID為 ${id} 的任務` }] }; } return { content: [{ type: "text", text: `任務更新成功:\n${JSON.stringify(updatedTask, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `更新任務失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } } );
  • main.ts:665-683 (handler)
    Inline handler function for the taskUpdate tool that calls TaskManagerTool.updateTask, handles errors, and returns formatted text response.
    async ({ id, updates }) => { try { const updatedTask = await TaskManagerTool.updateTask(id, updates); if (!updatedTask) { return { content: [{ type: "text", text: `未找到ID為 ${id} 的任務` }] }; } return { content: [{ type: "text", text: `任務更新成功:\n${JSON.stringify(updatedTask, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `更新任務失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } }
  • Zod schema defining input parameters: required 'id' string and optional 'updates' object with task fields.
    id: z.string(), updates: z.object({ title: z.string().optional(), description: z.string().optional(), tags: z.array(z.string()).optional(), dueDate: z.string().optional(), priority: z.number().optional(), status: z.enum([ TaskStatus.PENDING, TaskStatus.IN_PROGRESS, TaskStatus.COMPLETED, TaskStatus.CANCELLED ]).optional() }) },
  • Core implementation of task updating logic in TaskManagerTool class: reads tasks from JSON file, updates specified fields (excluding status COMPLETED), updates timestamp, and persists changes.
    public static async updateTask(id: string, updates: Partial<Omit<Task, 'id' | 'createdAt'>>): Promise<Task | null> { const tasks = await this.readTasks(); const taskIndex = tasks.findIndex(t => t.id === id); if (taskIndex === -1) { return null; } // 檢查是否嘗試將任務設置為已完成狀態 if (updates.status === TaskStatus.COMPLETED) { throw new Error('不能使用 updateTask 方法將任務標記為已完成,請使用 completeTask 方法'); } // 更新任務 tasks[taskIndex] = { ...tasks[taskIndex], ...updates, updatedAt: new Date().toISOString() }; // 保存所有任務 await this.writeTasks(tasks); return tasks[taskIndex]; }

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/GonTwVn/GonMCPtool'

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