Skip to main content
Glama

update_task

Modify task details like description or status in the coderide system using the task's unique identifier number.

Instructions

Updates an existing task's 'description' and/or 'status'. The task is identified by its unique 'number' (e.g., 'CRD-1'). At least one of 'description' or 'status' must be provided for an update.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numberYes
descriptionNo
statusNo

Implementation Reference

  • The execute method of UpdateTaskTool that performs the actual tool logic: extracts input, calls PUT /task/number/{taskNumber} via SecureApiClient, processes response, handles errors and returns formatted result.
    async execute(input: UpdateTaskInput): Promise<unknown> {
      logger.info('Executing update-task tool', input);
    
      try {
        // Use the injected API client to update task
        if (!this.apiClient) {
          throw new Error('API client not available - tool not properly initialized');
        }
    
        // Extract task number
        const { number, ...updateData } = input;
        
        // Convert task number to uppercase for consistency
        const taskNumber = number.toUpperCase();
        
        // Update task using the API endpoint
        const url = `/task/number/${taskNumber}`;
        logger.debug(`Making PUT request to: ${url}`);
        
        const responseData = await this.apiClient.put<UpdateTaskApiResponse>(url, updateData) as unknown as UpdateTaskApiResponse;
        
        if (!responseData.success) {
          const apiErrorMessage = responseData.message || 'API reported update failure without a specific message.';
          logger.warn(`Update task API call for ${taskNumber} returned success:false. Message: ${apiErrorMessage}`);
          return {
            isError: true,
            content: [{ type: "text", text: `Update for task ${taskNumber} failed: ${apiErrorMessage}` }]
          };
        }
    
        // At this point, responseData.success is true
        const updatedFieldsList = Object.keys(updateData).join(', ') || 'no specific fields (refresh)'; // Handle case where updateData is empty if API allows
        const apiMessage = responseData.message || 'Task successfully updated.';
    
        if (responseData.task) {
          return {
            number: responseData.task.number,
            title: responseData.task.title,
            description: responseData.task.description,
            status: responseData.task.status,
            updateConfirmation: `Task ${responseData.task.number} updated fields: ${updatedFieldsList}. API: ${apiMessage}`
          };
        } else {
          // responseData.success is true, but responseData.task is missing.
          logger.warn(`Update task API call for ${taskNumber} succeeded but returned no task data. API message: ${apiMessage}`);
          return {
            number: taskNumber, // Use input taskNumber as fallback
            title: '', // No title info available from response
            description: input.description || '', // Fallback to input description if available
            status: input.status || '',       // Fallback to input status if available
            updateConfirmation: `Task ${taskNumber} update reported success by API, but full task details were not returned. Attempted to update fields: ${updatedFieldsList}. API: ${apiMessage}`
          };
        }
      } catch (error) {
        let errorMessage = (error instanceof Error) ? error.message : 'An unknown error occurred';
        logger.error(`Error in update-task tool: ${errorMessage}`, error instanceof Error ? error : undefined);
    
        // Check if it's a not found error based on API response structure or message
        // Note: ApiError from apiClient already provides a safeErrorMessage
        if (error instanceof Error && (error as any).status === 404) {
           errorMessage = `Task with number '${input.number}' not found.`;
        } else if (error instanceof Error && error.message.includes('not found')) { // Fallback for other not found indications
           errorMessage = `Task with number '${input.number}' not found or update failed.`;
        }
        
        return {
          isError: true,
          content: [{ type: "text", text: errorMessage }]
        };
      }
    }
  • Zod schema UpdateTaskSchema defining input validation for the tool: requires task number (format XXX-NNN), optional description (max 2000 chars) and status (enum), with refine ensuring at least one update field.
    const UpdateTaskSchema = z.object({
      // Required field to identify the task
      number: z.string({
        required_error: "Task number is required to identify the task",
        invalid_type_error: "Task number must be a string"
      })
      .regex(/^[A-Za-z]{3}-\d+$/, { message: "Task number must be in the format ABC-123 (e.g., CRD-1 or crd-1). Case insensitive." })
      .describe("Task number to identify the task to update (case insensitive)"),
      
      // Optional fields that can be updated with security constraints
      description: z.string()
        .max(2000, "Description cannot exceed 2000 characters")
        .optional()
        .describe("New task description"),
      status: z.enum(['to-do', 'in-progress', 'done'], {
        invalid_type_error: "Status must be one of: to-do, in-progress, done"
      }).optional().describe("New task status"),
    }).strict().refine(
      // Ensure at least one field to update is provided
      (data) => {
        const updateFields = ['description', 'status'];
        return updateFields.some(field => field in data);
      },
      {
        message: 'At least one field to update must be provided',
        path: ['updateFields']
      }
    );
  • src/index.ts:315-330 (registration)
    In createProductionServer, instantiates UpdateTaskTool with SecureApiClient dependency and adds to tools array, then registers all tools with the MCP Server via tool.register(server). Import at line 24.
    const tools: any[] = [
      new StartProjectTool(secureApiClient),
      new GetPromptTool(secureApiClient),
      new GetTaskTool(secureApiClient),
      new GetProjectTool(secureApiClient),
      new UpdateTaskTool(secureApiClient),
      new UpdateProjectTool(secureApiClient),
      new ListProjectsTool(secureApiClient),
      new ListTasksTool(secureApiClient),
      new NextTaskTool(secureApiClient),
    ];
    
    // Register each tool with the server
    tools.forEach(tool => {
      tool.register(server);
    });

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/PixdataOrg/coderide-mcp'

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