freedcamp_delete_task
Permanently delete tasks from Freedcamp projects. Remove individual or multiple tasks at once with irreversible bulk deletion capabilities.
Instructions
Permanently delete one or more tasks from Freedcamp. WARNING: This action cannot be undone. Supports bulk operations for deleting multiple tasks at once.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tasks | Yes |
Implementation Reference
- src/mcpServer.ts:114-127 (handler)Core function executing the delete logic for a single task: constructs the DELETE API URL and calls executeFreedcampRequest.async function processSingleDeleteTask(taskArgs: z.infer<typeof singleDeleteTaskSchema>, authParams: Record<string, string>) { try { const url = `https://freedcamp.com/api/v1/tasks/${taskArgs.task_id}`; const result = await executeFreedcampRequest(url, "DELETE", authParams); if (result.error) { return { type: "text", text: `Error deleting task ID "${taskArgs.task_id}": ${result.error}`, task_id: taskArgs.task_id, details: result.details }; } return { type: "text", text: `Task ID "${taskArgs.task_id}" deleted successfully.`, task_id: taskArgs.task_id, data: result.data }; } catch (err: any) { console.error(`Error processing delete for task ID "${taskArgs.task_id}":`, err); return { type: "text", text: `Failed to delete task ID "${taskArgs.task_id}": ${err.message}`, task_id: taskArgs.task_id, error_details: err }; } }
- src/mcpServer.ts:31-33 (schema)Zod input schema definition for a single delete task argument, requiring only 'task_id'.const singleDeleteTaskSchema = z.object({ task_id: z.string().describe("ID of the task to delete (required) - WARNING: This action cannot be undone") });
- src/mcpServer.ts:179-199 (registration)Registers the tool with MCP server: defines description, bulk input schema (array of singleDeleteTaskSchema), title annotation, and handler that builds auth and processes each task via processSingleDeleteTask.server.registerTool("freedcamp_delete_task", { description: "Permanently delete one or more tasks from Freedcamp. WARNING: This action cannot be undone. Supports bulk operations for deleting multiple tasks at once.", inputSchema: { tasks: z.array(singleDeleteTaskSchema) }, annotations: { title: "Delete Task" } }, async (args) => { const tasksToDelete = args.tasks; const authParams = buildFreedcampAuthParams({ api_key: config.apiKey, api_secret: config.apiSecret, }); const results = await Promise.all(tasksToDelete.map((taskArg: any) => processSingleDeleteTask(taskArg, authParams))); return { content: results.map(r => ({ type: "text", text: JSON.stringify(r) })) }; } );
- src/mcpServer.ts:35-65 (helper)Utility function to perform API requests to Freedcamp, handling authentication parameters in FormData or query for DELETE, fetch execution, and response parsing with error handling.async function executeFreedcampRequest(url: string, method: string, authParams: Record<string, string>, bodyData?: Record<string, any>) { const form = new FormData(); if (bodyData) { form.append("data", JSON.stringify(bodyData)); } for (const [k, v] of Object.entries(authParams)) { form.append(k, v); } let requestUrl = url; let requestBody: any = form; if (method === "DELETE" && !bodyData) { const params = new URLSearchParams(authParams); requestUrl = `${url}?${params.toString()}`; requestBody = undefined; } console.log(`Making ${method} request to Freedcamp API: ${requestUrl}`); const resp = await fetch(requestUrl, { method: method, body: requestBody, }); const json = (await resp.json()) as any; console.log("Freedcamp API response:", json); if (!resp.ok || (json && json.http_code >= 400)) { return { error: json?.msg || resp.statusText, details: json }; } return { success: true, data: json?.data }; }
- src/freedcamp.ts:26-40 (helper)Builds authentication parameters for Freedcamp API calls, generating timestamp and HMAC hash if api_secret provided.export function buildFreedcampAuthParams(auth: FreedcampAuth): Record<string, string> { if (auth.api_secret) { const timestamp = Math.floor(Date.now() / 1000); const hash = generateFreedcampHash(auth.api_key, auth.api_secret, timestamp); return { api_key: auth.api_key, timestamp: String(timestamp), hash, }; } else { return { api_key: auth.api_key, }; } }