Skip to main content
Glama

get-user-permissions

Retrieve detailed Azure user permissions by combining role assignments and definitions to manage access control and security policies.

Instructions

Get detailed user permissions by combining role assignments and role definitions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeNoScope to check permissions for. Leave empty for subscription level.

Implementation Reference

  • Main handler function for 'get-user-permissions' tool. Parses input scope, fetches role assignments and definitions using helpers, matches them to compute user permissions, and returns structured results including summary.
    private async handleGetUserPermissions(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 permissionScope =
          scope || `/subscriptions/${this.context.selectedSubscription}`;
    
        // Get both role assignments and role definitions
        const [roleAssignments, roleDefinitions] = await Promise.all([
          this.getRoleAssignments(permissionScope),
          this.getRoleDefinitions(permissionScope),
        ]);
    
        // Match assignments with definitions
        const userPermissions = roleAssignments.map((assignment) => {
          const roleDefinition = roleDefinitions.find((def) =>
            assignment.roleDefinitionId?.endsWith(def.name || "")
          );
    
          return {
            principalId: assignment.principalId,
            principalType: assignment.principalType,
            scope: assignment.scope,
            roleDefinition: {
              id: roleDefinition?.id,
              name: roleDefinition?.roleName,
              description: roleDefinition?.description,
              permissions: roleDefinition?.permissions || [],
            },
            createdOn: assignment.createdOn,
          };
        });
    
        // Group by role for summary
        const roleSummary = userPermissions.reduce((acc, perm) => {
          const roleName = perm.roleDefinition.name || "Unknown";
          acc[roleName] = (acc[roleName] || 0) + 1;
          return acc;
        }, {} as Record<string, number>);
    
        return {
          userPermissions,
          roleSummary,
          totalAssignments: roleAssignments.length,
          scope: permissionScope,
        };
      } catch (error) {
        this.logWithContext("error", `Error getting user permissions: ${error}`, {
          error,
        });
        throw new AzureResourceError(`Failed to get user permissions: ${error}`);
      }
    }
  • Tool registration in listTools response, including name, description, and input schema definition.
    {
      name: "get-user-permissions",
      description:
        "Get detailed user permissions by combining role assignments and role definitions",
      inputSchema: {
        type: "object",
        properties: {
          scope: {
            type: "string",
            description:
              "Scope to check permissions for. Leave empty for subscription level.",
          },
        },
        required: [],
      },
    },
  • Dispatch case in handleCallTool switch statement that routes to the handler.
    case "get-user-permissions":
      result = await this.handleGetUserPermissions(args);
      break;
  • Helper function to fetch role assignments for a given scope.
    private async getRoleAssignments(scope: string) {
      const assignments = [];
      for await (const assignment of this.context.authorizationClient!.roleAssignments.listForScope(
        scope
      )) {
        assignments.push(assignment);
      }
      return assignments;
    }
  • Helper function to fetch role definitions for a given scope.
    private async getRoleDefinitions(scope: string) {
      const definitions = [];
      for await (const definition of this.context.authorizationClient!.roleDefinitions.list(
        scope
      )) {
        definitions.push(definition);
      }
      return definitions;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It describes the data sources (role assignments and definitions) but lacks behavioral details such as required permissions, rate limits, error handling, or output format. For a tool that likely involves sensitive permissions data, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that conveys the core purpose without unnecessary words. It is front-loaded with the main action. However, it could be slightly more structured by explicitly mentioning the output or usage context to improve clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of permissions data and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., a list of permissions, aggregated view), how permissions are combined, or any behavioral traits. For a tool with no structured output documentation, this leaves significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter 'scope' with its description. The description adds no additional meaning about parameters beyond what the schema provides, such as examples of scope values or how scope affects the permission calculation. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('detailed user permissions'), and explains the mechanism ('by combining role assignments and role definitions'). It distinguishes from siblings like 'get-role-definitions' or 'list-role-assignments' by focusing on the combined result. However, it doesn't explicitly differentiate from all siblings (e.g., 'get-resource-details' might overlap in some contexts).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list-role-assignments' or 'get-role-definitions'. It mentions the combination of data sources but doesn't specify scenarios where this combined view is preferable over fetching the components separately. No exclusions or prerequisites are stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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