list_organization_departments
Retrieve department structures within an Alibaba Cloud organization to manage team hierarchies and access controls for DevOps workflows.
Instructions
Get the list of departments in an organization
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organizationId | Yes | Organization ID | |
| parentId | No | Parent department ID |
Implementation Reference
- tool-handlers/organization.ts:8-17 (handler)Tool handler switch case that parses arguments using the schema, calls the core getOrganizationDepartmentsFunc, and returns the departments as JSON string.case "list_organization_departments": { const args = types.GetOrganizationDepartmentsSchema.parse(request.params.arguments); const departments = await organization.getOrganizationDepartmentsFunc( args.organizationId, args.parentId ?? undefined ); return { content: [{ type: "text", text: JSON.stringify(departments, null, 2) }], }; }
- tool-registry/organization.ts:21-25 (registration)Tool registration entry defining name, description, and input schema reference.{ name: "list_organization_departments", description: "Get the list of departments in an organization", inputSchema: zodToJsonSchema(types.GetOrganizationDepartmentsSchema), },
- Zod input schema for the tool arguments: organizationId (required), parentId (optional).export const GetOrganizationDepartmentsSchema = z.object({ organizationId: z.string().describe("Organization ID"), parentId: z.string().optional().describe("Parent department ID"), });
- Core helper function that constructs the API URL, makes the yunxiaoRequest GET call, and parses the response using OrganizationDepartmentsSchema.export async function getOrganizationDepartmentsFunc( organizationId: string, parentId?: string ): Promise<z.infer<typeof OrganizationDepartmentsSchema>> { const baseUrl = `/oapi/v1/platform/organizations/${organizationId}/departments`; const params: Record<string, string | undefined> = {}; if (parentId) { params.parentId = parentId; } const url = buildUrl(baseUrl, params); const response = await yunxiaoRequest(url, { method: "GET" }); return OrganizationDepartmentsSchema.parse(response); }