Skip to main content
Glama

list_expenses

Retrieve and filter expense data by user, client, project, billing status, and date ranges to track spending and generate reports.

Instructions

Retrieve expenses with filtering by user, client, project, billing status, and date ranges. Returns paginated results with expense details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNoFilter by user ID
client_idNoFilter by client ID
project_idNoFilter by project ID
is_billedNoFilter by billing status
is_closedNoFilter by closed status
fromNoStart date for date range filter (YYYY-MM-DD)
toNoEnd date for date range filter (YYYY-MM-DD)
updated_sinceNoFilter by expenses updated since this timestamp
pageNoPage number for pagination
per_pageNoNumber of expenses per page (max 2000)

Implementation Reference

  • The handler class that executes the logic for 'list_expenses' by invoking the Harvest API client.
    class ListExpensesHandler implements ToolHandler {
      constructor(private readonly config: BaseToolConfig) {}
    
      async execute(args: Record<string, any>): Promise<CallToolResult> {
        try {
          const validatedArgs = validateInput(ExpenseQuerySchema, args, 'expense query');
          logger.info('Listing expenses from Harvest API');
          const expenses = await this.config.harvestClient.getExpenses(validatedArgs);
          
          return {
            content: [{ type: 'text', text: JSON.stringify(expenses, null, 2) }],
          };
        } catch (error) {
          return handleMCPToolError(error, 'list_expenses');
        }
      }
    }
  • Registration of the 'list_expenses' tool, including its schema and handler association.
    {
      tool: {
        name: 'list_expenses',
        description: 'Retrieve expenses with filtering by user, client, project, billing status, and date ranges. Returns paginated results with expense details.',
        inputSchema: {
          type: 'object',
          properties: {
            user_id: { type: 'number', description: 'Filter by user ID' },
            client_id: { type: 'number', description: 'Filter by client ID' },
            project_id: { type: 'number', description: 'Filter by project ID' },
            is_billed: { type: 'boolean', description: 'Filter by billing status' },
            is_closed: { type: 'boolean', description: 'Filter by closed status' },
            from: { type: 'string', format: 'date', description: 'Start date for date range filter (YYYY-MM-DD)' },
            to: { type: 'string', format: 'date', description: 'End date for date range filter (YYYY-MM-DD)' },
            updated_since: { type: 'string', format: 'date-time', description: 'Filter by expenses updated since this timestamp' },
            page: { type: 'number', minimum: 1, description: 'Page number for pagination' },
            per_page: { type: 'number', minimum: 1, maximum: 2000, description: 'Number of expenses per page (max 2000)' },
          },
          additionalProperties: false,
        },
      },
      handler: new ListExpensesHandler(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