search_expense_reports
Search for expense reports using filters like submitter, status, or page size to quickly find and review financial documentation in Autotask.
Instructions
Search for expense reports with optional filters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pageSize | No | Number of results to return (default: 25, max: 100) | |
| status | No | Filter by status (1=New, 2=Submitted, 3=Approved, 4=Paid, 5=Rejected, 6=InReview) | |
| submitterId | No | Filter by submitter resource ID |
Implementation Reference
- src/handlers/tool.handler.ts:745-768 (registration)Tool registration including name, description, and input schema definition for 'search_expense_reports'{ name: 'search_expense_reports', description: 'Search for expense reports with optional filters', inputSchema: { type: 'object', properties: { submitterId: { type: 'number', description: 'Filter by submitter resource ID' }, status: { type: 'number', description: 'Filter by status (1=New, 2=Submitted, 3=Approved, 4=Paid, 5=Rejected, 6=InReview)' }, pageSize: { type: 'number', description: 'Number of results to return (default: 25, max: 100)', minimum: 1, maximum: 100 } }, required: [] } },
- Core handler implementation: builds filters for submitterId (mapped to resourceId) and status, calls Autotask API expenses.list, returns typed expense reportsasync searchExpenseReports(options: AutotaskQueryOptionsExtended = {}): Promise<AutotaskExpenseReport[]> { const client = await this.ensureClient(); try { this.logger.debug('Searching expense reports with options:', options); // Build filter based on provided options const filters = []; if (options.submitterId) { filters.push({ field: 'resourceId', op: 'eq', value: options.submitterId }); } if (options.status) { filters.push({ field: 'status', op: 'eq', value: options.status }); } const queryOptions = { filter: filters.length > 0 ? filters : [{ field: 'id', op: 'gte', value: 0 }], pageSize: options.pageSize || 25 }; const result = await client.expenses.list(queryOptions); const reports = (result.data as any[]) || []; this.logger.info(`Retrieved ${reports.length} expense reports`); return reports as AutotaskExpenseReport[]; } catch (error) { this.logger.error('Failed to search expense reports:', error); throw error; } }
- src/handlers/tool.handler.ts:1251-1258 (handler)MCP tool handler dispatch: maps tool args to service method and formats response (duplicate case exists at lines 1407-1414)case 'search_expense_reports': result = await this.autotaskService.searchExpenseReports({ submitterId: args.submitterId, status: args.status, pageSize: args.pageSize }); message = `Found ${result.length} expense reports`; break;