Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

List Dataverse Security Roles

list_dataverse_roles

Retrieve security roles from Dataverse with filtering options to discover available permissions, find custom roles, and understand permission structures across business units.

Instructions

Retrieves a list of security roles in the Dataverse environment with filtering options. Use this to discover available roles, find custom roles, or get an overview of permission structures. Supports filtering by business unit, custom/system roles, and managed/unmanaged status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
businessUnitIdNoFilter roles by business unit ID
customOnlyNoWhether to list only custom (non-system) roles
filterNoOData filter expression
includeManagedNoWhether to include managed roles
topNoMaximum number of roles to return (default: 50)

Implementation Reference

  • Handler implementation that constructs OData query for listing Dataverse security roles based on input parameters (businessUnitId, customOnly, includeManaged, top, filter), fetches from Dataverse API, formats results, and returns as text content.
    async (params) => {
      try {
        let queryParams: Record<string, any> = {
          $select: 'roleid,name,description,appliesto,isautoassigned,isinherited,businessunitid,ismanaged,iscustomizable,canbedeleted',
          $top: params.top || 50
        };
    
        const filters: string[] = [];
    
        if (params.businessUnitId) {
          filters.push(`businessunitid eq ${params.businessUnitId}`);
        }
    
        if (params.customOnly) {
          filters.push(`iscustomizable/Value eq true`);
        }
    
        if (!params.includeManaged) {
          filters.push(`ismanaged eq false`);
        }
    
        if (params.filter) {
          filters.push(params.filter);
        }
    
        if (filters.length > 0) {
          queryParams.$filter = filters.join(' and ');
        }
    
        const response = await client.get('roles', queryParams);
    
        const roles = response.value?.map((role: any) => ({
          roleId: role.roleid,
          name: role.name,
          description: role.description,
          appliesTo: role.appliesto,
          isAutoAssigned: role.isautoassigned === 1,
          isInherited: role.isinherited,
          businessUnitId: role.businessunitid,
          isManaged: role.ismanaged,
          isCustomizable: role.iscustomizable,
          canBeDeleted: role.canbedeleted
        })) || [];
    
        return {
          content: [
            {
              type: "text",
              text: `Found ${roles.length} security roles:\n\n${JSON.stringify(roles, null, 2)}`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error listing security roles: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod input schema defining optional parameters for filtering and limiting the list of Dataverse security roles.
    inputSchema: {
      businessUnitId: z.string().optional().describe("Filter roles by business unit ID"),
      customOnly: z.boolean().default(false).describe("Whether to list only custom (non-system) roles"),
      includeManaged: z.boolean().default(false).describe("Whether to include managed roles"),
      top: z.number().optional().describe("Maximum number of roles to return (default: 50)"),
      filter: z.string().optional().describe("OData filter expression")
    }
  • server.registerTool call that registers the 'list_dataverse_roles' MCP tool with its title, description, input schema, and handler function.
    server.registerTool(
      "list_dataverse_roles",
      {
        title: "List Dataverse Security Roles",
        description: "Retrieves a list of security roles in the Dataverse environment with filtering options. Use this to discover available roles, find custom roles, or get an overview of permission structures. Supports filtering by business unit, custom/system roles, and managed/unmanaged status.",
        inputSchema: {
          businessUnitId: z.string().optional().describe("Filter roles by business unit ID"),
          customOnly: z.boolean().default(false).describe("Whether to list only custom (non-system) roles"),
          includeManaged: z.boolean().default(false).describe("Whether to include managed roles"),
          top: z.number().optional().describe("Maximum number of roles to return (default: 50)"),
          filter: z.string().optional().describe("OData filter expression")
        }
      },
      async (params) => {
        try {
          let queryParams: Record<string, any> = {
            $select: 'roleid,name,description,appliesto,isautoassigned,isinherited,businessunitid,ismanaged,iscustomizable,canbedeleted',
            $top: params.top || 50
          };
    
          const filters: string[] = [];
    
          if (params.businessUnitId) {
            filters.push(`businessunitid eq ${params.businessUnitId}`);
          }
    
          if (params.customOnly) {
            filters.push(`iscustomizable/Value eq true`);
          }
    
          if (!params.includeManaged) {
            filters.push(`ismanaged eq false`);
          }
    
          if (params.filter) {
            filters.push(params.filter);
          }
    
          if (filters.length > 0) {
            queryParams.$filter = filters.join(' and ');
          }
    
          const response = await client.get('roles', queryParams);
    
          const roles = response.value?.map((role: any) => ({
            roleId: role.roleid,
            name: role.name,
            description: role.description,
            appliesTo: role.appliesto,
            isAutoAssigned: role.isautoassigned === 1,
            isInherited: role.isinherited,
            businessUnitId: role.businessunitid,
            isManaged: role.ismanaged,
            isCustomizable: role.iscustomizable,
            canBeDeleted: role.canbedeleted
          })) || [];
    
          return {
            content: [
              {
                type: "text",
                text: `Found ${roles.length} security roles:\n\n${JSON.stringify(roles, null, 2)}`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error listing security roles: ${error instanceof Error ? error.message : 'Unknown error'}`
              }
            ],
            isError: true
          };
        }
      }
    );
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions filtering capabilities and the tool's purpose, but doesn't disclose important behavioral traits like whether this is a read-only operation, potential rate limits, authentication requirements, pagination behavior (beyond the 'top' parameter), or what the response format looks like.

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

Conciseness5/5

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

The description is perfectly concise with two sentences that each earn their place - the first states the core purpose, the second provides usage context and filtering capabilities. No wasted words, well-structured and front-loaded.

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

Completeness3/5

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

For a read operation with 5 parameters and no output schema, the description is adequate but has gaps. It covers the purpose and filtering context well, but without annotations or output schema, it should ideally mention that this is a read-only operation and provide some indication of the response structure to be more complete.

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 all 5 parameters thoroughly. The description adds marginal value by mentioning filtering options generally ('filtering by business unit, custom/system roles, and managed/unmanaged status'), but doesn't provide additional semantic context beyond what's in the parameter descriptions.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verb ('Retrieves') and resource ('list of security roles in the Dataverse environment'), and distinguishes it from siblings like 'get_dataverse_role' (singular) by emphasizing it lists multiple roles with filtering capabilities.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('to discover available roles, find custom roles, or get an overview of permission structures'), but doesn't explicitly state when NOT to use it or mention specific alternatives among the many sibling tools.

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/mwhesse/mcp-dataverse'

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