Skip to main content
Glama

delete_task

Remove a task from the orchestration server when it has no dependent tasks, ensuring clean task management and coordination.

Instructions

Delete a task if it has no dependents

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYesID of the task to delete

Implementation Reference

  • The handler for the 'delete_task' tool. It extracts the task_id from arguments, checks if the task exists and has no dependent tasks, deletes the task from the tasks object, saves the changes to the JSON file, and returns a confirmation message.
    case "delete_task": {
      const { task_id } = request.params.arguments as {
        task_id: string;
      };
    
      debug(`Deleting task ${task_id}`);
    
      const task = tasks[task_id];
      if (!task) {
        throw new McpError(ErrorCode.InvalidRequest, `Task ${task_id} not found`);
      }
    
      // Check if any other tasks depend on this one
      const dependentTasks = Object.values(tasks).filter(t => 
        t.dependencies?.includes(task_id)
      );
    
      if (dependentTasks.length > 0) {
        throw new McpError(
          ErrorCode.InvalidRequest, 
          `Cannot delete task ${task_id} as it has dependent tasks: ${dependentTasks.map(t => t.id).join(', ')}`
        );
      }
    
      delete tasks[task_id];
      saveTasks();
      debug(`Deleted task ${task_id}`);
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify({ deleted: task_id }, null, 2)
        }]
      };
    }
  • src/index.ts:388-401 (registration)
    Registration of the 'delete_task' tool in the ListToolsRequestSchema handler, providing the tool's name, description, and input schema for discovery by MCP clients.
    {
      name: "delete_task",
      description: "Delete a task if it has no dependents",
      inputSchema: {
        type: "object",
        properties: {
          task_id: {
            type: "string",
            description: "ID of the task to delete"
          }
        },
        required: ["task_id"]
      }
    },
  • The input schema for the 'delete_task' tool, defining the required 'task_id' parameter.
    inputSchema: {
      type: "object",
      properties: {
        task_id: {
          type: "string",
          description: "ID of the task to delete"
        }
      },
      required: ["task_id"]
    }

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/mokafari/orchestrator-server'

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