Skip to main content
Glama

listChildren

Retrieve child nodes from a specified path in Adobe Experience Manager to manage content structure and hierarchy.

Instructions

Legacy: List child nodes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • Core handler function that implements listChildren by fetching AEM node JSON, extracting child nodes (filtering system props), with fallback to QueryBuilder for pages.
    async listChildren(path, depth = 1) {
        return safeExecute(async () => {
            const client = this.createAxiosInstance();
            // First try direct JSON API approach
            try {
                const response = await client.get(`${path}.${depth}.json`);
                const children = [];
                if (response.data && typeof response.data === 'object') {
                    Object.entries(response.data).forEach(([key, value]) => {
                        // Skip JCR system properties and metadata
                        if (key.startsWith('jcr:') || key.startsWith('sling:') || key.startsWith('cq:') ||
                            key.startsWith('rep:') || key.startsWith('oak:') || key === 'jcr:content') {
                            return;
                        }
                        if (value && typeof value === 'object') {
                            const childPath = `${path}/${key}`;
                            children.push({
                                name: key,
                                path: childPath,
                                primaryType: value['jcr:primaryType'] || 'nt:unstructured',
                                title: value['jcr:content']?.['jcr:title'] ||
                                    value['jcr:title'] ||
                                    key,
                                lastModified: value['jcr:content']?.['cq:lastModified'] ||
                                    value['cq:lastModified'],
                                resourceType: value['jcr:content']?.['sling:resourceType'] ||
                                    value['sling:resourceType']
                            });
                        }
                    });
                }
                return children;
            }
            catch (error) {
                // Fallback to QueryBuilder for cq:Page nodes specifically
                if (error.response?.status === 404 || error.response?.status === 403) {
                    const response = await client.get('/bin/querybuilder.json', {
                        params: {
                            path: path,
                            type: 'cq:Page',
                            'p.nodedepth': '1',
                            'p.limit': '1000',
                            'p.hits': 'full'
                        },
                    });
                    const children = (response.data.hits || []).map((hit) => ({
                        name: hit.name || hit.path?.split('/').pop(),
                        path: hit.path,
                        primaryType: hit['jcr:primaryType'] || 'cq:Page',
                        title: hit['jcr:content/jcr:title'] || hit.title || hit.name,
                        lastModified: hit['jcr:content/cq:lastModified'],
                        resourceType: hit['jcr:content/sling:resourceType']
                    }));
                    return children;
                }
                throw error;
            }
        }, 'listChildren');
    }
  • MCP SDK request handler case that processes listChildren tool calls by extracting path argument and invoking the AEM connector.
    case 'listChildren': {
        const path = args.path;
        const children = await aemConnector.listChildren(path);
        return { content: [{ type: 'text', text: JSON.stringify({ children }, null, 2) }] };
    }
  • Registration of the listChildren tool in the MCP server tools array, including input schema requiring 'path' parameter.
    {
        name: 'listChildren',
        description: 'Legacy: List child nodes',
        inputSchema: {
            type: 'object',
            properties: { path: { type: 'string' } },
            required: ['path'],
        },
    },
  • Handler dispatch in MCPRequestHandler switch statement for listChildren.
    case 'listChildren':
        return await this.aemConnector.listChildren(params.path);
  • Tool description listed in MCPRequestHandler.getAvailableMethods() for client discovery.
    { name: 'listChildren', description: 'Legacy: List child nodes', parameters: ['path'] },

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