Skip to main content
Glama
108yen

task-orchestrator-mcp

by 108yen

createTask

Initiate new tasks with hierarchical organization and positioning for structured workflow management in task orchestration.

Instructions

Create a new task with optional parent and index positioning.

This tool initiates a new workflow for handling user requests. To manage tasks, you MUST always run this tool first. The workflow is as follows:

  1. Create tasks with the provided name and optional description. Tasks are organized in a hierarchical structure where subtasks can be created by specifying parentId.

  2. Tasks are ordered by their position in the parent's tasks array. Use insertIndex to specify position (defaults to end).

  3. After task creation, you MUST call the startTask tool to begin processing the task.

  4. When the task is completed, call the completeTask tool with the task ID and resolution details.

  5. If the following task is assigned, execute it by calling the startTask tool again.

  6. Repeat this cycle until all tasks are completed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
completion_criteriaNoCompletion criteria for the task (optional)
constraintsNoConstraints for task execution (optional)
descriptionNoTask description (optional)
insertIndexNoIndex position within parent's tasks array (optional, defaults to end of array)
nameYesTask name (required)
parentIdNoParent task ID for hierarchical organization (optional)
tasksNoArray of subtasks to create simultaneously (optional)

Implementation Reference

  • Core handler function that orchestrates task creation: validates parameters, loads existing tasks, creates hierarchical task structure (including subtasks), inserts at correct position, persists changes, and returns created task with message.
    export function createTask(params: {
      completion_criteria?: string[]
      constraints?: string[]
      description?: string
      insertIndex?: number
      name: string
      parentId?: string
      tasks?: TaskInput[]
    }): { message?: string; task: Task } {
      const {
        completion_criteria,
        constraints,
        description = "",
        insertIndex,
        name,
        parentId,
        tasks: subtasks,
      } = params
    
      // Validate basic parameters
      validateCreateTaskBasicParams({
        completion_criteria,
        constraints,
        insertIndex,
        name,
      })
    
      // Validate subtasks
      validateSubtasks(subtasks)
    
      // Load and validate parent task
      const allTasks = readTasks()
      const parentTask = validateAndFindParentTask(parentId, allTasks)
    
      // Create new task object
      const newTask = createTaskObject(
        {
          completion_criteria,
          constraints,
          description,
          name,
        },
        subtasks,
      )
    
      // Insert task into hierarchy
      insertTaskIntoHierarchy(newTask, parentTask, allTasks, insertIndex)
    
      // Save to storage
      writeTasks(allTasks)
    
      // Generate response message
      const message = generateCreationMessage(newTask, parentId)
    
      return { message, task: newTask }
    }
  • src/tools.ts:29-115 (registration)
    Registers the 'createTask' tool with the MCP server, defining detailed description, Zod input schema for validation, and a wrapper handler that calls the core createTask function with error handling and JSON response formatting.
    // Register createTask tool
    server.registerTool(
      "createTask",
      {
        description:
          "Create a new task with optional parent and index positioning.\n\n" +
          "This tool initiates a new workflow for handling user requests. To manage tasks, you MUST always run this tool first. The workflow is as follows:\n" +
          "1. Create tasks with the provided name and optional description. Tasks are organized in a hierarchical structure where subtasks can be created by specifying parentId.\n" +
          "2. Tasks are ordered by their position in the parent's tasks array. Use insertIndex to specify position (defaults to end).\n" +
          "3. After task creation, you MUST call the `startTask` tool to begin processing the task.\n" +
          "4. When the task is completed, call the `completeTask` tool with the task ID and resolution details.\n" +
          "5. If the following task is assigned, execute it by calling the `startTask` tool again.\n" +
          "6. Repeat this cycle until all tasks are completed.",
        inputSchema: {
          completion_criteria: z
            .array(z.string())
            .describe("Completion criteria for the task (optional)")
            .optional(),
          constraints: z
            .array(z.string())
            .describe("Constraints for task execution (optional)")
            .optional(),
          description: z
            .string()
            .describe("Task description (optional)")
            .optional(),
          insertIndex: z
            .number()
            .describe(
              "Index position within parent's tasks array (optional, defaults to end of array)",
            )
            .optional(),
          name: z.string().describe("Task name (required)"),
          parentId: z
            .string()
            .describe("Parent task ID for hierarchical organization (optional)")
            .optional(),
          tasks: z
            .array(TaskInputSchema)
            .describe("Array of subtasks to create simultaneously (optional)")
            .optional(),
        },
      },
      (args) => {
        try {
          const result = createTask(
            args as {
              completion_criteria?: string[]
              constraints?: string[]
              description?: string
              insertIndex?: number
              name: string
              parentId?: string
              tasks?: TaskInput[]
            },
          )
          return {
            content: [
              {
                text: JSON.stringify(result, null, 2),
                type: "text",
              },
            ],
          }
        } catch (error) {
          return {
            content: [
              {
                text: JSON.stringify(
                  {
                    error: {
                      code: "TASK_CREATION_ERROR",
                      message:
                        error instanceof Error ? error.message : "Unknown error",
                    },
                  },
                  null,
                  2,
                ),
                type: "text",
              },
            ],
            isError: true,
          }
        }
      },
    )
  • Zod schema defining the input parameters for createTask tool, including hierarchical subtasks support via recursive TaskInputSchema.
    inputSchema: {
      completion_criteria: z
        .array(z.string())
        .describe("Completion criteria for the task (optional)")
        .optional(),
      constraints: z
        .array(z.string())
        .describe("Constraints for task execution (optional)")
        .optional(),
      description: z
        .string()
        .describe("Task description (optional)")
        .optional(),
      insertIndex: z
        .number()
        .describe(
          "Index position within parent's tasks array (optional, defaults to end of array)",
        )
        .optional(),
      name: z.string().describe("Task name (required)"),
      parentId: z
        .string()
        .describe("Parent task ID for hierarchical organization (optional)")
        .optional(),
      tasks: z
        .array(TaskInputSchema)
        .describe("Array of subtasks to create simultaneously (optional)")
        .optional(),
    },
  • Helper function for basic parameter validation used within createTask, checking name, arrays of strings for criteria/constraints, and numeric insertIndex.
    function validateCreateTaskBasicParams(params: {
      completion_criteria?: string[]
      constraints?: string[]
      insertIndex?: number
      name: string
    }): void {
      const { completion_criteria, constraints, insertIndex, name } = params
    
      if (!name || typeof name !== "string" || name.trim() === "") {
        throw new Error("Task name is required and must be a non-empty string")
      }
    
      // Validate completion_criteria if provided
      if (completion_criteria !== undefined) {
        if (!Array.isArray(completion_criteria)) {
          throw new Error("Completion criteria must be an array")
        }
        if (completion_criteria.some((criteria) => typeof criteria !== "string")) {
          throw new Error("All completion criteria must be strings")
        }
      }
    
      // Validate constraints if provided
      if (constraints !== undefined) {
        if (!Array.isArray(constraints)) {
          throw new Error("Constraints must be an array")
        }
        if (constraints.some((constraint) => typeof constraint !== "string")) {
          throw new Error("All constraints must be strings")
        }
      }
    
      // Validate insertIndex if provided
      if (insertIndex !== undefined && typeof insertIndex !== "number") {
        throw new Error("Insert index must be a number")
      }
    }
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by explaining the hierarchical structure, ordering behavior, and mandatory workflow sequence. It doesn't mention permissions, rate limits, or error conditions, but provides substantial behavioral context beyond basic creation.

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

Conciseness3/5

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

The description is appropriately front-loaded with the core purpose, but the lengthy workflow explanation (6 steps) contains redundant information about sibling tools that belongs in general documentation rather than this specific tool's description. Some sentences don't directly earn their place in this tool's definition.

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

Completeness4/5

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

For a creation tool with no annotations and no output schema, the description provides good context about the hierarchical system and workflow integration. It could better explain what happens on creation failure or the return format, but covers the essential behavioral expectations given the complexity.

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 schema already documents all 7 parameters thoroughly. The description mentions parentId and insertIndex semantics but doesn't add significant meaning beyond what the schema provides. The baseline of 3 is appropriate when schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('Create a new task') and resource ('task'), distinguishing it from siblings like updateTask or deleteTask. It explicitly mentions optional parent and index positioning, which differentiates it from simple creation tools.

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

Usage Guidelines5/5

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

The description provides explicit workflow guidance: 'you MUST always run this tool first' and outlines a complete sequence involving startTask and completeTask. It distinguishes when to use this tool versus alternatives by positioning it as the initial step in task management.

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

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/108yen/task-orchestrator-mcp'

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