getTemplateStructure
Analyze and retrieve the detailed structure of a specific template in Adobe Experience Manager using the AEM MCP Server API for precise content and component management.
Instructions
Get detailed structure of a specific template
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| templatePath | Yes |
Implementation Reference
- Core handler function that fetches the template structure from AEM using .infinity.json endpoint, parses policies to extract allowed components, and returns structured response.async getTemplateStructure(templatePath: string): Promise<TemplateStructureResponse> { return safeExecute<TemplateStructureResponse>(async () => { try { // Get the full template structure with deeper depth const response = await this.httpClient.get(`${templatePath}.infinity.json`); const structure = { path: templatePath, properties: response.data['jcr:content'] || {}, policies: response.data['jcr:content']?.['policies'] || {}, structure: response.data['jcr:content']?.['structure'] || {}, initialContent: response.data['jcr:content']?.['initial'] || {}, allowedComponents: [] as string[], allowedPaths: response.data['jcr:content']?.['allowedPaths'] || [] }; // Extract allowed components from policies const extractComponents = (node: any, path: string = '') => { if (!node || typeof node !== 'object') return; if (node['components']) { const componentKeys = Object.keys(node['components']); structure.allowedComponents.push(...componentKeys); } Object.entries(node).forEach(([key, value]) => { if (typeof value === 'object' && value !== null && !key.startsWith('jcr:')) { extractComponents(value, path ? `${path}/${key}` : key); } }); }; extractComponents(structure.policies); // Remove duplicates structure.allowedComponents = [...new Set(structure.allowedComponents)]; return createSuccessResponse({ templatePath, structure, fullData: response.data }, 'getTemplateStructure') as TemplateStructureResponse; } catch (error: any) { throw handleAEMHttpError(error, 'getTemplateStructure'); } }, 'getTemplateStructure'); }
- src/mcp-handler.ts:81-82 (handler)MCP request handler case that delegates getTemplateStructure call to AEMConnector.case 'getTemplateStructure': return await this.aemConnector.getTemplateStructure(params.templatePath);
- src/mcp-server.ts:406-414 (registration)Tool registration in MCP tools array including name, description, and input schema.{ name: 'getTemplateStructure', description: 'Get detailed structure of a specific template', inputSchema: { type: 'object', properties: { templatePath: { type: 'string' } }, required: ['templatePath'], }, },
- src/mcp-server.ts:750-753 (handler)Primary MCP server tool dispatch handler for getTemplateStructure that extracts args and calls AEMConnector.case 'getTemplateStructure': { const templatePath = (args as { templatePath: string }).templatePath; const result = await aemConnector.getTemplateStructure(templatePath); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
- src/mcp-server.ts:578-580 (schema)MCP server registration of tools list handler which exposes the getTemplateStructure tool schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });