plan_task
Define task objectives, establish success criteria, and outline requirements to structure workflows effectively. Optionally reference prior tasks for continuity and improved planning.
Instructions
Initialize and detail the task flow, establish clear goals and success criteria, optionally reference existing tasks for continuation planning
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | Yes | Complete detailed task problem description, should include task objectives, background and expected outcomes | |
| existingTasksReference | No | Whether to reference existing tasks as a planning basis, used for task adjustment and continuity planning | |
| requirements | No | Specific technical requirements, business constraints or quality standards for the task (optional) |
Implementation Reference
- src/tools/taskTools.ts:67-116 (handler)The main handler function for the plan_task tool. Prepares context (loading existing tasks if needed), generates a prompt with getPlanTaskPrompt including task details and memory directory, and returns MCP-formatted text content.export async function planTask({ description, requirements, existingTasksReference = false, }: z.infer<typeof planTaskSchema>) { // Get base directory path const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const PROJECT_ROOT = path.resolve(__dirname, "../.."); const DATA_DIR = process.env.DATA_DIR || path.join(PROJECT_ROOT, "data"); const MEMORY_DIR = path.join(DATA_DIR, "memory"); // Prepare required parameters let completedTasks: Task[] = []; let pendingTasks: Task[] = []; // When existingTasksReference is true, load all tasks from the database as reference if (existingTasksReference) { try { const allTasks = await getAllTasks(); // Split tasks into completed and pending categories completedTasks = allTasks.filter( (task) => task.status === TaskStatus.COMPLETED ); pendingTasks = allTasks.filter( (task) => task.status !== TaskStatus.COMPLETED ); } catch (error) {} } // Use prompt generator to get the final prompt const prompt = getPlanTaskPrompt({ description, requirements, existingTasksReference, completedTasks, pendingTasks, memoryDir: MEMORY_DIR, }); return { content: [ { type: "text" as const, text: prompt, }, ], }; }
- src/tools/taskTools.ts:49-65 (schema)Zod schema defining input parameters for plan_task: required detailed description, optional requirements and existingTasksReference flag.export const planTaskSchema = z.object({ description: z .string() .min(10, { message: "Task description cannot be less than 10 characters, please provide a more detailed description to ensure clear task objectives", }) .describe("Complete detailed task problem description, should include task objectives, background and expected outcomes"), requirements: z .string() .optional() .describe("Specific technical requirements, business constraints or quality standards for the task (optional)"), existingTasksReference: z .boolean() .optional() .default(false) .describe("Whether to reference existing tasks as a planning basis, used for task adjustment and continuity planning"), });
- src/index.ts:229-233 (registration)Registration of the plan_task tool in the MCP server's ListTools handler, specifying name, description from template, and input schema.{ name: "plan_task", description: loadPromptFromTemplate("toolsDescription/planTask.md"), inputSchema: zodToJsonSchema(planTaskSchema), },
- src/index.ts:384-394 (registration)Dispatch logic in the MCP server's CallTool handler for plan_task: parses arguments with schema, calls the planTask handler if valid.case "plan_task": parsedArgs = await planTaskSchema.safeParseAsync( request.params.arguments ); if (!parsedArgs.success) { throw new Error( `Invalid arguments for tool ${request.params.name}: ${parsedArgs.error.message}` ); } result = await planTask(parsedArgs.data); return result;
- src/types/index.ts:68-71 (schema)TypeScript interface matching the planTask input args for type safety.export interface PlanTaskArgs { description: string; // Comprehensive and detailed task problem description, should include task objectives, background, and expected outcomes requirements?: string; // Specific technical requirements, business constraints, or quality standards for the task (optional) }