Skip to main content
Glama

complete_task

Mark a task as completed, generate a detailed report, and update the dependency status of related tasks to ensure workflow continuity and accountability.

Instructions

Formally mark a task as completed, generate a detailed completion report, and update the dependency status of related tasks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
summaryNoTask completion summary, concise description of implementation results and important decisions (optional, will be automatically generated if not provided)
taskIdYesUnique identifier of the task to mark as completed, must be a valid unfinished task ID in the status of "in progress"

Implementation Reference

  • The main handler function for the 'complete_task' tool. Validates the task exists and is in 'IN_PROGRESS' status, optionally generates a summary, updates the task status to 'COMPLETED', and returns a prompt summarizing the completion.
    export async function completeTask({ taskId, summary, }: z.infer<typeof completeTaskSchema>) { const task = await getTaskById(taskId); if (!task) { return { content: [ { type: "text" as const, text: `## System Error\n\nTask with ID \`${taskId}\` not found. Please use the "list_tasks" tool to confirm a valid task ID before trying again.`, }, ], isError: true, }; } if (task.status !== TaskStatus.IN_PROGRESS) { return { content: [ { type: "text" as const, text: `## Status Error\n\nTask "${task.name}" (ID: \`${task.id}\`) current status is "${task.status}", not in progress state, cannot mark as completed.\n\nOnly tasks in "in progress" state can be marked as completed. Please use the "execute_task" tool to start task execution first.`, }, ], isError: true, }; } // Process summary information let taskSummary = summary; if (!taskSummary) { // Automatically generate summary taskSummary = generateTaskSummary(task.name, task.description); } // Update task status to completed and add summary await updateTaskStatus(taskId, TaskStatus.COMPLETED); await updateTaskSummary(taskId, taskSummary); // Use prompt generator to get the final prompt const prompt = getCompleteTaskPrompt({ task, completionTime: new Date().toISOString(), }); return { content: [ { type: "text" as const, text: prompt, }, ], }; }
  • Zod schema defining the input parameters for the completeTask tool: taskId (required UUID) and optional summary (string min 30 chars).
    export const completeTaskSchema = z.object({ taskId: z .string() .uuid({ message: "Invalid task ID format, please provide a valid UUID format" }) .describe( "Unique identifier of the task to mark as completed, must be a valid unfinished task ID in the status of \"in progress\"" ), summary: z .string() .min(30, { message: "Task summary too short, please provide a more detailed completion report, including implementation results and main decisions", }) .optional() .describe( "Task completion summary, concise description of implementation results and important decisions (optional, will be automatically generated if not provided)" ), });
  • src/index.ts:277-282 (registration)
    Registration of the 'complete_task' tool in the MCP server's ListToolsRequestHandler, specifying name, description from template, and input schema converted to JSON schema.
    name: "complete_task", description: loadPromptFromTemplate( "toolsDescription/completeTask.md" ), inputSchema: zodToJsonSchema(completeTaskSchema), },
  • src/index.ts:474-487 (registration)
    Handler dispatch in the CallToolRequestHandler switch case for 'complete_task', which parses arguments with the schema and calls the completeTask function.
    case "complete_task": parsedArgs = await completeTaskSchema.safeParseAsync( request.params.arguments ); if (!parsedArgs.success) { throw new Error( `Invalid arguments for tool ${request.params.name}: ${parsedArgs.error.message}` ); } taskId = parsedArgs.data.taskId; await saveRequest(); result = await completeTask(parsedArgs.data); await saveResponse(result); return result;
  • Helper function that generates the completion prompt using templates, used by the handler to format the response.
    export function getCompleteTaskPrompt(params: CompleteTaskPromptParams): string { const { task, summary } = params; const indexTemplate = loadPromptFromTemplate("completeTask/index.md"); // Start building the base prompt let prompt = generatePrompt(indexTemplate, { taskName: task.name, taskId: task.id, taskDescription: task.description, summary: summary || "", }); // Load possible custom prompt return loadPrompt(prompt, "COMPLETE_TASK"); }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/liorfranko/mcp-chain-of-thought'

If you have feedback or need assistance with the MCP directory API, please join our Discord server