Skip to main content
Glama

list-role-assignments

View Azure role assignments at subscription, resource group, or resource level to manage access control and permissions.

Instructions

List role assignments for the subscription or resource group

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeNoScope for role assignments (subscription, resource group, or resource ID). Leave empty for subscription level.

Implementation Reference

  • Tool registration including name, description, and input schema definition in handleListTools() method.
    { name: "list-role-assignments", description: "List role assignments for the subscription or resource group", inputSchema: { type: "object", properties: { scope: { type: "string", description: "Scope for role assignments (subscription, resource group, or resource ID). Leave empty for subscription level.", }, }, required: [], }, },
  • Main handler function that parses input, lists role assignments using Azure AuthorizationManagementClient.roleAssignments.listForScope, and returns formatted results.
    private async handleListRoleAssignments(args: any) { const { scope } = z .object({ scope: z.string().optional(), }) .parse(args); if (!this.context.authorizationClient) { throw new AzureMCPError( "Authorization client not initialized", "NO_CLIENT" ); } try { const roleAssignments = []; const assignmentScope = scope || `/subscriptions/${this.context.selectedSubscription}`; for await (const assignment of this.context.authorizationClient.roleAssignments.listForScope( assignmentScope )) { roleAssignments.push({ id: assignment.id, principalId: assignment.principalId, principalType: assignment.principalType, roleDefinitionId: assignment.roleDefinitionId, scope: assignment.scope, createdOn: assignment.createdOn, createdBy: assignment.createdBy, }); } return { roleAssignments, total: roleAssignments.length }; } catch (error) { this.logWithContext("error", `Error listing role assignments: ${error}`, { error, }); throw new AzureResourceError(`Failed to list role assignments: ${error}`); } }
  • Dispatch case in handleCallTool switch statement that routes to the handler.
    case "list-role-assignments": result = await this.handleListRoleAssignments(args); break;
  • Input schema validation using Zod in the handler function.
    const { scope } = z .object({ scope: z.string().optional(), }) .parse(args);

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/kalivaraprasad-gonapa/azure-mcp'

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