search_resources
Find users in Autotask by name, email, or status. Filter results by active status and resource type (employee, contractor, temporary) to locate specific team members.
Instructions
Search for resources (users) in Autotask with optional filters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| searchTerm | No | Search term for resource name or email | |
| isActive | No | Filter by active status | |
| resourceType | No | Filter by resource type (1=Employee, 2=Contractor, 3=Temporary) | |
| pageSize | No | Number of results to return (default: 25, max: 500) |
Implementation Reference
- src/handlers/tool.handler.ts:450-477 (schema)Defines the tool metadata, description, and input schema (JSON Schema) for 'search_resources' tool returned by listTools() method.{ name: 'search_resources', description: 'Search for resources (users) in Autotask with optional filters', inputSchema: { type: 'object', properties: { searchTerm: { type: 'string', description: 'Search term for resource name or email' }, isActive: { type: 'boolean', description: 'Filter by active status' }, resourceType: { type: 'number', description: 'Filter by resource type (1=Employee, 2=Contractor, 3=Temporary)' }, pageSize: { type: 'number', description: 'Number of results to return (default: 25, max: 500)', minimum: 1, maximum: 500 } }, required: [] } },
- src/handlers/tool.handler.ts:1138-1142 (handler)Dispatch handler in callTool() switch statement that executes the search_resources tool by calling AutotaskService.searchResources(args).// Resource tools case 'search_resources': result = await this.autotaskService.searchResources(args); message = `Found ${result.length} resources`; break;
- src/services/autotask.service.ts:804-873 (handler)Core implementation of searchResources in AutotaskService: handles optional pagination (full results by default or limited by pageSize), queries Autotask resources via autotask-node client.resources.list, includes logging and error handling.async searchResources(options: AutotaskQueryOptions = {}): Promise<AutotaskResource[]> { const client = await this.ensureClient(); try { this.logger.debug('Searching resources with options:', options); // PAGINATION BY DEFAULT for data accuracy // Only limit results when user explicitly provides pageSize if (options.pageSize !== undefined && options.pageSize > 0) { // User wants limited results const queryOptions = { ...options, pageSize: Math.min(options.pageSize, 500) // Respect user limit, max 500 per request }; this.logger.debug('Single page request with user-specified limit:', queryOptions); const result = await client.resources.list(queryOptions as any); const resources = (result.data as AutotaskResource[]) || []; this.logger.info(`Retrieved ${resources.length} resources (limited by user to ${options.pageSize})`); return resources; } else { // DEFAULT: Get ALL matching resources via pagination for complete accuracy const allResources: AutotaskResource[] = []; const pageSize = 500; // Use max safe page size for efficiency let currentPage = 1; let hasMorePages = true; while (hasMorePages) { const queryOptions = { ...options, pageSize: pageSize, page: currentPage }; this.logger.debug(`Fetching resources page ${currentPage}...`); const result = await client.resources.list(queryOptions as any); const resources = (result.data as AutotaskResource[]) || []; if (resources.length === 0) { hasMorePages = false; } else { allResources.push(...resources); // Check if we got a full page - if not, we're done if (resources.length < pageSize) { hasMorePages = false; } else { currentPage++; } } // Safety check to prevent infinite loops if (currentPage > 20) { this.logger.warn('Resource pagination safety limit reached at 20 pages (10,000 resources)'); hasMorePages = false; } } this.logger.info(`Retrieved ${allResources.length} resources across ${currentPage} pages (COMPLETE dataset for accuracy)`); return allResources; } } catch (error) { this.logger.error('Failed to search resources:', error); throw error; } }