complete_task
Mark a task as finished in Task Trellis MCP by providing task ID, summary, and file changes. Updates task status, records details, and triggers dependent tasks for accurate project progression.
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 |
|---|---|---|---|
| filesChanged | Yes | Map of files changed with their descriptions | |
| summary | Yes | Summary of the completed task | |
| taskId | Yes | ID of the task to complete |
Input Schema (JSON Schema)
Implementation Reference
- src/tools/completeTaskTool.ts:60-80 (handler)Handler function for the 'complete_task' MCP tool. Extracts input parameters and 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)Input schema defining the parameters for the complete_task tool: 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:177-188 (registration)Registration of the complete_task tool in the MCP server's list of available tools returned by ListToolsRequestHandler.const tools: unknown[] = [ createObjectTool, updateObjectTool, getObjectTool, deleteObjectTool, listObjectsTool, appendObjectLogTool, appendModifiedFilesTool, claimTaskTool, getNextAvailableIssueTool, completeTaskTool, ];
- src/server.ts:274-275 (registration)Dispatch handler in the MCP CallToolRequestHandler that routes 'complete_task' calls to the handleCompleteTask function.case "complete_task": return handleCompleteTask(_getService(), repository, args, serverConfig);
- Core helper function implementing the task completion logic: validation, status update, file tracking, logging, persistence, and optional parent auto-completion.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.`, }, ], }; }