get_expense
Retrieve detailed expense information including receipts and billing data by providing the expense ID.
Instructions
Retrieve a specific expense by ID with complete details including receipts and billing information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expense_id | Yes | The ID of the expense to retrieve |
Implementation Reference
- src/tools/expenses.ts:39-57 (handler)The GetExpenseHandler class contains the execution logic for the get_expense MCP tool. It validates the input and calls the harvestClient to fetch the expense.
class GetExpenseHandler implements ToolHandler { constructor(private readonly config: BaseToolConfig) {} async execute(args: Record<string, any>): Promise<CallToolResult> { try { const inputSchema = z.object({ expense_id: z.number().int().positive() }); const { expense_id } = validateInput(inputSchema, args, 'get expense'); logger.info('Fetching expense from Harvest API', { expenseId: expense_id }); const expense = await this.config.harvestClient.getExpense(expense_id); return { content: [{ type: 'text', text: JSON.stringify(expense, null, 2) }], }; } catch (error) { return handleMCPToolError(error, 'get_expense'); } } } - src/tools/expenses.ts:158-172 (registration)Registration of the get_expense tool in the registerExpenseTools function within src/tools/expenses.ts.
{ tool: { name: 'get_expense', description: 'Retrieve a specific expense by ID with complete details including receipts and billing information.', inputSchema: { type: 'object', properties: { expense_id: { type: 'number', description: 'The ID of the expense to retrieve' }, }, required: ['expense_id'], additionalProperties: false, }, }, handler: new GetExpenseHandler(config), },