get_document_tree
Retrieve and filter hierarchical document structures by root category, including metadata and specifying tree depth, for context-aware project architecture insights on CastPlan MCP.
Instructions
Retrieve the hierarchical document tree structure
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeMetadata | No | Include document metadata | |
| maxDepth | No | Maximum tree depth | |
| rootCategory | No | Root category to filter by |
Implementation Reference
- src/tools/enhanced/index.ts:375-406 (handler)Main execution handler for get_document_tree tool. Fetches documents, builds and filters tree using DocumentTreeService, generates representation, and returns structured tree data.tools.set('get_document_tree', async (args: any) => { try { logger.info(`Getting document tree: ${args.rootCategory || 'all'}`); const documents = await lifecycleService.getAllDocuments(); const treeNodes = await treeService.buildTree(documents); // Filter by root category if specified const filteredNodes = args.rootCategory ? treeNodes.filter(node => node.treeType === args.rootCategory) : treeNodes; // Build tree representation const treeRepresentation = await buildTreeRepresentation( filteredNodes, documents, args.includeMetadata, args.maxDepth ); return { success: true, totalNodes: filteredNodes.length, maxDepth: Math.max(...filteredNodes.map(n => n.depth)), tree: treeRepresentation, generatedAt: localizationService.getCurrentDateTimeString() }; } catch (error) { logger.error('Failed to get document tree:', error); throw error; } });
- src/tools/enhanced/index.ts:136-160 (registration)Tool registration entry in registerEnhancedTools function, defining name, description, and input schema.{ name: 'get_document_tree', description: 'Retrieve the hierarchical document tree structure', inputSchema: { type: 'object', properties: { rootCategory: { type: 'string', enum: ['master', 'component', 'category'], description: 'Root category to filter by' }, includeMetadata: { type: 'boolean', description: 'Include document metadata', default: false }, maxDepth: { type: 'number', description: 'Maximum tree depth', default: 10 } }, required: [] } },
- src/types/enhanced.types.ts:118-122 (schema)Zod schema for input validation of get_document_tree tool parameters.export const GetDocumentTreeSchema = z.object({ rootCategory: z.enum(['master', 'component', 'category']).optional(), includeMetadata: z.boolean().default(false), maxDepth: z.number().default(10), });