Skip to main content
Glama
aafsar

Task Manager MCP Server

by aafsar

delete_task

Remove tasks from the Task Manager MCP Server by specifying the task ID to clear completed or unwanted items and maintain an organized task list.

Instructions

Delete a task by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdYesTask ID (use first 8 characters)

Implementation Reference

  • The primary handler function for the 'delete_task' MCP tool. It validates the input arguments using TaskIdSchema, loads the task storage, finds the task by prefix-matching the ID, removes it from the array using splice, persists the changes, and returns a formatted text response indicating success or failure.
    export async function deleteTask(args: unknown) {
      // Validate input
      const validated = TaskIdSchema.parse(args);
    
      // Load tasks
      const storage = await loadTasks();
    
      // Find task index
      const taskIndex = storage.tasks.findIndex((t) =>
        t.id.startsWith(validated.taskId)
      );
    
      if (taskIndex === -1) {
        return {
          content: [
            {
              type: "text",
              text: `❌ Task with ID ${validated.taskId} not found.`,
            },
          ],
        };
      }
    
      // Remove task
      const deletedTask = storage.tasks.splice(taskIndex, 1)[0]!;
      await saveTasks(storage);
    
      return {
        content: [
          {
            type: "text",
            text: `🗑️ Task "${deletedTask.title}" deleted successfully.`,
          },
        ],
      };
    }
  • Zod schema (TaskIdSchema) used for input validation within the delete_task handler.
    export const TaskIdSchema = z.object({
      taskId: z.string().min(8, "Task ID must be at least 8 characters"),
    });
  • JSON Schema definition for the 'delete_task' tool provided to MCP clients via the tools list.
    name: "delete_task",
    description: "Delete a task by ID",
    inputSchema: {
      type: "object",
      properties: {
        taskId: {
          type: "string",
          description: "Task ID (use first 8 characters)",
          minLength: 8,
        },
      },
      required: ["taskId"],
    },
  • src/index.ts:224-225 (registration)
    Dispatch logic in the MCP CallToolRequest handler that routes 'delete_task' calls to the deleteTask function.
    case "delete_task":
      return await deleteTask(args);
  • src/index.ts:13-21 (registration)
    Import statement registering the deleteTask handler function from tools.ts into the main index module.
      createTask,
      listTasks,
      updateTask,
      deleteTask,
      completeTask,
      searchTasks,
      getTaskStats,
      clearCompleted,
    } from "./tools.js";

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

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