Skip to main content
Glama

get_expense

Retrieve an expense by ID to access full details, receipts, and billing information.

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 that implements the 'get_expense' tool logic. It validates input (expects expense_id), fetches the expense from the Harvest API, and returns the result.
    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 with its name, description, input schema (expense_id required), and handler binding (new GetExpenseHandler(config)).
    {
      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),
    },
  • Inline input schema for get_expense using zod: expects expense_id as a positive integer.
    const inputSchema = z.object({ expense_id: z.number().int().positive() });
  • The ExpensesClient.getExpense() API client method that makes the actual HTTP GET request to /expenses/{expenseId}.
    async getExpense(expenseId: number): Promise<any> {
      try {
        this.logger.debug('Fetching expense', { expenseId });
        const response: AxiosResponse = await this.client.get(`/expenses/${expenseId}`);
        
        this.logger.info('Successfully retrieved expense', {
          expenseId: response.data.id,
          totalCost: response.data.total_cost,
          spentDate: response.data.spent_date
        });
        
        return response.data;
      } catch (error) {
        this.logger.error('Failed to retrieve expense', { expenseId, error: (error as Error).message });
        throw error;
      }
    }
  • src/server.ts:139-139 (registration)
    The 'get_expense' tool name is listed under the 'expenses' category mapping in the server, enabling tool filtering by category.
    'expenses': ['list_expenses', 'get_expense', 'create_expense', 'update_expense', 'delete_expense', 'list_expense_categories'],
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries the burden. It mentions returning 'complete details including receipts and billing information', implying a read-only operation. However, it does not explicitly state side effects or safety profile, which is acceptable for a simple get.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, well-formed sentence that conveys all necessary information without filler. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite no output schema or annotations, the description is adequate for a simple retrieval tool. It tells the agent what it does and what data it returns. Minor gaps like return format are acceptable given the tool's simplicity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The single parameter expense_id is fully described in the schema ('The ID of the expense to retrieve'). The description adds no further semantics, so baseline 3 is appropriate given 100% coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Retrieve', the resource 'expense by ID', and the scope 'with complete details including receipts and billing information'. This distinguishes it from sibling tools like list_expenses.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit when-to-use or alternatives are provided. The usage is implicitly clear (when you need a single expense by ID), but explicit guidance versus list_expenses would improve it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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