Skip to main content
Glama

get_document_tree

Retrieve hierarchical document tree structures to understand project organization, with options to filter by root category, include metadata, and control depth.

Instructions

Retrieve the hierarchical document tree structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rootCategoryNoRoot category to filter by
includeMetadataNoInclude document metadata
maxDepthNoMaximum tree depth

Implementation Reference

  • The main handler function that executes the get_document_tree tool logic. It retrieves all documents, builds the tree using DocumentTreeService, filters by root category if specified, builds a tree representation, and returns structured results including total nodes and max depth.
    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; } });
  • Zod schema defining the input validation for the get_document_tree tool parameters: rootCategory (optional enum), includeMetadata (boolean, default false), maxDepth (number, default 10).
    export const GetDocumentTreeSchema = z.object({ rootCategory: z.enum(['master', 'component', 'category']).optional(), includeMetadata: z.boolean().default(false), maxDepth: z.number().default(10), });
  • MCPTool registration object defining the name, description, and JSON schema for the get_document_tree tool inputs, used in the registerEnhancedTools function.
    { 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: [] } },

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