Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

Get Business Unit Users

get_businessunit_users

Retrieve users associated with a specific business unit to understand user assignments and organizational membership, with option to include subsidiary business unit users.

Instructions

Retrieves all users associated with a specific business unit, with option to include users from subsidiary business units. Use this to understand user assignments and organizational membership.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
businessUnitIdYesUnique identifier of the business unit
includeSubsidiaryUsersNoWhether to include users from subsidiary business units

Implementation Reference

  • Executes the tool logic: queries Dataverse API for users in the business unit (direct or subsidiary via special function), formats results, handles errors.
        try {
          let endpoint: string;
          
          if (params.includeSubsidiaryUsers) {
            // Use the RetrieveSubsidiaryUsersBusinessUnit function
            endpoint = `RetrieveSubsidiaryUsersBusinessUnit(BusinessUnitId=${params.businessUnitId})`;
          } else {
            // Get users directly associated with the business unit
            endpoint = `systemusers?$filter=businessunitid/businessunitid eq ${params.businessUnitId}&$select=systemuserid,fullname,domainname,businessunitid,isdisabled&$expand=businessunitid($select=name)`;
          }
    
          const result = await client.get(endpoint);
          const users = params.includeSubsidiaryUsers ? result : result.value;
    
          const formattedUsers = (Array.isArray(users) ? users : users?.value || []).map((user: any) => ({
            userId: user.systemuserid,
            fullName: user.fullname,
            domainName: user.domainname,
            businessUnitId: user.businessunitid,
            businessUnitName: user.businessunitid?.name,
            isDisabled: user.isdisabled
          }));
    
          return {
            content: [
              {
                type: "text",
                text: `Found ${formattedUsers.length} ${params.includeSubsidiaryUsers ? 'subsidiary ' : ''}users for business unit:\n\n${JSON.stringify(formattedUsers, null, 2)}`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error retrieving business unit users: ${error instanceof Error ? error.message : 'Unknown error'}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • Input schema using Zod validation for businessUnitId (required GUID) and optional includeSubsidiaryUsers flag.
      title: "Get Business Unit Users",
      description: "Retrieves all users associated with a specific business unit, with option to include users from subsidiary business units. Use this to understand user assignments and organizational membership.",
      inputSchema: {
        businessUnitId: z.string().describe("Unique identifier of the business unit"),
        includeSubsidiaryUsers: z.boolean().optional().default(false).describe("Whether to include users from subsidiary business units")
      }
    },
  • Registers the 'get_businessunit_users' tool on the MCP server within the getBusinessUnitUsersTool function.
      server.registerTool(
        "get_businessunit_users",
        {
          title: "Get Business Unit Users",
          description: "Retrieves all users associated with a specific business unit, with option to include users from subsidiary business units. Use this to understand user assignments and organizational membership.",
          inputSchema: {
            businessUnitId: z.string().describe("Unique identifier of the business unit"),
            includeSubsidiaryUsers: z.boolean().optional().default(false).describe("Whether to include users from subsidiary business units")
          }
        },
        async (params: any) => {
          try {
            let endpoint: string;
            
            if (params.includeSubsidiaryUsers) {
              // Use the RetrieveSubsidiaryUsersBusinessUnit function
              endpoint = `RetrieveSubsidiaryUsersBusinessUnit(BusinessUnitId=${params.businessUnitId})`;
            } else {
              // Get users directly associated with the business unit
              endpoint = `systemusers?$filter=businessunitid/businessunitid eq ${params.businessUnitId}&$select=systemuserid,fullname,domainname,businessunitid,isdisabled&$expand=businessunitid($select=name)`;
            }
    
            const result = await client.get(endpoint);
            const users = params.includeSubsidiaryUsers ? result : result.value;
    
            const formattedUsers = (Array.isArray(users) ? users : users?.value || []).map((user: any) => ({
              userId: user.systemuserid,
              fullName: user.fullname,
              domainName: user.domainname,
              businessUnitId: user.businessunitid,
              businessUnitName: user.businessunitid?.name,
              isDisabled: user.isdisabled
            }));
    
            return {
              content: [
                {
                  type: "text",
                  text: `Found ${formattedUsers.length} ${params.includeSubsidiaryUsers ? 'subsidiary ' : ''}users for business unit:\n\n${JSON.stringify(formattedUsers, null, 2)}`
                }
              ]
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text",
                  text: `Error retrieving business unit users: ${error instanceof Error ? error.message : 'Unknown error'}`
                }
              ],
              isError: true
            };
          }
        }
      );
    }
  • src/index.ts:221-221 (registration)
    Calls the registration function during server initialization to register the tool.
    getBusinessUnitUsersTool(server, dataverseClient);
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 the option to include subsidiary users, which adds useful context, but does not cover other behavioral aspects like permissions required, rate limits, pagination, or what happens if the business unit doesn't exist. This leaves gaps for a read operation tool.

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 appropriately sized with two sentences that are front-loaded with the core purpose and usage context. Every sentence earns its place by providing essential information without redundancy or unnecessary details.

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?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is somewhat complete but lacks details on behavioral aspects like error handling or response format. It adequately covers the purpose and basic usage but could benefit from more context to fully guide 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?

The input schema has 100% description coverage, so the schema already documents both parameters thoroughly. The description mentions the option to include subsidiary users, which aligns with the includeSubsidiaryUsers parameter, but does not add significant meaning beyond what the schema provides, resulting in a baseline score of 3.

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 a specific verb ('Retrieves') and resource ('all users associated with a specific business unit'), and distinguishes it from sibling tools like get_team_members or get_dataverse_businessunit by focusing on user retrieval within a business unit context.

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 understand user assignments and organizational membership'), but does not explicitly mention when not to use it or name alternative tools for similar purposes, such as get_team_members for team-specific user 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