taskStepUpdate
Modify specific steps within tasks by updating step descriptions, completion status, order, or estimated time using predefined schemas.
Instructions
更新任務的特定步驟
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stepId | Yes | ||
| taskId | Yes | ||
| updates | Yes |
Implementation Reference
- main.ts:724-742 (handler)The MCP tool handler function that destructures input parameters, calls the TaskManagerTool helper, handles errors, and returns a formatted text response.async ({ taskId, stepId, updates }) => { try { const updatedTask = await TaskManagerTool.updateTaskStep(taskId, stepId, updates); if (!updatedTask) { return { content: [{ type: "text", text: `未找到指定的任務或步驟` }] }; } 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:715-722 (schema)Zod schema for input validation of the taskStepUpdate tool, specifying required taskId and stepId, and optional updates to step properties.taskId: z.string(), stepId: z.string(), updates: z.object({ description: z.string().optional(), completed: z.boolean().optional(), order: z.number().optional(), estimatedTime: z.number().optional() })
- main.ts:712-743 (registration)Registers the 'taskStepUpdate' tool with the MCP server, including name, description, input schema, and handler function.server.tool("taskStepUpdate", "更新任務的特定步驟", { taskId: z.string(), stepId: z.string(), updates: z.object({ description: z.string().optional(), completed: z.boolean().optional(), order: z.number().optional(), estimatedTime: z.number().optional() }) }, async ({ taskId, stepId, updates }) => { try { const updatedTask = await TaskManagerTool.updateTaskStep(taskId, stepId, updates); if (!updatedTask) { return { content: [{ type: "text", text: `未找到指定的任務或步驟` }] }; } return { content: [{ type: "text", text: `步驟更新成功:\n${JSON.stringify(updatedTask, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `更新步驟失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } } );
- tools/taskManagerTool.ts:229-264 (helper)Core helper method in TaskManagerTool class that finds the task and step by ID, applies updates to the step, updates timestamp, checks completion status, and persists changes to tasks.json.public static async updateTaskStep(taskId: string, stepId: string, updates: Partial<Omit<TaskStep, 'id'>>): Promise<Task | null> { const tasks = await this.readTasks(); const taskIndex = tasks.findIndex(t => t.id === taskId); if (taskIndex === -1) { return null; } const task = tasks[taskIndex]; const stepIndex = task.steps.findIndex(s => s.id === stepId); if (stepIndex === -1) { return null; } // 更新步驟 task.steps[stepIndex] = { ...task.steps[stepIndex], ...updates }; // 更新任務 task.updatedAt = new Date().toISOString(); // 檢查所有步驟是否完成,如果所有步驟完成則提示用戶使用 completeTask const allStepsCompleted = task.steps.every(s => s.completed); if (allStepsCompleted && task.status !== TaskStatus.COMPLETED) { // 不自動設置任務為完成狀態,顯示提示信息 console.log(`任務 "${task.title}" 的所有步驟已完成,請使用 completeTask 方法將任務標記為已完成`); } // 保存所有任務 await this.writeTasks(tasks); return task; }
- TypeScript interface defining the structure of a TaskStep, used in the updates parameter and throughout the task management system.export interface TaskStep { /** * 步驟ID */ id: string; /** * 步驟描述 */ description: string; /** * 步驟是否完成 */ completed?: boolean; /** * 步驟順序 */ order?: number; /** * 步驟預估完成時間(分鐘) */ estimatedTime?: number; }