listPages
Retrieve all pages under a specified site root with adjustable depth and limit settings to streamline site navigation and content management in Adobe Experience Manager.
Instructions
List all pages under a site root
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| depth | No | ||
| limit | No | ||
| siteRoot | No |
Implementation Reference
- Core handler function that implements the listPages logic: recursively traverses site tree via .json API, filters cq:Page nodes, with QueryBuilder fallbackasync listPages(siteRoot, depth = 1, limit = 20) { return safeExecute(async () => { // First try direct JSON API approach for better performance try { const response = await this.httpClient.get(`${siteRoot}.${depth}.json`); const pages = []; const processNode = (node, currentPath, currentDepth) => { if (currentDepth > depth || pages.length >= limit) return; Object.entries(node).forEach(([key, value]) => { if (pages.length >= limit) return; // Skip JCR system properties if (key.startsWith('jcr:') || key.startsWith('sling:') || key.startsWith('cq:') || key.startsWith('rep:') || key.startsWith('oak:')) { return; } if (value && typeof value === 'object') { const childPath = `${currentPath}/${key}`; const primaryType = value['jcr:primaryType']; // Only include cq:Page nodes if (primaryType === 'cq:Page') { pages.push({ name: key, path: childPath, primaryType: 'cq:Page', title: value['jcr:content']?.['jcr:title'] || key, template: value['jcr:content']?.['cq:template'], lastModified: value['jcr:content']?.['cq:lastModified'], lastModifiedBy: value['jcr:content']?.['cq:lastModifiedBy'], resourceType: value['jcr:content']?.['sling:resourceType'], type: 'page' }); } // Recursively process child nodes if within depth limit if (currentDepth < depth) { processNode(value, childPath, currentDepth + 1); } } }); }; if (response.data && typeof response.data === 'object') { processNode(response.data, siteRoot, 0); } return createSuccessResponse({ siteRoot, pages, pageCount: pages.length, depth, limit, totalChildrenScanned: pages.length }, 'listPages'); } catch (error) { // Fallback to QueryBuilder if JSON API fails if (error.response?.status === 404 || error.response?.status === 403) { const response = await this.httpClient.get('/bin/querybuilder.json', { params: { path: siteRoot, type: 'cq:Page', 'p.nodedepth': depth.toString(), 'p.limit': limit.toString(), 'p.hits': 'full' }, }); const pages = (response.data.hits || []).map((hit) => ({ name: hit.name || hit.path?.split('/').pop(), path: hit.path, primaryType: 'cq:Page', title: hit['jcr:content/jcr:title'] || hit.title || hit.name, template: hit['jcr:content/cq:template'], lastModified: hit['jcr:content/cq:lastModified'], lastModifiedBy: hit['jcr:content/cq:lastModifiedBy'], resourceType: hit['jcr:content/sling:resourceType'], type: 'page' })); return createSuccessResponse({ siteRoot, pages, pageCount: pages.length, depth, limit, totalChildrenScanned: response.data.total || pages.length, fallbackUsed: 'QueryBuilder' }, 'listPages'); } throw error; } }, 'listPages'); }
- dist/mcp-server.js:647-651 (handler)MCP CallToolRequestSchema handler case for 'listPages' tool, extracts params and calls aemConnector.listPagescase 'listPages': { const { siteRoot, depth, limit } = args; const result = await aemConnector.listPages(siteRoot, depth, limit); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- dist/mcp-server.js:154-165 (registration)Registration of 'listPages' tool in the MCP tools array, including name, description, and inputSchema used by ListToolsRequest{ name: 'listPages', description: 'List all pages under a site root', inputSchema: { type: 'object', properties: { siteRoot: { type: 'string' }, depth: { type: 'number' }, limit: { type: 'number' }, }, }, },
- dist/mcp-handler.js:35-36 (handler)Alternative handler in MCPRequestHandler class switch statementcase 'listPages': return await this.aemConnector.listPages(params.siteRoot || params.path || '/content', params.depth || 1, params.limit || 20);
- dist/mcp-handler.js:128-128 (registration)Tool listing in getAvailableMethods() for listPages with parameters array (simplified schema){ name: 'listPages', description: 'List all pages under a site root', parameters: ['siteRoot', 'depth', 'limit'] },