update_expense
Modify existing expense records in Harvest by updating project, category, cost, or billing details. Only specified fields are changed.
Instructions
Update an existing expense including project, category, cost, and billing details. Only provided fields will be updated.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the expense to update (required) | |
| user_id | No | Update the user ID | |
| project_id | No | Update the project ID | |
| expense_category_id | No | Update the expense category ID | |
| spent_date | No | Update the spent date | |
| notes | No | Update the notes | |
| total_cost | No | Update the total cost | |
| units | No | Update the units | |
| billable | No | Update the billable status |
Implementation Reference
- src/tools/expenses.ts:77-93 (handler)The UpdateExpenseHandler class implements the tool's core logic, using UpdateExpenseSchema for input validation and calling the Harvest API's updateExpense method.
class UpdateExpenseHandler implements ToolHandler { constructor(private readonly config: BaseToolConfig) {} async execute(args: Record<string, any>): Promise<CallToolResult> { try { const validatedArgs = validateInput(UpdateExpenseSchema, args, 'update expense'); logger.info('Updating expense via Harvest API', { expenseId: validatedArgs.id }); const expense = await this.config.harvestClient.updateExpense(validatedArgs); return { content: [{ type: 'text', text: JSON.stringify(expense, null, 2) }], }; } catch (error) { return handleMCPToolError(error, 'update_expense'); } } } - src/tools/expenses.ts:195-217 (registration)Registration of the update_expense tool within the registerExpenseTools function.
{ tool: { name: 'update_expense', description: 'Update an existing expense including project, category, cost, and billing details. Only provided fields will be updated.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'The ID of the expense to update (required)' }, user_id: { type: 'number', description: 'Update the user ID' }, project_id: { type: 'number', description: 'Update the project ID' }, expense_category_id: { type: 'number', description: 'Update the expense category ID' }, spent_date: { type: 'string', format: 'date', description: 'Update the spent date' }, notes: { type: 'string', description: 'Update the notes' }, total_cost: { type: 'number', minimum: 0, description: 'Update the total cost' }, units: { type: 'number', minimum: 0, description: 'Update the units' }, billable: { type: 'boolean', description: 'Update the billable status' }, }, required: ['id'], additionalProperties: false, }, }, handler: new UpdateExpenseHandler(config), },