get_businessunit_hierarchy
Retrieve the complete organizational hierarchy for a business unit to understand parent-child relationships and organizational structure within Dataverse.
Instructions
Retrieves the complete organizational hierarchy for a specific business unit, showing parent-child relationships and the full organizational structure. Use this to understand business unit relationships and organizational structure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| businessUnitId | Yes | Unique identifier of the business unit to get hierarchy for |
Implementation Reference
- src/tools/businessunit-tools.ts:500-524 (handler)The handler function that implements the core logic of the 'get_businessunit_hierarchy' tool by calling the Dataverse bound function 'RetrieveBusinessHierarchyBusinessUnit' to fetch the complete organizational hierarchy.async (params: any) => { try { // Use the RetrieveBusinessHierarchyBusinessUnit bound function const response = await client.get(`businessunits(${params.businessUnitId})/Microsoft.Dynamics.CRM.RetrieveBusinessHierarchyBusinessUnit()`); return { content: [ { type: "text", text: `Business unit hierarchy:\n\n${JSON.stringify(response, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error retrieving business unit hierarchy: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- The input schema defining the required 'businessUnitId' parameter for the tool.inputSchema: { businessUnitId: z.string().describe("Unique identifier of the business unit to get hierarchy for") }
- src/tools/businessunit-tools.ts:490-526 (registration)The exported factory function that registers the 'get_businessunit_hierarchy' tool, including schema and handler.export function getBusinessUnitHierarchyTool(server: McpServer, client: DataverseClient) { server.registerTool( "get_businessunit_hierarchy", { title: "Get Business Unit Hierarchy", description: "Retrieves the complete organizational hierarchy for a specific business unit, showing parent-child relationships and the full organizational structure. Use this to understand business unit relationships and organizational structure.", inputSchema: { businessUnitId: z.string().describe("Unique identifier of the business unit to get hierarchy for") } }, async (params: any) => { try { // Use the RetrieveBusinessHierarchyBusinessUnit bound function const response = await client.get(`businessunits(${params.businessUnitId})/Microsoft.Dynamics.CRM.RetrieveBusinessHierarchyBusinessUnit()`); return { content: [ { type: "text", text: `Business unit hierarchy:\n\n${JSON.stringify(response, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error retrieving business unit hierarchy: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } ); }
- src/index.ts:219-219 (registration)Invocation of the registration factory function in the main server setup.getBusinessUnitHierarchyTool(server, dataverseClient);