Skip to main content
Glama

getTemplates

Retrieve available page templates for a specific site in Adobe Experience Manager to streamline content creation and ensure consistent design implementation.

Instructions

Get available page templates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sitePathNo

Implementation Reference

  • Core handler function that implements the getTemplates tool logic by querying AEM instance for site-specific and global page templates via HTTP GET requests to template paths, with fallback logic and structured response.
    async getTemplates(sitePath) {
        return safeExecute(async () => {
            // If sitePath is provided, look for templates specific to that site
            if (sitePath) {
                try {
                    // Try to get site-specific templates from /conf
                    const confPath = `/conf${sitePath.replace('/content', '')}/settings/wcm/templates`;
                    const response = await this.httpClient.get(`${confPath}.json`, {
                        params: { ':depth': '2' }
                    });
                    const templates = [];
                    if (response.data && typeof response.data === 'object') {
                        Object.entries(response.data).forEach(([key, value]) => {
                            if (key.startsWith('jcr:') || key.startsWith('sling:'))
                                return;
                            if (value && typeof value === 'object' && value['jcr:content']) {
                                templates.push({
                                    name: key,
                                    path: `${confPath}/${key}`,
                                    title: value['jcr:content']['jcr:title'] || key,
                                    description: value['jcr:content']['jcr:description'],
                                    thumbnail: value['jcr:content']['thumbnail'],
                                    allowedPaths: value['jcr:content']['allowedPaths'],
                                    status: value['jcr:content']['status'],
                                    ranking: value['jcr:content']['ranking'] || 0,
                                    templateType: value['jcr:content']['templateType'],
                                    lastModified: value['jcr:content']['cq:lastModified'],
                                    createdBy: value['jcr:content']['jcr:createdBy']
                                });
                            }
                        });
                    }
                    return createSuccessResponse({
                        sitePath,
                        templates,
                        totalCount: templates.length,
                        source: 'site-specific'
                    }, 'getTemplates');
                }
                catch (error) {
                    // Fallback to global templates if site-specific not found
                    this.logger.warn('Site-specific templates not found, falling back to global templates', {
                        sitePath,
                        error: error.message
                    });
                }
            }
            // Get global templates from /apps or /libs
            try {
                const globalPaths = ['/apps/wcm/core/content/sites/templates', '/libs/wcm/core/content/sites/templates'];
                const allTemplates = [];
                for (const templatePath of globalPaths) {
                    try {
                        const response = await this.httpClient.get(`${templatePath}.json`, {
                            params: { ':depth': '2' }
                        });
                        if (response.data && typeof response.data === 'object') {
                            Object.entries(response.data).forEach(([key, value]) => {
                                if (key.startsWith('jcr:') || key.startsWith('sling:'))
                                    return;
                                if (value && typeof value === 'object') {
                                    allTemplates.push({
                                        name: key,
                                        path: `${templatePath}/${key}`,
                                        title: value['jcr:title'] || key,
                                        description: value['jcr:description'],
                                        thumbnail: value['thumbnail'],
                                        allowedPaths: value['allowedPaths'],
                                        status: value['status'] || 'enabled',
                                        ranking: value['ranking'] || 0,
                                        templateType: value['templateType'],
                                        lastModified: value['cq:lastModified'],
                                        createdBy: value['jcr:createdBy'],
                                        source: templatePath.includes('/apps/') ? 'apps' : 'libs'
                                    });
                                }
                            });
                        }
                    }
                    catch (pathError) {
                        // Continue to next path if this one fails
                        this.logger.debug('Template path not accessible', {
                            path: templatePath,
                            error: pathError.message
                        });
                    }
                }
                return createSuccessResponse({
                    sitePath: sitePath || 'global',
                    templates: allTemplates,
                    totalCount: allTemplates.length,
                    source: 'global'
                }, 'getTemplates');
            }
            catch (error) {
                throw handleAEMHttpError(error, 'getTemplates');
            }
        }, 'getTemplates');
    }
  • MCP tool registration entry in the list of available methods, defining name, description, and parameters.
    { name: 'getTemplates', description: 'Get available page templates', parameters: ['sitePath'] },
  • MCP request handler dispatch for 'getTemplates' tool, delegating to AEM connector.
    case 'getTemplates':
        return await this.aemConnector.getTemplates(params.sitePath);
  • TypeScript type definition/signature for getTemplates method, specifying input (optional sitePath) and output (TemplatesResponse).
    getTemplates(sitePath?: string): Promise<import("./interfaces/index.js").TemplatesResponse>;
  • Delegation method in AEMConnector that forwards getTemplates call to the TemplateOperations module.
    async getTemplates(sitePath) {
        return this.templateOps.getTemplates(sitePath);
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden but offers minimal behavioral insight. It doesn't disclose whether this is a read-only operation, if it requires authentication, how results are returned (e.g., pagination, format), or any rate limits. The description lacks essential context for safe and effective use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence, 'Get available page templates', which is front-loaded and wastes no words. It efficiently communicates the core purpose without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no annotations, no output schema, and low schema coverage (0%), the description is incomplete. It doesn't cover parameter meaning, return values, behavioral traits, or usage context, making it inadequate for a tool with even one parameter in a complex environment with many siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has one parameter 'sitePath' with 0% description coverage, and the tool description provides no information about parameters. The description doesn't explain what 'sitePath' is, its format, or if it's optional/required, failing to compensate for the schema's lack of documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get available page templates' clearly states the action (get) and resource (page templates), but it's vague about scope. It doesn't specify whether this retrieves all templates globally, per site, or with filtering, nor does it distinguish from sibling 'getTemplateStructure' which might provide more detailed template information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, context (e.g., after fetching sites), or comparisons to siblings like 'getTemplateStructure' or 'listPages', leaving the agent to infer usage based on the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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