Skip to main content
Glama
cristip73

MCP Server for Asana

by cristip73

asana_get_tasks_for_project

Retrieve all tasks from a specific Asana project with pagination support, filtering options, and customizable result fields.

Instructions

Get all tasks from a specific project with pagination support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe project ID to get tasks for
completedNoFilter for completed or incomplete tasks
limitNoMaximum number of results to return (1-100)
offsetNoPagination token from previous response
auto_paginateNoAutomatically fetch all pages of results (up to max_pages)
max_pagesNoMaximum number of pages to fetch when auto_paginate is true
opt_fieldsNoComma-separated list of optional fields to include

Implementation Reference

  • MCP tool handler switch case that extracts project_id and opts from arguments, calls asanaClient.getTasksForProject, and returns the JSON stringified response.
    case "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) }],
      };
    }
  • Tool schema definition including name, description, and detailed inputSchema with properties like project_id, completed, limit, offset, auto_paginate, opt_fields.
    export 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"]
      }
    };
  • Import of getTasksForProjectTool from task-tools.js and its inclusion in the exported tools array for MCP tool registration.
      searchTasksTool,
      getTaskTool,
      createTaskTool,
      updateTaskTool,
      createSubtaskTool,
      getMultipleTasksByGidTool,
      addTaskToSectionTool,
      getTasksForSectionTool,
      getProjectHierarchyTool,
      getSubtasksForTaskTool,
      getTasksForProjectTool
    } from './tools/task-tools.js';
    import { getTasksForTagTool, getTagsForWorkspaceTool, addTagsToTaskTool } from './tools/tag-tools.js';
    import {
      addTaskDependenciesTool,
      addTaskDependentsTool,
      setParentForTaskTool,
      addFollowersToTaskTool
    } from './tools/task-relationship-tools.js';
    import {
      getStoriesForTaskTool,
      createTaskStoryTool
    } from './tools/story-tools.js';
    import {
      getTeamsForUserTool,
      getTeamsForWorkspaceTool,
      getUsersForWorkspaceTool
    } from './tools/user-tools.js';
    import {
      getAttachmentsForObjectTool,
      uploadAttachmentForObjectTool,
      downloadAttachmentTool
    } from './tools/attachment-tools.js';
    
    export 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,
  • Core implementation in AsanaClientWrapper that handles input options, builds params, performs paginated API calls to Asana's getTasksForProject endpoint, and manages errors.
    async 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;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'pagination support' which is helpful, but doesn't describe authentication requirements, rate limits, error conditions, or what the response format looks like (especially important since there's no output schema). For a read operation with 7 parameters, this leaves significant behavioral gaps.

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

Conciseness4/5

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

The description is a single, efficient sentence that front-loads the core purpose. Every word earns its place - 'Get all tasks' (action), 'from a specific project' (scope), 'with pagination support' (key capability). However, it could be slightly more structured by separating core functionality from behavioral notes.

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

Completeness2/5

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

Given the tool's complexity (7 parameters, no output schema, no annotations), the description is insufficiently complete. It doesn't explain what the tool returns (task objects? just IDs?), doesn't mention authentication or permissions needed, and doesn't provide error handling context. For a data retrieval tool with multiple filtering and pagination options, users need more guidance about expected behavior and results.

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?

Schema description coverage is 100%, so the schema already documents all 7 parameters thoroughly. The description adds minimal value beyond the schema - it mentions 'pagination support' which relates to 'offset' and 'auto_paginate' parameters, but doesn't provide additional context about parameter interactions or usage patterns. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the verb 'Get' and resource 'all tasks from a specific project', making the purpose unambiguous. It distinguishes from sibling tools like 'asana_get_task' (single task) and 'asana_search_tasks' (search across projects), though it doesn't explicitly name these alternatives. The mention of 'pagination support' adds useful scope information.

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?

The description implies usage context by specifying 'from a specific project', suggesting this tool is for project-scoped task retrieval rather than workspace-wide searches. However, it doesn't provide explicit guidance on when to use this versus alternatives like 'asana_get_tasks_for_section', 'asana_get_tasks_for_tag', or 'asana_search_tasks', nor does it mention prerequisites or exclusions.

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/cristip73/mcp-server-asana'

If you have feedback or need assistance with the MCP directory API, please join our Discord server