search_tasks
Find and filter tasks in Autotask using search terms, project IDs, status codes, or assigned resources to manage project workflows and track task progress.
Instructions
Search for tasks in Autotask with optional filters. Returns optimized task data to prevent large responses.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assignedResourceID | No | Filter by assigned resource ID | |
| pageSize | No | Number of results to return (default: 25, max: 100) | |
| projectID | No | Filter by project ID | |
| searchTerm | No | Search term for task title | |
| status | No | Filter by task status (1=New, 2=In Progress, 5=Complete) |
Implementation Reference
- Core handler implementation: Queries Autotask tasks via client.tasks.list with essential fields only, pagination limits, and data optimization via optimizeTaskData.async searchTasks(options: AutotaskQueryOptions = {}): Promise<AutotaskTask[]> { const client = await this.ensureClient(); try { this.logger.debug('Searching tasks with options:', options); // Define essential task fields to minimize response size const essentialFields = [ 'id', 'title', 'description', 'status', 'projectID', 'assignedResourceID', 'creatorResourceID', 'createDateTime', 'startDateTime', 'endDateTime', 'estimatedHours', 'hoursToBeScheduled', 'remainingHours', 'percentComplete', 'priorityLabel', 'taskType', 'lastActivityDateTime', 'completedDateTime' ]; // Set default pagination and field limits const optimizedOptions = { ...options, includeFields: essentialFields, pageSize: options.pageSize || 25, ...(options.pageSize && options.pageSize > 100 && { pageSize: 100 }) }; const result = await client.tasks.list(optimizedOptions as any); const tasks = (result.data as unknown as AutotaskTask[]) || []; // Transform tasks to optimize data size const optimizedTasks = tasks.map(task => this.optimizeTaskData(task)); this.logger.info(`Retrieved ${optimizedTasks.length} tasks (optimized for size)`); return optimizedTasks; } catch (error) { this.logger.error('Failed to search tasks:', error); throw error; } }
- Input schema definition for the search_tasks tool, defining parameters like searchTerm, projectID, status, assignedResourceID, and pageSize.{ name: 'search_tasks', description: 'Search for tasks in Autotask with optional filters. Returns optimized task data to prevent large responses.', inputSchema: { type: 'object', properties: { searchTerm: { type: 'string', description: 'Search term for task title' }, projectID: { type: 'number', description: 'Filter by project ID' }, status: { type: 'number', description: 'Filter by task status (1=New, 2=In Progress, 5=Complete)' }, assignedResourceID: { type: 'number', description: 'Filter by assigned resource ID' }, pageSize: { type: 'number', description: 'Number of results to return (default: 25, max: 100)', minimum: 1, maximum: 100 } }, required: [] } },
- src/handlers/tool.handler.ts:1163-1166 (handler)Tool dispatch handler in AutotaskToolHandler.callTool that invokes the service method and formats the MCP response.case 'search_tasks': result = await this.autotaskService.searchTasks(args); message = `Found ${result.length} tasks`; break;
- Helper function to optimize task data by truncating long descriptions and removing unnecessary fields to reduce response size.private optimizeTaskData(task: AutotaskTask): AutotaskTask { const maxDescriptionLength = 400; const optimizedDescription = task.description ? (task.description.length > maxDescriptionLength ? task.description.substring(0, maxDescriptionLength) + '... [truncated]' : task.description) : ''; return { ...task, description: optimizedDescription, // Remove potentially large arrays userDefinedFields: [] }; }
- src/mcp/server.ts:56-56 (registration)Instantiation of the tool handler (EnhancedAutotaskToolHandler extending AutotaskToolHandler) in MCP server, which registers all tools including search_tasks via listTools.this.toolHandler = new EnhancedAutotaskToolHandler(this.autotaskService, logger);