completeTask
Mark a task as complete and retrieve the next task for execution in the task-orchestrator-mcp server to streamline task management.
Instructions
Complete a task and get the next task to execute.
To start the next task, execute startTask.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Task ID | |
| resolution | Yes | Task completion resolution/details |
Implementation Reference
- src/task.ts:1515-1561 (handler)The core handler function implementing the completeTask tool logic: validates params, completes the task, auto-completes parents if applicable, generates progress summary and identifies next task.export function completeTask(params: { id: string; resolution: string }): { message: string next_task_id?: string progress_summary: ProgressSummary } { const { id, resolution } = params // Validate input parameters validateCompleteTaskParams(id, resolution) // Load tasks and find task to complete const tasks = readTasks() const taskToComplete = findAndValidateTaskToComplete(id, tasks) // Validate that task has no incomplete subtasks validateNoIncompleteSubtasks(taskToComplete) // Complete task and handle auto-completion of parents const { autoCompletedParents, updatedTask } = completeTaskAndAutoCompleteParents(id, resolution, tasks) // Save changes writeTasks(tasks) // Generate progress summary with updated tasks and changed task IDs const changedTaskIds = new Set<string>([ updatedTask.id, ...autoCompletedParents.map((p) => p.id), ]) const progress_summary = generateProgressSummary(tasks, changedTaskIds) // Find next task to execute const nextTask = findNextTask(tasks, updatedTask) // Generate completion message const message = generateCompletionMessage( taskToComplete, autoCompletedParents, nextTask, ) return { message, next_task_id: nextTask?.id, progress_summary, } }
- src/tools.ts:375-419 (registration)MCP tool registration for completeTask, including description, Zod input schema, and error-handling wrapper that calls the core completeTask function.server.registerTool( "completeTask", { description: "Complete a task and get the next task to execute.\n" + "To start the next task, execute `startTask`.", inputSchema: { id: z.string().describe("Task ID"), resolution: z.string().describe("Task completion resolution/details"), }, }, (args) => { try { const result = completeTask(args as { id: string; resolution: string }) return { content: [ { text: JSON.stringify(result, null, 2), type: "text", }, ], } } catch (error) { return { content: [ { text: JSON.stringify( { error: { code: "TASK_COMPLETE_ERROR", message: error instanceof Error ? error.message : "Unknown error", }, }, null, 2, ), type: "text", }, ], isError: true, } } }, )
- src/task.ts:1515-1561 (handler)Primary execution logic for completing tasks.export function completeTask(params: { id: string; resolution: string }): { message: string next_task_id?: string progress_summary: ProgressSummary } { const { id, resolution } = params // Validate input parameters validateCompleteTaskParams(id, resolution) // Load tasks and find task to complete const tasks = readTasks() const taskToComplete = findAndValidateTaskToComplete(id, tasks) // Validate that task has no incomplete subtasks validateNoIncompleteSubtasks(taskToComplete) // Complete task and handle auto-completion of parents const { autoCompletedParents, updatedTask } = completeTaskAndAutoCompleteParents(id, resolution, tasks) // Save changes writeTasks(tasks) // Generate progress summary with updated tasks and changed task IDs const changedTaskIds = new Set<string>([ updatedTask.id, ...autoCompletedParents.map((p) => p.id), ]) const progress_summary = generateProgressSummary(tasks, changedTaskIds) // Find next task to execute const nextTask = findNextTask(tasks, updatedTask) // Generate completion message const message = generateCompletionMessage( taskToComplete, autoCompletedParents, nextTask, ) return { message, next_task_id: nextTask?.id, progress_summary, } }
- src/tools.ts:381-384 (schema)Zod schema for input validation of completeTask tool parameters.inputSchema: { id: z.string().describe("Task ID"), resolution: z.string().describe("Task completion resolution/details"), },
- src/task.ts:1403-1415 (helper)Helper function for validating completeTask parameters.function validateCompleteTaskParams(id: string, resolution: string): void { if (!id || typeof id !== "string") { throw new Error("Task ID is required and must be a string") } if ( !resolution || typeof resolution !== "string" || resolution.trim() === "" ) { throw new Error("Resolution is required and must be a non-empty string") } }