listChildren
Retrieve and list child nodes for a specified path in Adobe Experience Manager using the AEM MCP Server. Enables efficient content management and organization.
Instructions
Legacy: List child nodes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/mcp-server.ts:669-673 (handler)MCP server handler for the 'listChildren' tool: extracts 'path' from arguments, calls aemConnector.listChildren, and formats response as MCP content.case 'listChildren': { const path = (args as { path: string }).path; const children = await aemConnector.listChildren(path); return { content: [{ type: 'text', text: JSON.stringify({ children }, null, 2) }] }; }
- src/mcp-server.ts:188-196 (registration)Tool registration in the MCP server's tools list, including name, description, and input schema requiring 'path' parameter.{ name: 'listChildren', description: 'Legacy: List child nodes', inputSchema: { type: 'object', properties: { path: { type: 'string' } }, required: ['path'], }, },
- Core helper function implementing listChildren logic: fetches direct children via .1.json endpoint, filters system properties, falls back to QueryBuilder for pages.async listChildren(path: string): Promise<ChildrenResponse> { return safeExecute<ChildrenResponse>(async () => { // First try direct JSON API approach try { const response = await this.httpClient.get(`${path}.1.json`); const children: Array<{ name: string; path: string; primaryType: string; title: string; lastModified?: string; resourceType?: string; }> = []; if (response.data && typeof response.data === 'object') { Object.entries(response.data).forEach(([key, value]: [string, any]) => { // 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: any) { // Fallback to QueryBuilder for cq:Page nodes specifically if (error.response?.status === 404 || error.response?.status === 403) { const response = await this.httpClient.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: any) => ({ 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'); }
- dist/interfaces/index.d.ts:550-559 (schema)TypeScript interface defining the structure of the response from listChildren tool.export interface ChildrenResponse { children: Array<{ name: string; path: string; primaryType: string; title: string; lastModified?: string; resourceType?: string; }>; }
- src/aem-connector-new.ts:201-202 (helper)Delegation method in AEMConnector that forwards listChildren calls to UtilityOperations instance.async listChildren(path: string) { return this.utilityOps.listChildren(path);