Skip to main content
Glama

listPages

Retrieve all pages from an Adobe Experience Manager site root, with options to control depth and limit results for content management.

Instructions

List all pages under a site root

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteRootNo
depthNo
limitNo

Implementation Reference

  • Registration of the 'listPages' MCP tool including name, description, and input schema.
    { name: 'listPages', description: 'List all pages under a site root', inputSchema: { type: 'object', properties: { siteRoot: { type: 'string' }, depth: { type: 'number' }, limit: { type: 'number' }, }, }, },
  • MCP server handler for 'listPages' tool: extracts parameters and delegates to AEMConnector.listPages, formats result as JSON text content.
    case 'listPages': { const { siteRoot, depth, limit } = args; const result = await aemConnector.listPages(siteRoot, depth, limit); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
  • Core implementation of listPages: fetches site tree as JSON, recursively traverses to collect cq:Page nodes up to depth/limit, falls back to QueryBuilder query, wraps in success response.
    async listPages(siteRoot, depth = 1, limit = 20) { return safeExecute(async () => { const client = this.createAxiosInstance(); // First try direct JSON API approach for better performance try { const response = await client.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 client.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');
  • Alternative handler in MCPRequestHandler class that delegates listPages call to AEMConnector with default parameters.
    case 'listPages': return await this.aemConnector.listPages(params.siteRoot || params.path || '/content', params.depth || 1, params.limit || 20);
  • Tool registration entry in getAvailableMethods() for listPages with parameters list.
    { name: 'listPages', description: 'List all pages under a site root', parameters: ['siteRoot', 'depth', 'limit'] },

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