Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

List Dataverse Business Units

list_dataverse_businessunits

Retrieve and filter business units from your Dataverse environment to understand organizational structure and find specific units by criteria.

Instructions

Retrieves a list of business units in the Dataverse environment with filtering and sorting options. Use this to discover available business units, understand organizational hierarchy, and find specific business units by criteria.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoOData filter expression
orderbyNoOData orderby expression
selectNoOData select expression to specify which fields to return
topNoMaximum number of business units to return (default: 50)

Implementation Reference

  • The handler function that lists Dataverse business units. It constructs an OData query with optional parameters for top, filter, orderby, and select, fetches from the Dataverse API, formats the results, and returns them.
    async (params: any) => {
      try {
        let query = 'businessunits?';
        const queryParams: string[] = [];
    
        // Select fields
        const selectFields = params.select || [
          'businessunitid', 'name', 'description', 'divisionname', 'emailaddress',
          'costcenter', 'isdisabled', 'createdon', 'modifiedon', 'parentbusinessunitid'
        ].join(',');
        queryParams.push(`$select=${selectFields}`);
    
        // Top
        queryParams.push(`$top=${params.top || 50}`);
    
        // Filter
        if (params.filter) {
          queryParams.push(`$filter=${encodeURIComponent(params.filter)}`);
        }
    
        // Order by
        if (params.orderby) {
          queryParams.push(`$orderby=${encodeURIComponent(params.orderby)}`);
        }
    
        // Expand parent business unit
        queryParams.push('$expand=parentbusinessunitid($select=businessunitid,name)');
    
        // Add count
        queryParams.push('$count=true');
    
        query += queryParams.join('&');
        const result = await client.get(query);
    
        const businessUnits = result.value?.map((bu: any) => ({
          businessUnitId: bu.businessunitid,
          name: bu.name,
          description: bu.description,
          divisionName: bu.divisionname,
          emailAddress: bu.emailaddress,
          costCenter: bu.costcenter,
          isDisabled: bu.isdisabled,
          createdOn: bu.createdon,
          modifiedOn: bu.modifiedon,
          parentBusinessUnitId: bu.parentbusinessunitid,
          parentBusinessUnitName: bu.parentbusinessunitid?.name
        })) || [];
    
        return {
          content: [
            {
              type: "text",
              text: `Found ${businessUnits.length} business units (Total: ${result['@odata.count'] || businessUnits.length}):\n\n${JSON.stringify(businessUnits, null, 2)}`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error listing business units: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • Input schema using Zod for validating tool parameters: top (number, optional), filter (string, optional), orderby (string, optional), select (string, optional).
      inputSchema: {
        top: z.number().min(1).max(5000).optional().describe("Maximum number of business units to return (default: 50)"),
        filter: z.string().optional().describe("OData filter expression"),
        orderby: z.string().optional().describe("OData orderby expression"),
        select: z.string().optional().describe("OData select expression to specify which fields to return")
      }
    },
  • Registers the 'list_dataverse_businessunits' tool on the MCP server using server.registerTool, providing title, description, inputSchema, and the handler function.
      server.registerTool(
        "list_dataverse_businessunits",
        {
          title: "List Dataverse Business Units",
          description: "Retrieves a list of business units in the Dataverse environment with filtering and sorting options. Use this to discover available business units, understand organizational hierarchy, and find specific business units by criteria.",
          inputSchema: {
            top: z.number().min(1).max(5000).optional().describe("Maximum number of business units to return (default: 50)"),
            filter: z.string().optional().describe("OData filter expression"),
            orderby: z.string().optional().describe("OData orderby expression"),
            select: z.string().optional().describe("OData select expression to specify which fields to return")
          }
        },
        async (params: any) => {
          try {
            let query = 'businessunits?';
            const queryParams: string[] = [];
    
            // Select fields
            const selectFields = params.select || [
              'businessunitid', 'name', 'description', 'divisionname', 'emailaddress',
              'costcenter', 'isdisabled', 'createdon', 'modifiedon', 'parentbusinessunitid'
            ].join(',');
            queryParams.push(`$select=${selectFields}`);
    
            // Top
            queryParams.push(`$top=${params.top || 50}`);
    
            // Filter
            if (params.filter) {
              queryParams.push(`$filter=${encodeURIComponent(params.filter)}`);
            }
    
            // Order by
            if (params.orderby) {
              queryParams.push(`$orderby=${encodeURIComponent(params.orderby)}`);
            }
    
            // Expand parent business unit
            queryParams.push('$expand=parentbusinessunitid($select=businessunitid,name)');
    
            // Add count
            queryParams.push('$count=true');
    
            query += queryParams.join('&');
            const result = await client.get(query);
    
            const businessUnits = result.value?.map((bu: any) => ({
              businessUnitId: bu.businessunitid,
              name: bu.name,
              description: bu.description,
              divisionName: bu.divisionname,
              emailAddress: bu.emailaddress,
              costCenter: bu.costcenter,
              isDisabled: bu.isdisabled,
              createdOn: bu.createdon,
              modifiedOn: bu.modifiedon,
              parentBusinessUnitId: bu.parentbusinessunitid,
              parentBusinessUnitName: bu.parentbusinessunitid?.name
            })) || [];
    
            return {
              content: [
                {
                  type: "text",
                  text: `Found ${businessUnits.length} business units (Total: ${result['@odata.count'] || businessUnits.length}):\n\n${JSON.stringify(businessUnits, null, 2)}`
                }
              ]
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text",
                  text: `Error listing business units: ${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. It mentions filtering and sorting options which is helpful, but doesn't disclose important behavioral traits like pagination behavior (implied by 'top' parameter but not explained), rate limits, authentication requirements, or what happens when no results match filters. The description is adequate but lacks depth for a read operation.

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 sentence states the core functionality, and the second provides usage context. There's zero wasted language and it's front-loaded with the essential information.

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-only list tool with 4 well-documented parameters but no output schema and no annotations, the description is minimally adequate. It covers the purpose and basic usage but lacks information about return format, pagination behavior, error conditions, or examples of filter/orderby syntax that would be helpful given the OData expressions mentioned in the schema.

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 fully documents all 4 parameters. The description mentions 'filtering and sorting options' which aligns with the schema parameters but doesn't add any meaningful semantic context beyond what the schema provides. The baseline of 3 is appropriate when the schema does the heavy lifting.

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 verb ('Retrieves') and resource ('list of business units in the Dataverse environment'), distinguishing it from siblings like 'get_dataverse_businessunit' (singular retrieval) and 'get_businessunit_hierarchy' (hierarchical view). It specifies the operation is a list retrieval with filtering and sorting 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 business units, understand organizational hierarchy, and find specific business units by criteria'), but doesn't explicitly state when not to use it or name specific alternatives like 'get_businessunit_hierarchy' for hierarchical views or 'get_dataverse_businessunit' for single unit retrieval.

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