taskDelete
Remove tasks by ID from the MCP server to manage workflow and maintain organized project structures.
Instructions
刪除指定ID的任務
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- main.ts:687-709 (registration)Registration of the taskDelete MCP tool, including input schema { id: z.string() } and the handler function that calls TaskManagerTool.deleteTask(id) and returns formatted response.server.tool("taskDelete", "刪除指定ID的任務", { id: z.string() }, async ({ id }) => { try { const result = await TaskManagerTool.deleteTask(id); if (!result) { return { content: [{ type: "text", text: `未找到ID為 ${id} 的任務` }] }; } return { content: [{ type: "text", text: `任務已成功刪除` }] }; } catch (error) { return { content: [{ type: "text", text: `刪除任務失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } } );
- tools/taskManagerTool.ts:210-224 (handler)Core implementation of task deletion: reads all tasks, filters out the one matching the ID, writes back the list if changed, returns success boolean.public static async deleteTask(id: string): Promise<boolean> { const tasks = await this.readTasks(); const initialLength = tasks.length; const filteredTasks = tasks.filter(t => t.id !== id); if (filteredTasks.length === initialLength) { return false; } // 保存所有任務 await this.writeTasks(filteredTasks); return true; }
- main.ts:689-689 (schema)Zod input schema for taskDelete tool: requires 'id' as string.{ id: z.string() },