Skip to main content
Glama

deleteTask

Remove one or more tasks from a specified project by providing the project ID and task IDs. Deleting a task also removes its subtasks and dependency links. Returns the count of successfully deleted tasks.

Instructions

Deletes one or more tasks within a specified project. Requires the project ID and an array of task IDs to delete. Note: Deleting a task also deletes its subtasks and dependency links due to database cascade rules. Returns the count of successfully deleted tasks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe unique identifier (UUID) of the project containing the tasks to delete. This project must exist.
task_idsYesAn array of task IDs (UUIDs, 1-100) to be deleted from the specified project.

Implementation Reference

  • The async processRequest function implements the core logic of the deleteTask tool handler. It processes the input arguments, calls TaskService.deleteTasks(project_id, task_ids), handles errors, and returns a JSON response with the deleted count.
    const processRequest = async (args: DeleteTaskArgs): Promise<{ content: { type: 'text', text: string }[] }> => { logger.info(`[${TOOL_NAME}] Received request to delete ${args.task_ids.length} tasks from project ${args.project_id}`); try { // Call the service method to delete the tasks const deletedCount = await taskService.deleteTasks(args.project_id, args.task_ids); // Format the successful response logger.info(`[${TOOL_NAME}] Successfully deleted ${deletedCount} tasks from project ${args.project_id}`); return { content: [{ type: "text" as const, text: JSON.stringify({ success: true, deleted_count: deletedCount }) }] }; } catch (error: unknown) { // Handle potential errors according to systemPatterns.md mapping logger.error(`[${TOOL_NAME}] Error processing request:`, error); if (error instanceof NotFoundError) { // Project or one/more tasks not found - Map to InvalidParams as per convention throw new McpError(ErrorCode.InvalidParams, error.message); } else { // Generic internal error const message = error instanceof Error ? error.message : 'An unknown error occurred while deleting tasks.'; throw new McpError(ErrorCode.InternalError, message); } } };
  • Defines TOOL_PARAMS Zod schema for input validation (project_id: uuid, task_ids: array of uuids with min/max), TOOL_NAME, TOOL_DESCRIPTION, and DeleteTaskArgs type.
    // Zod schema for the parameters, matching FR-012 export const TOOL_PARAMS = z.object({ project_id: z.string() .uuid("The project_id must be a valid UUID.") .describe("The unique identifier (UUID) of the project containing the tasks to delete. This project must exist."), // Required, UUID format task_ids: z.array( z.string() .uuid("Each task ID must be a valid UUID.") .describe("A unique identifier (UUID) of a task to delete.") ) .min(1, "At least one task ID must be provided.") .max(100, "Cannot delete more than 100 tasks per call.") .describe("An array of task IDs (UUIDs, 1-100) to be deleted from the specified project."), // Required, array of UUID strings, limits }); // Define the expected type for arguments based on the Zod schema export type DeleteTaskArgs = z.infer<typeof TOOL_PARAMS>;
  • Registers the deleteTask tool on the MCP server using server.tool() with name, description, schema.shape, and processRequest handler.
    // Register the tool with the server server.tool(TOOL_NAME, TOOL_DESCRIPTION, TOOL_PARAMS.shape, processRequest); // Using .shape as this schema doesn't use .refine() logger.info(`[${TOOL_NAME}] Tool registered successfully.`);
  • Invokes deleteTaskTool(server, taskService) within registerTools to register the tool during server setup.
    deleteTaskTool(server, taskService); // Register deleteTask tool
  • Exports the exact tool name constant TOOL_NAME = "deleteTask" used in registration.
    export const TOOL_NAME = "deleteTask";

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/bsmi021/mcp-task-manager-server'

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