get_organization_department_ancestors
Retrieve the hierarchical chain of parent departments for a specific department within an Alibaba Cloud DevOps organization to understand reporting structures and access controls.
Instructions
Get the ancestors of a department in an organization
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organizationId | Yes | Organization ID | |
| id | Yes | Department ID |
Implementation Reference
- tool-handlers/organization.ts:30-39 (handler)MCP tool handler for get_organization_department_ancestors: parses input args using schema, calls the core helper function, and formats response as JSON text.case "get_organization_department_ancestors": { const args = types.GetOrganizationDepartmentAncestorsSchema.parse(request.params.arguments); const ancestors = await organization.getOrganizationDepartmentAncestorsFunc( args.organizationId, args.id ); return { content: [{ type: "text", text: JSON.stringify(ancestors, null, 2) }], }; }
- Zod schema defining input parameters: organizationId and department id.export const GetOrganizationDepartmentAncestorsSchema = z.object({ organizationId: z.string().describe("Organization ID"), id: z.string().describe("Department ID"), });
- tool-registry/organization.ts:31-35 (registration)Tool registration entry with name, description, and JSON schema derived from Zod schema.{ name: "get_organization_department_ancestors", description: "Get the ancestors of a department in an organization", inputSchema: zodToJsonSchema(types.GetOrganizationDepartmentAncestorsSchema), },
- Helper function that constructs API URL, makes GET request to fetch department ancestors, and parses response using schema.export async function getOrganizationDepartmentAncestorsFunc( organizationId: string, id: string): Promise<z.infer<typeof OrganizationDepartmentsSchema>> { const url = `/oapi/v1/platform/organizations/${organizationId}/departments/${id}/ancestors`; const response = await yunxiaoRequest(url, { method: "GET", }) return OrganizationDepartmentsSchema.parse(response); };