Skip to main content
Glama

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
NameRequiredDescriptionDefault
includeMetadataNoInclude document metadata
maxDepthNoMaximum tree depth
rootCategoryNoRoot category to filter by

Implementation Reference

  • 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; } });
  • 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: [] } },
  • 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), });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ghostseller/CastPlan_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server