Skip to main content
Glama
cristip73

MCP Server for Asana

by cristip73

asana_get_project_task_counts

Retrieve task counts for Asana projects to monitor progress and manage workloads. Provide a project ID to get the number of tasks.

Instructions

Get the number of tasks in a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe project ID to get task counts for
opt_fieldsNoComma-separated list of optional fields to include

Implementation Reference

  • Tool schema definition including name, description, and input schema for asana_get_project_task_counts
    export const getProjectTaskCountsTool: Tool = {
      name: "asana_get_project_task_counts",
      description: "Get the number of tasks in a project",
      inputSchema: {
        type: "object",
        properties: {
          project_id: {
            type: "string",
            description: "The project ID to get task counts for"
          },
          opt_fields: {
            type: "string",
            description: "Comma-separated list of optional fields to include"
          }
        },
        required: ["project_id"]
      }
    };
  • Registration of all tools including getProjectTaskCountsTool in the tools array used by the MCP server
    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,
      getTasksForTagTool,
      getTagsForWorkspaceTool,
      addTagsToTaskTool,
      addTaskDependenciesTool,
      addTaskDependentsTool,
      setParentForTaskTool,
      addFollowersToTaskTool,
      getStoriesForTaskTool,
      createTaskStoryTool,
      getTeamsForUserTool,
      getTeamsForWorkspaceTool,
      addMembersForProjectTool,
      addFollowersForProjectTool,
      getUsersForWorkspaceTool,
      getAttachmentsForObjectTool,
      uploadAttachmentForObjectTool,
      downloadAttachmentTool
    ];
  • Dispatch handler case in tool_handler switch that extracts parameters and calls AsanaClientWrapper.getProjectTaskCounts
    case "asana_get_project_task_counts": {
      const { project_id, ...opts } = args;
      const response = await asanaClient.getProjectTaskCounts(project_id, opts);
      return {
        content: [{ type: "text", text: JSON.stringify(response) }],
      };
    }
  • Core implementation of getProjectTaskCounts in AsanaClientWrapper, calling Asana SDK's getTaskCountsForProject with appropriate opt_fields
    async getProjectTaskCounts(projectId: string, opts: any = {}) {
      // Ensure we always include essential opt_fields for task counts
      // See: https://developers.asana.com/reference/gettaskcountsforproject
      const options = {
        opt_fields: 'num_tasks,num_incomplete_tasks,num_completed_tasks,num_milestones,num_incomplete_milestones,num_completed_milestones'
      };
      
      // If caller provided specific opt_fields, use those instead
      if (opts.opt_fields) {
        options.opt_fields = opts.opt_fields;
      }
      
      const response = await this.projects.getTaskCountsForProject(projectId, options);
      return response.data;
    }
  • Validation logic for project_id parameter in validateProjectParameters function
    case 'asana_get_project_task_counts':
    case 'asana_get_project_sections':
      result = validateGid(params.project_id, 'project_id');
      if (!result.valid) errors.push(...result.errors);
      break;

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