update_task
Modify an existing task's name, billing defaults, and active status. Only provided fields are updated.
Instructions
Update an existing task. Can modify task name, billing settings, and activity status. Only provided fields will be updated.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the task to update (required) | |
| name | No | Update task name | |
| billable_by_default | No | Update default billing status | |
| default_hourly_rate | No | Update default hourly rate | |
| is_default | No | Update default task status | |
| is_active | No | Update active status |
Implementation Reference
- src/tools/tasks.ts:76-92 (handler)The UpdateTaskHandler class implementing the ToolHandler interface. Its execute() method validates input via UpdateTaskSchema, calls harvestClient.updateTask(), and returns the result.
class UpdateTaskHandler implements ToolHandler { constructor(private readonly config: BaseToolConfig) {} async execute(args: Record<string, any>): Promise<CallToolResult> { try { const validatedArgs = validateInput(UpdateTaskSchema, args, 'update task'); logger.info('Updating task via Harvest API', { taskId: validatedArgs.id }); const task = await this.config.harvestClient.updateTask(validatedArgs); return { content: [{ type: 'text', text: JSON.stringify(task, null, 2) }], }; } catch (error) { return handleMCPToolError(error, 'update_task'); } } } - src/schemas/task.ts:75-77 (schema)The UpdateTaskSchema definition using Zod. It extends CreateTaskSchema.partial() (making all create fields optional) and adds a required 'id' field.
export const UpdateTaskSchema = CreateTaskSchema.partial().extend({ id: z.number().int().positive(), }); - src/tools/tasks.ts:167-186 (registration)Registration of the 'update_task' tool in the registerTaskTools() function. Defines the tool name, description, input schema (id required, fields optional), and maps to UpdateTaskHandler.
{ tool: { name: 'update_task', description: 'Update an existing task. Can modify task name, billing settings, and activity status. Only provided fields will be updated.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'The ID of the task to update (required)' }, name: { type: 'string', minLength: 1, description: 'Update task name' }, billable_by_default: { type: 'boolean', description: 'Update default billing status' }, default_hourly_rate: { type: 'number', minimum: 0, description: 'Update default hourly rate' }, is_default: { type: 'boolean', description: 'Update default task status' }, is_active: { type: 'boolean', description: 'Update active status' }, }, required: ['id'], additionalProperties: false, }, }, handler: new UpdateTaskHandler(config), }, - src/client/tasks-client.ts:65-86 (helper)The actual HTTP client method for update. Extracts 'id' from input, destructures updateData, and sends a PATCH request to /tasks/{id}.
async updateTask(input: any): Promise<any> { try { const { id, ...updateData } = input; this.logger.debug('Updating task', { taskId: id, updateFields: Object.keys(updateData) }); const response = await this.client.patch(`/tasks/${id}`, updateData); this.logger.info('Successfully updated task', { taskId: response.data.id, taskName: response.data.name }); return response.data; } catch (error) { this.logger.error('Failed to update task:', error); throw error; } } - src/client/harvest-api.ts:184-186 (helper)The delegation method in the main HarvestApi class that forwards updateTask calls to the tasksClient.
async updateTask(input: any): Promise<any> { return this.tasksClient.updateTask(input); }