complete_task
Mark tasks as finished in Task Trellis MCP by recording completion details, updating status to 'done', tracking file changes, and triggering dependent tasks.
Instructions
Completes a task in the task trellis system
Use this tool to mark a task as finished and record completion details. Critical for task lifecycle management and maintaining accurate project status.
Required completion data:
'taskId': Unique identifier of the task being completed
'summary': Concise description of what was accomplished
'filesChanged': Map of modified files with descriptions of changes made
Completion process:
Validates task is in a completable state ('in-progress')
Updates task status to 'done'
Records completion timestamp and summary
Associates file changes with the task for traceability
Updates parent-child relationships and dependency chains
Triggers any dependent tasks that were waiting for this completion
File change tracking:
Key: relative file path from project root
Value: description of changes made to that file
Example: {'src/api/users.ts': 'Added user authentication endpoints', 'tests/auth.test.ts': 'Added comprehensive auth test coverage'}
Best practices:
Provide clear, actionable summaries that explain the outcome
Document all meaningful file changes for future reference
Complete tasks only when all acceptance criteria are met
Verify dependent tasks can now proceed before completion
Include any important notes or lessons learned in the summary
Task completion automatically notifies dependent tasks and may trigger workflow progression for related work items.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | ID of the task to complete | |
| summary | Yes | Summary of the completed task | |
| filesChanged | Yes | Map of files changed with their descriptions |
Implementation Reference
- src/tools/completeTaskTool.ts:60-80 (handler)The handler function for the 'complete_task' MCP tool. It validates and extracts input arguments then delegates execution to the TaskTrellisService.completeTask method.export function handleCompleteTask( service: TaskTrellisService, repository: Repository, args: unknown, serverConfig: ServerConfig, ) { const { taskId, summary, filesChanged } = args as { taskId: string; summary: string; filesChanged: Record<string, string>; }; // Delegate to service.completeTask return service.completeTask( repository, serverConfig, taskId, summary, filesChanged, ); }
- src/tools/completeTaskTool.ts:37-57 (schema)The input schema definition for the 'complete_task' tool, specifying required parameters: taskId, summary, and filesChanged.inputSchema: { type: "object", properties: { taskId: { type: "string", description: "ID of the task to complete", }, summary: { type: "string", description: "Summary of the completed task", }, filesChanged: { type: "object", additionalProperties: { type: "string", }, description: "Map of files changed with their descriptions", }, }, required: ["taskId", "summary", "filesChanged"], },
- src/server.ts:274-275 (registration)Registration of the 'complete_task' tool handler in the server's CallToolRequest switch statement.case "complete_task": return handleCompleteTask(_getService(), repository, args, serverConfig);
- src/server.ts:187-188 (registration)Inclusion of completeTaskTool in the list of available tools returned by ListToolsRequest.completeTaskTool, ];
- Core helper function implementing the task completion logic: validates task status, updates to DONE, appends files changed and summary to log, saves, and optionally auto-completes parents.export async function completeTask( repository: Repository, serverConfig: ServerConfig, taskId: string, summary: string, filesChanged: Record<string, string>, ): Promise<{ content: Array<{ type: string; text: string }> }> { // Get the task object from repository const task = await repository.getObjectById(taskId); if (!task) { throw new Error(`Task with ID "${taskId}" not found`); } // Check if task is in progress if (task.status !== TrellisObjectStatus.IN_PROGRESS) { throw new Error( `Task "${taskId}" is not in progress (current status: ${task.status})`, ); } // Update task status to done task.status = TrellisObjectStatus.DONE; // Append to affected files map await appendAffectedFiles(repository, task, filesChanged); // Append summary to log task.log.push(summary); // Save the updated task await repository.saveObject(task); // If auto-complete parent is enabled, check if we should complete parent objects if (serverConfig.autoCompleteParent) { await autoCompleteParentHierarchy(repository, task); } return { content: [ { type: "text", text: `Task "${taskId}" completed successfully. Updated ${Object.keys(filesChanged).length} affected files.`, }, ], }; }