Skip to main content
Glama
cristip73

MCP Server for Asana

by cristip73

asana_add_followers_to_task

Add team members as followers to an Asana task to keep them updated on progress and changes.

Instructions

Add followers to a task

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYesThe task ID to add followers to
followersYesArray of user IDs to add as followers to the task

Implementation Reference

  • Core implementation that adds followers to a task using Asana API with fallback method.
    async addFollowersToTask(taskId: string, followers: any) {
      // Ensure followers is an array
      const followersArray = this.ensureArray(followers);
      
      try {
        const body = {
          data: {
            followers: followersArray
          }
        };
        const response = await this.tasks.addFollowersForTask(body, taskId);
        return response.data;
      } catch (error) {
        console.error(`Error adding followers to task: ${error}`);
        // Dacă metoda standard eșuează, încercăm metoda alternativă cu callApi direct
        try {
          const client = Asana.ApiClient.instance;
          const response = await client.callApi(
            `/tasks/${taskId}/addFollowers`,
            'POST',
            { task_gid: taskId },
            {},
            {},
            {},
            { data: { followers: followersArray } },
            ['token'],
            ['application/json'],
            ['application/json'],
            'Blob'
          );
          return response.data;
        } catch (fallbackError) {
          console.error("Error in fallback method for adding followers:", fallbackError);
          throw fallbackError;
        }
      }
    }
  • Tool dispatcher switch case that handles the tool execution by calling the Asana client.
    case "asana_add_followers_to_task": {
      const { task_id, followers } = args;
      const response = await asanaClient.addFollowersToTask(task_id, followers);
      return {
        content: [{ type: "text", text: JSON.stringify(response) }],
      };
    }
  • Tool definition with input schema specifying task_id and followers array.
    export const addFollowersToTaskTool: Tool = {
      name: "asana_add_followers_to_task",
      description: "Add followers to a task",
      inputSchema: {
        type: "object",
        properties: {
          task_id: {
            type: "string",
            description: "The task ID to add followers to"
          },
          followers: {
            type: "array",
            items: {
              type: "string"
            },
            description: "Array of user IDs to add as followers to the task"
          }
        },
        required: ["task_id", "followers"]
      }
    };
  • Tool registration in the exported tools array.
    setParentForTaskTool,
    addFollowersToTaskTool,
  • Input parameter validation specific to this tool.
    case 'asana_add_followers_to_task':
      result = validateGid(params.task_id, 'task_id');
      if (!result.valid) errors.push(...result.errors);
      
      if (!params.followers) {
        errors.push('followers is required');
      }
      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