taskStepAdd
Add new steps to tasks in projects by specifying the task ID, step description, and optional order or estimated time using this MCP server tool.
Instructions
為任務添加新步驟
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | Yes | ||
| estimatedTime | No | ||
| order | No | ||
| taskId | Yes |
Implementation Reference
- tools/taskManagerTool.ts:269-309 (handler)Core implementation of taskStepAdd: adds a new step to the specified task by ID, generates UUID, appends, sorts steps by order, updates timestamp, and saves to tasks.json.public static async addTaskStep( taskId: string, description: string, order?: number, estimatedTime?: number ): 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 newOrder = order || task.steps.length + 1; // 創建新步驟 const newStep: TaskStep = { id: uuidv4(), description, completed: false, order: newOrder, estimatedTime }; // 添加新步驟 task.steps.push(newStep); // 重新排序步驟 task.steps.sort((a, b) => (a.order ?? 0) - (b.order ?? 0)); // 更新任務 task.updatedAt = new Date().toISOString(); // 保存所有任務 await this.writeTasks(tasks); return task; }
- main.ts:749-753 (schema)Zod input schema for taskStepAdd tool defining parameters: taskId, description, optional order and estimatedTime.taskId: z.string(), description: z.string(), order: z.number().optional(), estimatedTime: z.number().optional() },
- main.ts:746-773 (registration)MCP server.tool registration for 'taskStepAdd', includes description, schema, and thin wrapper handler that calls TaskManagerTool.addTaskStep and formats response.server.tool("taskStepAdd", "為任務添加新步驟", { taskId: z.string(), description: z.string(), order: z.number().optional(), estimatedTime: z.number().optional() }, async ({ taskId, description, order, estimatedTime }) => { try { const updatedTask = await TaskManagerTool.addTaskStep(taskId, description, order, estimatedTime); if (!updatedTask) { return { content: [{ type: "text", text: `未找到ID為 ${taskId} 的任務` }] }; } return { content: [{ type: "text", text: `步驟添加成功:\n${JSON.stringify(updatedTask, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `添加步驟失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } } );