Skip to main content
Glama

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
NameRequiredDescriptionDefault
idYesThe ID of the expense to update (required)
user_idNoUpdate the user ID
project_idNoUpdate the project ID
expense_category_idNoUpdate the expense category ID
spent_dateNoUpdate the spent date
notesNoUpdate the notes
total_costNoUpdate the total cost
unitsNoUpdate the units
billableNoUpdate the billable status

Implementation Reference

  • 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');
        }
      }
    }
  • 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),
    },

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/ianaleck/harvest-mcp-server'

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