delete_task
Permanently delete a task from Capsule CRM. Requires confirm=true; irreversible. Idempotent on retry.
Instructions
DESTRUCTIVE & IRREVERSIBLE: permanently delete a task. Prefer complete_task to mark a task done while keeping it in history. Requires confirm=true. Idempotent on retry: response is {deleted: true, alreadyDeleted: false, id} on a fresh delete or {deleted: true, alreadyDeleted: true, id} if the task was already gone.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| confirm | Yes | Must be set to true. Permanently deletes the task. To mark done without losing history use complete_task. Irreversible. |
Implementation Reference
- src/tools/tasks.ts:196-205 (handler)The actual handler function for delete_task. Validates confirm:true, then calls capsuleDelete with idempotent retry logic.
export async function deleteTask(input: z.infer<typeof deleteTaskSchema>) { if (input.confirm !== true) { throw new Error("delete_task requires confirm: true"); } return idempotent( () => capsuleDelete(`/tasks/${input.id}`), () => ({ deleted: true, alreadyDeleted: false, id: input.id }), () => ({ deleted: true, alreadyDeleted: true, id: input.id }), ); } - src/tools/tasks.ts:189-194 (schema)Zod schema for delete_task: requires id (positive integer) and confirm (must be literal true).
export const deleteTaskSchema = z.object({ id: z.number().int().positive(), confirm: confirmFlag().describe( "Must be set to true. Permanently deletes the task. To mark done without losing history use complete_task. Irreversible.", ), }); - src/server.ts:647-653 (registration)Registration of the 'delete_task' tool with name, description, schema, and handler via registerTool.
registerTool( server, "delete_task", "DESTRUCTIVE & IRREVERSIBLE: permanently delete a task. Prefer complete_task to mark a task done while keeping it in history. Requires confirm=true. Idempotent on retry: response is `{deleted: true, alreadyDeleted: false, id}` on a fresh delete or `{deleted: true, alreadyDeleted: true, id}` if the task was already gone.", deleteTaskSchema, deleteTask, ); - src/tools/confirm-flag.ts:20-28 (helper)Helper that provides the confirm: true literal Zod type with a clear error message for destructive operations.
import { z } from "zod"; const CONFIRM_REQUIRED_MESSAGE = "confirm: true is required to perform this destructive operation (set the parameter explicitly to acknowledge the destructive intent)"; export function confirmFlag(): z.ZodLiteral<true> { return z.literal(true, { error: () => CONFIRM_REQUIRED_MESSAGE }); } - src/server/register-tool.ts:39-59 (registration)Generic registerTool helper that wraps handlers with JSON MCP text response formatting.
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); }); }