Skip to main content
Glama

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
NameRequiredDescriptionDefault
templatePathYes

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'); }
  • MCP request handler case that delegates getTemplateStructure call to AEMConnector.
    case 'getTemplateStructure': return await this.aemConnector.getTemplateStructure(params.templatePath);
  • 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'], }, },
  • 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) }] };
  • MCP server registration of tools list handler which exposes the getTemplateStructure tool schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });

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/indrasishbanerjee/aem-mcp-server'

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