Skip to main content
Glama

clear_all_tasks

Clear unfinished tasks and reset the task list on mcp-chain-of-thought server. Use this tool to remove all pending tasks, ensuring a clean slate for new tasks.

Instructions

Clear unfinished tasks and reset the task list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
confirmYesConfirm to delete all unfinished tasks (this operation is irreversible)

Implementation Reference

  • The handler function for the 'clear_all_tasks' tool. Validates the confirm parameter, checks if tasks exist, invokes the modelClearAllTasks function to perform the clearing, and returns a formatted response using prompts.
    export async function clearAllTasks({
      confirm,
    }: z.infer<typeof clearAllTasksSchema>) {
      // Security check: If not confirmed, refuse operation
      if (!confirm) {
        return {
          content: [
            {
              type: "text" as const,
              text: getClearAllTasksPrompt({ confirm: false }),
            },
          ],
        };
      }
    
      // Check if there are really tasks to clear
      const allTasks = await getAllTasks();
      if (allTasks.length === 0) {
        return {
          content: [
            {
              type: "text" as const,
              text: getClearAllTasksPrompt({ isEmpty: true }),
            },
          ],
        };
      }
    
      // Execute clear operation
      const result = await modelClearAllTasks();
    
      return {
        content: [
          {
            type: "text" as const,
            text: getClearAllTasksPrompt({
              success: result.success,
              message: result.message,
              backupFile: result.backupFile,
            }),
          },
        ],
        isError: !result.success,
      };
    }
  • Zod schema defining the input parameters for the clear_all_tasks tool, requiring explicit confirmation via a boolean flag.
    export const clearAllTasksSchema = z.object({
      confirm: z
        .boolean()
        .refine((val) => val === true, {
          message:
            "Must clearly confirm the clear operation, please set the confirm parameter to true to confirm this dangerous operation",
        })
        .describe("Confirm to delete all unfinished tasks (this operation is irreversible)"),
    });
  • src/index.ts:290-296 (registration)
    Registration of the 'clear_all_tasks' tool in the MCP server's list of tools, including name, description from MD template, and input schema conversion.
    {
      name: "clear_all_tasks",
      description: loadPromptFromTemplate(
        "toolsDescription/clearAllTasks.md"
      ),
      inputSchema: zodToJsonSchema(clearAllTasksSchema),
    },
  • Core helper function (aliased as modelClearAllTasks) that implements the task clearing logic: backs up completed tasks to a timestamped JSON file in the memory directory and clears all unfinished tasks from the main tasks.json file.
    export async function clearAllTasks(): Promise<{
      success: boolean;
      message: string;
      backupFile?: string;
    }> {
      try {
        // Ensure data directory exists
        await ensureDataDir();
    
        // Read existing tasks
        const allTasks = await readTasks();
    
        // If there are no tasks, return directly
        if (allTasks.length === 0) {
          return { success: true, message: "No tasks need to be cleared" };
        }
    
        // Filter out completed tasks
        const completedTasks = allTasks.filter(
          (task) => task.status === TaskStatus.COMPLETED
        );
    
        // Create backup file name
        const timestamp = new Date()
          .toISOString()
          .replace(/:/g, "-")
          .replace(/\..+/, "");
        const backupFileName = `tasks_memory_${timestamp}.json`;
    
        // Ensure memory directory exists
        const MEMORY_DIR = path.join(DATA_DIR, "memory");
        try {
          await fs.access(MEMORY_DIR);
        } catch (error) {
          await fs.mkdir(MEMORY_DIR, { recursive: true });
        }
    
        // Create memory directory backup path
        const memoryFilePath = path.join(MEMORY_DIR, backupFileName);
    
        // Write to memory directory at the same time (only include completed tasks)
        await fs.writeFile(
          memoryFilePath,
          JSON.stringify({ tasks: completedTasks }, null, 2)
        );
    
        // Clear task file
        await writeTasks([]);
    
        return {
          success: true,
          message: `All tasks cleared successfully, ${allTasks.length} tasks deleted, ${completedTasks.length} completed tasks backed up to memory directory`,
          backupFile: backupFileName,
        };
      } catch (error) {
        return {
          success: false,
          message: `Error clearing tasks: ${
            error instanceof Error ? error.message : String(error)
          }`,
        };
      }
    }
  • Helper function that generates context-aware prompts for the clear_all_tasks tool responses, handling cases like unconfirmed, empty tasks, success/failure with backup info.
    export function getClearAllTasksPrompt(
      params: ClearAllTasksPromptParams
    ): string {
      const { confirm, success, message, backupFile, isEmpty } = params;
    
      // Handle unconfirmed case
      if (confirm === false) {
        const cancelTemplate = loadPromptFromTemplate("clearAllTasks/cancel.md");
        return generatePrompt(cancelTemplate, {});
      }
    
      // Handle case when no tasks need to be cleared
      if (isEmpty) {
        const emptyTemplate = loadPromptFromTemplate("clearAllTasks/empty.md");
        return generatePrompt(emptyTemplate, {});
      }
    
      // Handle successful or failed clearing
      const responseTitle = success ? "Success" : "Failure";
    
      // Generate backupInfo using template
      const backupInfo = backupFile
        ? generatePrompt(loadPromptFromTemplate("clearAllTasks/backupInfo.md"), {
            backupFile,
          })
        : "";
    
      const indexTemplate = loadPromptFromTemplate("clearAllTasks/index.md");
      const prompt = generatePrompt(indexTemplate, {
        responseTitle,
        message,
        backupInfo,
      });
    
      // Load possible custom prompt
      return loadPrompt(prompt, "CLEAR_ALL_TASKS");
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It mentions 'reset the task list' and implies deletion, but doesn't specify behavioral details like whether this requires admin permissions, affects other data, or has rate limits. The input schema's parameter description adds that it's 'irreversible', which helps, but more context on effects is needed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with just one sentence that directly states the tool's action and resource. It's front-loaded and wastes no words, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a destructive operation with no annotations and no output schema, the description is insufficient. It doesn't explain what 'reset' entails, what happens to finished tasks, or what the return value might be, leaving gaps in understanding the tool's full impact.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already documents the 'confirm' parameter as requiring confirmation for irreversible deletion. The description doesn't add any additional meaning beyond what the schema provides, such as explaining why confirmation is needed or default behaviors, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('clear' and 'reset') and resource ('unfinished tasks' and 'task list'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'delete_task' or 'complete_task', which might handle individual tasks rather than bulk operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'delete_task' for individual deletions or 'complete_task' for finishing tasks. The description lacks context about prerequisites, such as whether this should be used for cleanup or resetting state, leaving usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/liorfranko/mcp-chain-of-thought'

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