get_suite_hierarchy
Retrieve hierarchical test suite tree structure with configurable depth for Zebrunner project test organization and navigation.
Instructions
🌳 Get hierarchical test suite tree with configurable depth
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format | json |
| include_clickable_links | No | Include clickable links to Zebrunner web UI | |
| max_depth | No | Maximum tree depth | |
| project_key | Yes | Project key | |
| root_suite_id | No | Start from specific root suite |
Implementation Reference
- src/handlers/tools.ts:146-196 (handler)Core implementation of the get_suite_hierarchy tool handler in ZebrunnerToolHandlers class. Fetches suites via API client, processes hierarchy using HierarchyProcessor, applies depth limit, formats output.async getSuiteHierarchy(input: z.infer<typeof GetSuiteHierarchyInputSchema>) { const { projectKey, rootSuiteId, maxDepth, format } = input; try { const allSuites = await this.client.getAllTestSuites(projectKey); let suitesToProcess = allSuites; // Filter by root suite if specified if (rootSuiteId) { const descendants = HierarchyProcessor.getSuiteDescendants(rootSuiteId, allSuites); const rootSuite = allSuites.find(s => s.id === rootSuiteId); suitesToProcess = rootSuite ? [rootSuite, ...descendants] : descendants; } // Build hierarchical tree const hierarchyTree = HierarchyProcessor.buildSuiteTree(suitesToProcess); // Limit depth if specified const limitDepth = (suites: any[], currentDepth: number): any[] => { if (currentDepth >= maxDepth) { return suites.map(suite => ({ ...suite, children: [] })); } return suites.map(suite => ({ ...suite, children: suite.children ? limitDepth(suite.children, currentDepth + 1) : [] })); }; const limitedTree = limitDepth(hierarchyTree, 0); const formattedData = FormatProcessor.format(limitedTree, format); return { content: [ { type: "text" as const, text: typeof formattedData === 'string' ? formattedData : JSON.stringify(formattedData, null, 2) } ] }; } catch (error: any) { return { content: [ { type: "text" as const, text: `Error retrieving suite hierarchy: ${error.message}` } ] }; } }
- src/types/api.ts:112-117 (schema)Zod input schema defining parameters for the get_suite_hierarchy tool: projectKey (required), rootSuiteId (optional), maxDepth (default 5), format.export const GetSuiteHierarchyInputSchema = z.object({ projectKey: z.string().min(1), rootSuiteId: z.number().int().positive().optional(), maxDepth: z.number().int().positive().max(10).default(5), format: z.enum(['dto', 'json', 'string']).default('json') });
- src/index-enhanced.ts:133-143 (registration)MCP server tool registration for get_suite_hierarchy, linking name, description, input schema, and handler execution.server.tool( "get_suite_hierarchy", "Get hierarchical test suite tree with configurable depth", { projectKey: z.string().min(1), rootSuiteId: z.number().int().positive().optional(), maxDepth: z.number().int().positive().max(10).default(5), format: z.enum(['dto', 'json', 'string']).default('json') }, async (args) => toolHandlers.getSuiteHierarchy(args) );