Skip to main content
Glama

taskStepAdd

Add a new step to an existing task by specifying the task ID and step description, with optional ordering and time estimation.

Instructions

為任務添加新步驟

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdYes
descriptionYes
orderNo
estimatedTimeNo

Implementation Reference

  • Core handler implementation for adding a new task step. Loads tasks from JSON file, finds the target task, creates new step with UUID and order, appends it, sorts steps by order, updates timestamp, and persists changes back to JSON.
    public static async addTaskStep(
      taskId: string,
      description: string,
      order?: number,
      estimatedTime?: number
    ): Promise<Task | null> {
      const tasks = await this.readTasks();
      const taskIndex = tasks.findIndex(t => t.id === taskId);
    
      if (taskIndex === -1) {
        return null;
      }
    
      const task = tasks[taskIndex];
    
      // 確定步驟順序
      const newOrder = order || task.steps.length + 1;
    
      // 創建新步驟
      const newStep: TaskStep = {
        id: uuidv4(),
        description,
        completed: false,
        order: newOrder,
        estimatedTime
      };
    
      // 添加新步驟
      task.steps.push(newStep);
    
      // 重新排序步驟
      task.steps.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
    
      // 更新任務
      task.updatedAt = new Date().toISOString();
    
      // 保存所有任務
      await this.writeTasks(tasks);
    
      return task;
    }
  • main.ts:746-773 (registration)
    MCP tool registration for 'taskStepAdd', including input schema (Zod) and thin async handler wrapper that delegates to TaskManagerTool.addTaskStep and formats response.
    server.tool("taskStepAdd",
        "為任務添加新步驟",
        {
            taskId: z.string(),
            description: z.string(),
            order: z.number().optional(),
            estimatedTime: z.number().optional()
        },
        async ({ taskId, description, order, estimatedTime }) => {
            try {
                const updatedTask = await TaskManagerTool.addTaskStep(taskId, description, order, estimatedTime);
    
                if (!updatedTask) {
                    return {
                        content: [{ type: "text", text: `未找到ID為 ${taskId} 的任務` }]
                    };
                }
    
                return {
                    content: [{ type: "text", text: `步驟添加成功:\n${JSON.stringify(updatedTask, null, 2)}` }]
                };
            } catch (error) {
                return {
                    content: [{ type: "text", text: `添加步驟失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }]
                };
            }
        }
    );
  • TypeScript interface definition for TaskStep, used in the task data structure and matching the tool's input schema.
    export interface TaskStep {
      /**
       * 步驟ID
       */
      id: string;
      
      /**
       * 步驟描述
       */
      description: string;
      
      /**
       * 步驟是否完成
       */
      completed?: boolean;
      
      /**
       * 步驟順序
       */
      order?: number;
      
      /**
       * 步驟預估完成時間(分鐘)
       */
      estimatedTime?: number;
    }
  • Helper methods for reading and writing tasks to/from JSON file, used by the addTaskStep handler for persistence.
    private static async readTasks(): Promise<Task[]> {
      await this.ensureTasksDirectory();
    
      try {
        const tasksFile = this.getTasksFilePath();
        const fileContent = fs.readFileSync(tasksFile, 'utf-8');
        const data = JSON.parse(fileContent);
        return data.tasks || [];
      } catch (error) {
        console.error('Error reading tasks:', error);
        throw new Error(`讀取任務失敗: ${error instanceof Error ? error.message : '未知錯誤'}`);
      }
    }
    
    /**
     * 寫入所有任務
     */
    private static async writeTasks(tasks: Task[]): Promise<void> {
      await this.ensureTasksDirectory();
    
      try {
        const tasksFile = this.getTasksFilePath();
        fs.writeFileSync(tasksFile, JSON.stringify({ tasks }, null, 2));
      } catch (error) {
        console.error('Error writing tasks:', error);
        throw new Error(`寫入任務失敗: ${error instanceof Error ? error.message : '未知錯誤'}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. '添加' (add) implies a write/mutation operation, but the description doesn't disclose permissions needed, whether steps are appended or inserted at specific positions, what happens on duplicate orders, or error conditions. For a mutation tool with zero annotation coverage, this is insufficient.

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 a single, efficient phrase in Chinese that directly states the tool's purpose. There's no wasted language, repetition, or unnecessary elaboration. It's appropriately sized for a straightforward tool.

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?

For a mutation tool with 4 parameters (0% schema coverage), no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns, error conditions, or important behavioral aspects like how 'order' affects step sequencing. The agent lacks critical information for proper invocation.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate by explaining parameters. It mentions '新步驟' (new steps) which hints at the 'description' parameter but doesn't clarify what 'taskId', 'order', or 'estimatedTime' represent. The description adds minimal value beyond what's inferable from parameter names.

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 '為任務添加新步驟' (add new steps to a task) clearly states the verb ('添加' - add) and resource ('任務步驟' - task steps). It distinguishes from siblings like taskCreate (creates entire tasks) and taskStepUpdate (updates existing steps). However, it doesn't specify whether this adds single or multiple steps, which keeps it from a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., task must exist), when to use taskStepUpdate instead for modifications, or how it differs from taskSetAllSteps (which presumably replaces all steps). The agent must infer usage from tool names alone.

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/GonTwVn/GonMCPtool'

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