asana_get_tasks_for_project
Retrieve all tasks from a specific Asana project with pagination support, filtering options for completed/incomplete tasks, and customizable result limits.
Instructions
Get all tasks from a specific project with pagination support
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | The project ID to get tasks for | |
| completed | No | Filter for completed or incomplete tasks | |
| limit | No | Maximum number of results to return (1-100) | |
| offset | No | Pagination token from previous response | |
| auto_paginate | No | Automatically fetch all pages of results (up to max_pages) | |
| max_pages | No | Maximum number of pages to fetch when auto_paginate is true | |
| opt_fields | No | Comma-separated list of optional fields to include |
Input Schema (JSON Schema)
{
"properties": {
"auto_paginate": {
"default": false,
"description": "Automatically fetch all pages of results (up to max_pages)",
"type": "boolean"
},
"completed": {
"description": "Filter for completed or incomplete tasks",
"type": "boolean"
},
"limit": {
"description": "Maximum number of results to return (1-100)",
"maximum": 100,
"minimum": 1,
"type": "number"
},
"max_pages": {
"default": 10,
"description": "Maximum number of pages to fetch when auto_paginate is true",
"type": "number"
},
"offset": {
"description": "Pagination token from previous response",
"type": "string"
},
"opt_fields": {
"description": "Comma-separated list of optional fields to include",
"type": "string"
},
"project_id": {
"description": "The project ID to get tasks for",
"type": "string"
}
},
"required": [
"project_id"
],
"type": "object"
}
Implementation Reference
- src/tool-handler.ts:486-492 (handler)MCP tool handler switch case that destructures input arguments and delegates execution to AsanaClientWrapper.getTasksForProjectcase "asana_get_tasks_for_project": { const { project_id, ...opts } = args; const response = await asanaClient.getTasksForProject(project_id, opts); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
- src/tools/task-tools.ts:609-650 (schema)Tool object defining the name, description, and input schema for validation and introspectionexport const getTasksForProjectTool: Tool = { name: "asana_get_tasks_for_project", description: "Get all tasks from a specific project with pagination support", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "The project ID to get tasks for" }, completed: { type: "boolean", description: "Filter for completed or incomplete tasks" }, limit: { type: "number", description: "Maximum number of results to return (1-100)", minimum: 1, maximum: 100 }, offset: { type: "string", description: "Pagination token from previous response" }, auto_paginate: { type: "boolean", description: "Automatically fetch all pages of results (up to max_pages)", default: false }, max_pages: { type: "number", description: "Maximum number of pages to fetch when auto_paginate is true", default: 10 }, opt_fields: { type: "string", description: "Comma-separated list of optional fields to include" } }, required: ["project_id"] } };
- src/tool-handler.ts:61-103 (registration)Registration of all tools including getTasksForProjectTool in the exported tools array used by MCPexport const tools: Tool[] = [ listWorkspacesTool, searchProjectsTool, getProjectTool, getProjectTaskCountsTool, getProjectSectionsTool, createSectionForProjectTool, createProjectForWorkspaceTool, updateProjectTool, reorderSectionsTool, getProjectStatusTool, getProjectStatusesForProjectTool, createProjectStatusTool, deleteProjectStatusTool, searchTasksTool, getTaskTool, createTaskTool, updateTaskTool, createSubtaskTool, getMultipleTasksByGidTool, addTaskToSectionTool, getTasksForSectionTool, getProjectHierarchyTool, getSubtasksForTaskTool, getTasksForProjectTool, getTasksForTagTool, getTagsForWorkspaceTool, addTagsToTaskTool, addTaskDependenciesTool, addTaskDependentsTool, setParentForTaskTool, addFollowersToTaskTool, getStoriesForTaskTool, createTaskStoryTool, getTeamsForUserTool, getTeamsForWorkspaceTool, addMembersForProjectTool, addFollowersForProjectTool, getUsersForWorkspaceTool, getAttachmentsForObjectTool, uploadAttachmentForObjectTool, downloadAttachmentTool ];
- Core helper method in AsanaClientWrapper that implements the task retrieval logic with pagination support using Asana APIasync getTasksForProject(projectId: string, opts: any = {}) { try { // Extract pagination parameters const { auto_paginate = false, max_pages = 10, limit, offset, opt_fields, completed, ...otherOpts } = opts; // Build search parameters const searchParams: any = { ...otherOpts }; // Add specific filters if (completed !== undefined) searchParams.completed = completed; if (opt_fields) searchParams.opt_fields = opt_fields; // Add pagination parameters if (limit !== undefined) { // Ensure limit is between 1 and 100 searchParams.limit = Math.min(Math.max(1, Number(limit)), 100); } if (offset) searchParams.offset = offset; // Use the paginated results handler for more reliable pagination return await this.handlePaginatedResults( // Initial fetch function () => this.tasks.getTasksForProject(projectId, searchParams), // Next page fetch function (nextOffset) => this.tasks.getTasksForProject(projectId, { ...searchParams, offset: nextOffset }), // Pagination options { auto_paginate, max_pages } ); } catch (error: any) { console.error(`Error getting tasks for project ${projectId}: ${error.message}`); // Add detailed error handling for common issues if (error.message?.includes('Not Found')) { throw new Error(`Project with ID ${projectId} not found or inaccessible.`); } if (error.message?.includes('Bad Request')) { if (opts.limit && (opts.limit < 1 || opts.limit > 100)) { throw new Error(`Invalid limit parameter: ${opts.limit}. Limit must be between 1 and 100.`); } throw new Error(`Error retrieving tasks for project: ${error.message}. Check that all parameters are valid.`); } throw error; } }