Skip to main content
Glama
by cristip73

asana_add_members_for_project

Add team members to an Asana project by providing user IDs and project ID to manage project collaboration and access.

Instructions

Add members to a project

Input Schema

NameRequiredDescriptionDefault
project_idYesThe project ID to add members to
membersYesArray of user GIDs to add as members to the project
opt_fieldsNoComma-separated list of optional fields to include in the response

Input Schema (JSON Schema)

{ "properties": { "members": { "description": "Array of user GIDs to add as members to the project", "items": { "type": "string" }, "type": "array" }, "opt_fields": { "description": "Comma-separated list of optional fields to include in the response", "type": "string" }, "project_id": { "description": "The project ID to add members to", "type": "string" } }, "required": [ "project_id", "members" ], "type": "object" }

Implementation Reference

  • Handler logic that destructures arguments and calls the Asana client method to add members to a project, returning the JSON response.
    case "asana_add_members_for_project": { const { project_id, members, ...opts } = args; const response = await asanaClient.addMembersForProject(project_id, members); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
  • Core implementation in AsanaClientWrapper that calls the Asana API to add members to a project, with fallback direct API call.
    async addMembersForProject(projectId: string, members: any) { try { const membersArray = this.ensureArray(members); const body = { data: { members: membersArray } }; const response = await this.projects.addMembersForProject(body, projectId); return response.data; } catch (error: any) { console.error(`Error adding members to project: ${error}`); // Adăugăm mai multe detalii despre eroare pentru debugging if (error.response && error.response.body) { console.error(`Response error details: ${JSON.stringify(error.response.body, null, 2)}`); } // Dacă metoda standard eșuează, încercăm metoda alternativă cu callApi direct try { const client = Asana.ApiClient.instance; const membersArray = this.ensureArray(members); const response = await client.callApi( `/projects/${projectId}/addMembers`, 'POST', { project_gid: projectId }, {}, {}, {}, { data: { members: membersArray } }, ['token'], ['application/json'], ['application/json'], 'Blob' ); return response.data; } catch (fallbackError) { console.error("Error in fallback method for adding members:", fallbackError); throw fallbackError; } } }
  • Tool schema definition specifying input parameters: project_id (required), members (required array of strings), opt_fields (optional).
    export const addMembersForProjectTool: Tool = { name: "asana_add_members_for_project", description: "Add members to a project", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "The project ID to add members to" }, members: { type: "array", items: { type: "string" }, description: "Array of user GIDs to add as members to the project" }, opt_fields: { type: "string", description: "Comma-separated list of optional fields to include in the response" } }, required: ["project_id", "members"] } };
  • Registration of the tool in the exported 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 ];
  • Runtime parameter validation ensuring project_id is a valid GID and members array is provided.
    case 'asana_add_members_for_project': case 'asana_add_followers_for_project': result = validateGid(params.project_id, 'project_id'); if (!result.valid) errors.push(...result.errors); const arrayParam = toolName === 'asana_add_members_for_project' ? 'members' : 'followers'; if (!params[arrayParam]) { errors.push(`${arrayParam} 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