complete_task
Mark a task as completed, recording who completed it and when, while preserving it in task history.
Instructions
Mark a task as done / completed / finished. Sets status=COMPLETED on the task, populating completedBy and completedAt while preserving the task in history (unlike delete_task which removes it permanently). Use this whenever a user says 'mark done', 'complete', 'finish', or similar — equivalent to update_task with status:COMPLETED but more discoverable.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- src/tools/tasks.ts:180-185 (handler)The actual handler for the complete_task tool. Makes a PUT request to /tasks/{id} with status='COMPLETED'.
export async function completeTask(input: z.infer<typeof completeTaskSchema>) { // Capsule uses PUT /tasks/{id} with status field — no dedicated /complete action return capsulePut<{ task: unknown }>(`/tasks/${input.id}`, { task: { status: "COMPLETED" }, }); } - src/tools/tasks.ts:176-178 (schema)Zod schema for complete_task input: requires an id (positive integer).
export const completeTaskSchema = z.object({ id: z.number().int().positive(), }); - src/server.ts:639-645 (registration)Registration of the 'complete_task' tool in the MCP server using the registerTool helper.
registerTool( server, "complete_task", "Mark a task as done / completed / finished. Sets status=COMPLETED on the task, populating completedBy and completedAt while preserving the task in history (unlike delete_task which removes it permanently). Use this whenever a user says 'mark done', 'complete', 'finish', or similar — equivalent to update_task with status:COMPLETED but more discoverable.", completeTaskSchema, completeTask, ); - src/server/register-tool.ts:39-59 (helper)The registerTool helper that wraps the MCP server.tool() registration. Handles JSON-stringify wrapping of the handler's return value into MCP text content.
export function registerTool<Schema extends z.ZodObject<ZodRawShape>>( server: McpServer, name: string, description: string, schema: Schema, handler: (input: z.infer<Schema>) => Promise<unknown>, ): void { // Use the SDK config-form registerTool with the full Zod schema. The // deprecated shape overload rebuilds z.object(schema.shape), which drops // object-level refinements such as superRefine. const registerWithSchema = server.registerTool.bind(server) as ( toolName: string, config: { description: string; inputSchema: Schema }, callback: (input: z.infer<Schema>) => Promise<CallToolResult>, ) => void; registerWithSchema(name, { description, inputSchema: schema }, async (input) => { const result = await handler(input); return wrapAsText(result); }); } - src/capsule/client.ts:427-441 (helper)The capsulePut low-level HTTP client used by completeTask to send the PUT request to the Capsule API.
export async function capsulePut<T>(path: string, body: unknown): Promise<T> { if (isReadOnly()) throw new CapsuleReadOnlyError("PUT"); const token = getToken(); const url = buildUrl(path); const { res, cleanup } = await doFetch(url, { method: "PUT", headers: { ...baseHeaders(token), "Content-Type": "application/json" }, body: JSON.stringify(body), }); try { return await handleResponse<T>(res); } finally { cleanup(); } }