update-task-complete
Mark Sunsama tasks as complete with optional timestamp to track task completion and maintain updated task status.
Instructions
Mark a task as complete with optional completion timestamp
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| completeOn | No | Completion timestamp (ISO format). Defaults to current time | |
| limitResponsePayload | No | Whether to limit the response payload size | |
| taskId | Yes | The ID of the task to mark as complete |
Implementation Reference
- src/tools/task-tools.ts:183-204 (handler)The core handler function that executes the tool logic: marks the specified task as complete using the Sunsama client API, with optional completion timestamp and payload limiting, and returns a formatted JSON response.export const updateTaskCompleteTool = withTransportClient({ name: "update-task-complete", description: "Mark a task as complete with optional completion timestamp", parameters: updateTaskCompleteSchema, execute: async ( { taskId, completeOn, limitResponsePayload }: UpdateTaskCompleteInput, context: ToolContext, ) => { const result = await context.client.updateTaskComplete( taskId, completeOn, limitResponsePayload, ); return formatJsonResponse({ success: result.success, taskId, completed: true, updatedFields: result.updatedFields, }); }, });
- src/schemas.ts:136-146 (schema)Zod schema defining the input parameters for the tool: taskId (required), completeOn (optional ISO timestamp), limitResponsePayload (optional boolean).export const updateTaskCompleteSchema = z.object({ taskId: z.string().min(1, "Task ID is required").describe( "The ID of the task to mark as complete", ), completeOn: z.string().optional().describe( "Completion timestamp (ISO format). Defaults to current time", ), limitResponsePayload: z.boolean().optional().describe( "Whether to limit the response payload size", ), });
- src/main.ts:32-44 (registration)Generic registration of all tools (including update-task-complete) to the MCP server via forEach loop over allTools array.// Register all tools allTools.forEach((tool) => { server.registerTool( tool.name, { description: tool.description, inputSchema: "shape" in tool.parameters ? tool.parameters.shape : tool.parameters, }, tool.execute, ); });
- src/tools/shared.ts:29-65 (helper)Higher-order function that wraps the raw tool config, injects transport-aware client, handles execution context, and ensures MCP-compliant response formatting.export function withTransportClient(toolConfig: ToolConfig) { return { name: toolConfig.name, description: toolConfig.description, parameters: toolConfig.parameters, execute: async (args: any, extra: any = {}) => { try { // Auto-resolve client based on transport const client = await getClient(extra.session); // Execute tool with injected client const context: ToolContext = { ...extra, client }; const result = await toolConfig.execute(args, context); // Ensure MCP-compliant response format if (result && Array.isArray(result.content)) { return result; } // Wrap if needed return { content: [ { type: "text", text: typeof result === "string" ? result : JSON.stringify(result, null, 2) } ] }; } catch (error) { console.error(`Tool ${toolConfig.name} error:`, error); throw error; } } }; }
- src/tools/shared.ts:70-78 (helper)Utility function used by the handler to format the tool response as MCP-compliant JSON text content.export function formatJsonResponse(data: any) { return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], };