Skip to main content
Glama

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
NameRequiredDescriptionDefault
expense_idYesThe ID of the expense to retrieve

Implementation Reference

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

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