Skip to main content
Glama

task_batch_update

Idempotent

Update multiple tasks at once by specifying IDs to change their status, priority, or assignee.

Instructions

Update multiple tasks at once. Useful for changing status of several tasks (e.g., mark 3 tasks as done) or reassigning tasks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idsYesTask IDs to update
statusNo
priorityNo
assigned_toNo

Implementation Reference

  • The main handler function for task_batch_update. Iterates over task IDs, updates status/priority/assigned_to in a transaction, logs changes, auto-tracks time when moving to 'done', and re-evaluates downstream dependencies.
    function handleTaskBatchUpdate(args: Record<string, unknown>) {
      const db = getDb();
      const ids = args.ids as number[];
      const status = args.status as string | undefined;
      const priority = args.priority as string | undefined;
      const assignedTo = args.assigned_to as string | undefined;
    
      if (!status && !priority && assignedTo === undefined) {
        throw new Error('Provide at least one field to update: status, priority, or assigned_to');
      }
    
      const getStmt = db.prepare('SELECT * FROM tasks WHERE id = ?');
    
      const results = db.transaction(() => {
        return ids.map((id) => {
          const oldRow = getStmt.get(id) as Record<string, unknown> | undefined;
          if (!oldRow) throw new Error(`Task ${id} not found`);
    
          const updates: string[] = [];
          const params: unknown[] = [];
    
          if (status) {
            updates.push('status = ?');
            params.push(status);
          }
          if (priority) {
            updates.push('priority = ?');
            params.push(priority);
          }
          if (assignedTo !== undefined) {
            updates.push('assigned_to = ?');
            params.push(assignedTo);
          }
    
          updates.push("updated_at = datetime('now')");
          params.push(id);
    
          const newRow = db
            .prepare(`UPDATE tasks SET ${updates.join(', ')} WHERE id = ? RETURNING *`)
            .get(...params) as Record<string, unknown>;
    
          // Log status changes
          if (status && oldRow.status !== status) {
            logActivity(
              db, 'task', id, 'status_changed', 'status',
              oldRow.status as string, status,
              `Task '${newRow.title}' status: ${oldRow.status} -> ${status}`
            );
          }
          if (priority && oldRow.priority !== priority) {
            logActivity(
              db, 'task', id, 'updated', 'priority',
              oldRow.priority as string, priority,
              `Task '${newRow.title}' priority: ${oldRow.priority} -> ${priority}`
            );
          }
    
          // Auto time tracking
          if (status === 'done' && oldRow.status !== 'done' && !newRow.actual_hours) {
            const startEntry = db.prepare(
              `SELECT created_at FROM activity_log
               WHERE entity_type = 'task' AND entity_id = ? AND action = 'status_changed'
                 AND field_name = 'status' AND new_value = 'in_progress'
               ORDER BY created_at DESC LIMIT 1`
            ).get(id) as { created_at: string } | undefined;
    
            if (startEntry) {
              const startMs = new Date(startEntry.created_at + 'Z').getTime();
              const nowMs = Date.now();
              const hours = Math.round(((nowMs - startMs) / 3_600_000) * 10) / 10;
              if (hours > 0) {
                db.prepare('UPDATE tasks SET actual_hours = ? WHERE id = ?').run(hours, id);
                newRow.actual_hours = hours;
                logActivity(db, 'task', id, 'updated', 'actual_hours', null, String(hours),
                  `Task '${newRow.title}' auto-tracked: ${hours}h`);
              }
            }
          }
    
          // Re-evaluate downstream dependencies when task marked done
          if (status === 'done' && oldRow.status !== 'done') {
            reevaluateDownstream(db, id);
          }
    
          return newRow;
        });
      })();
    
      return { updated: results.length, tasks: results };
    }
  • Input schema definition for task_batch_update. Accepts 'ids' (required array of integers), plus optional 'status', 'priority', and 'assigned_to'.
    {
      name: 'task_batch_update',
      description:
        'Update multiple tasks at once. Useful for changing status of several tasks (e.g., mark 3 tasks as done) or reassigning tasks.',
      annotations: { title: 'Batch Update Tasks', readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
      inputSchema: {
        type: 'object',
        properties: {
          ids: {
            type: 'array',
            items: { type: 'integer' },
            description: 'Task IDs to update',
          },
          status: { type: 'string', enum: ['todo', 'in_progress', 'review', 'done', 'blocked'] },
          priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
          assigned_to: { type: 'string' },
        },
        required: ['ids'],
      },
    },
  • Registration of task_batch_update handler in the exported handlers map used by src/index.ts.
    export const handlers: Record<string, ToolHandler> = {
      activity_log: handleActivityLog,
      tracker_session_diff: handleSessionDiff,
      task_batch_update: handleTaskBatchUpdate,
    };
  • src/index.ts:23-35 (registration)
    Top-level tool registration: activityDefs (which includes task_batch_update schema) is spread into ALL_TOOLS array.
    const ALL_TOOLS: Tool[] = [
      ...projectDefs,
      ...epicDefs,
      ...taskDefs,
      ...subtaskDefs,
      ...noteDefs,
      ...commentDefs,
      ...templateDefs,
      ...dashboardDefs,
      ...searchDefs,
      ...activityDefs,
      ...exportImportDefs,
    ];
  • reevaluateDownstream helper - called by handleTaskBatchUpdate when tasks are marked 'done' to re-evaluate dependencies of downstream tasks.
    export function reevaluateDownstream(db: Database.Database, completedTaskId: number): void {
      const downstream = db.prepare(
        'SELECT task_id FROM task_dependencies WHERE depends_on_task_id = ?'
      ).all(completedTaskId) as Array<{ task_id: number }>;
    
      for (const row of downstream) {
        evaluateAndUpdateDependencies(db, row.task_id);
      }
    }
Behavior3/5

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

Annotations already indicate readOnlyHint=false, destructiveHint=false, and idempotentHint=true. The description's 'update' aligns with these. No additional behavioral details are provided beyond the annotations (e.g., partial failure handling, authentication requirements, or side effects). The description adds moderate context but does not deepen transparency.

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?

Two sentences, front-loaded with the core purpose, followed by concrete usage examples. Every word earns its place; no filler or repetition. Highly efficient.

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

Completeness3/5

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

For a batch operation with 4 parameters and no output schema, the description covers basic use cases but lacks guidance on error behavior (e.g., partial updates, rollback), performance considerations for large batches, or expected return format. While not severely incomplete, it leaves gaps that an agent might need resolved via experimentation.

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?

With schema_description_coverage at 25% (only 'ids' has a description), the description partially compensates by mentioning 'status' and 'assigned_to' through examples. However, it does not explain 'priority' or provide format/constraint details beyond what the schema enums offer. The examples add value but coverage remains incomplete.

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 function: 'Update multiple tasks at once.' It gives specific examples ('mark 3 tasks as done, reassign tasks') which ties verb (update) to resource (tasks) and distinguishes from single-task update siblings like task_update.

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

Usage Guidelines3/5

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

The description implies usage scenarios ('change status of several tasks, reassign tasks') but does not explicitly state when not to use this tool (e.g., for single updates use task_update) or provide exclusion criteria. The 'useful for' phrasing provides context but lacks clear alternatives.

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/spranab/saga-mcp'

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