assign_role_to_team
Assign security roles to teams to provide consistent access permissions for groups of users working on similar tasks in Microsoft Dataverse.
Instructions
Assigns a security role to a team, granting all team members the permissions defined in that role. Use this to provide consistent access levels to groups of users working together on similar tasks.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| roleId | Yes | ID of the role to assign | |
| teamId | Yes | ID of the team to assign the role to |
Implementation Reference
- src/tools/role-tools.ts:579-617 (registration)The exported assignRoleToTeamTool function defines and registers the MCP tool 'assign_role_to_team' with Zod input schema and async handler that performs the role assignment via Dataverse Web API.export function assignRoleToTeamTool(server: McpServer, client: DataverseClient) { server.registerTool( "assign_role_to_team", { title: "Assign Role to Team", description: "Assigns a security role to a team, granting all team members the permissions defined in that role. Use this to provide consistent access levels to groups of users working together on similar tasks.", inputSchema: { roleId: z.string().describe("ID of the role to assign"), teamId: z.string().describe("ID of the team to assign the role to") } }, async (params) => { try { await client.post(`teams(${params.teamId})/teamroles_association/$ref`, { "@odata.id": `${client['config'].dataverseUrl}/api/data/v9.2/roles(${params.roleId})` }); return { content: [ { type: "text", text: `Successfully assigned role to team.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error assigning role to team: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } ); }
- src/index.ts:195-195 (registration)Invocation of assignRoleToTeamTool to register the tool on the main MCP server instance.assignRoleToTeamTool(server, dataverseClient);
- src/tools/role-tools.ts:582-589 (schema)Tool metadata including title, description, and Zod input schema for validation.{ title: "Assign Role to Team", description: "Assigns a security role to a team, granting all team members the permissions defined in that role. Use this to provide consistent access levels to groups of users working together on similar tasks.", inputSchema: { roleId: z.string().describe("ID of the role to assign"), teamId: z.string().describe("ID of the team to assign the role to") } },
- src/tools/role-tools.ts:590-616 (handler)The core handler logic that posts to the Dataverse Web API endpoint to associate the role with the team.async (params) => { try { await client.post(`teams(${params.teamId})/teamroles_association/$ref`, { "@odata.id": `${client['config'].dataverseUrl}/api/data/v9.2/roles(${params.roleId})` }); return { content: [ { type: "text", text: `Successfully assigned role to team.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error assigning role to team: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } );