Skip to main content
Glama

aem_query_content

Execute JCR-SQL2 or XPath queries on Adobe Experience Manager (AEM) content to retrieve specific nodes or data, with customizable limits and host configurations.

Instructions

Query content using JCR-SQL2 or XPath

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostNoAEM host (default: localhost)localhost
limitNoMaximum number of results (default: 20)
passwordNoAEM password (default: admin)admin
portNoAEM port (default: 4502)
queryYesQuery string (JCR-SQL2 or XPath)
typeNoQuery typeJCR-SQL2
usernameNoAEM username (default: admin)admin

Implementation Reference

  • The primary handler function for the 'aem_query_content' tool. It validates input, calls the AEMClient to perform the query, and formats the response as MCP content.
    async queryContent(args: any) { const config = this.getConfig(args); const { query, type = 'JCR-SQL2', limit = 20 } = args; if (!query) { throw new Error('Query is required'); } const result = await this.aemClient.queryContent(config, query, type, limit); let queryText = `Content Query Result: Query: ${query} Type: ${type} Limit: ${limit} Success: ${result.success} `; if (result.success && result.results) { queryText += `Results:\n${JSON.stringify(result.results, null, 2)}`; } else { queryText += `Message: ${result.message || 'Query failed'}`; } return { content: [ { type: 'text', text: queryText, }, ], }; }
  • Input schema definition for the 'aem_query_content' tool, including parameters like query, type, limit, and AEM connection details.
    inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Query string (JCR-SQL2 or XPath)' }, type: { type: 'string', description: 'Query type', enum: ['JCR-SQL2', 'xpath'], default: 'JCR-SQL2' }, limit: { type: 'number', description: 'Maximum number of results (default: 20)', default: 20 }, host: { type: 'string', description: 'AEM host (default: localhost)', default: 'localhost' }, port: { type: 'number', description: 'AEM port (default: 4502)', default: 4502 }, username: { type: 'string', description: 'AEM username (default: admin)', default: 'admin' }, password: { type: 'string', description: 'AEM password (default: admin)', default: 'admin' } }, required: ['query'] }
  • src/index.ts:363-364 (registration)
    Registration of the tool handler in the CallToolRequest switch statement, dispatching to AEMTools.queryContent.
    case 'aem_query_content': return await this.aemTools.queryContent(args);
  • src/index.ts:231-275 (registration)
    Tool registration in the ListTools response, including name, description, and schema reference.
    { name: 'aem_query_content', description: 'Query content using JCR-SQL2 or XPath', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Query string (JCR-SQL2 or XPath)' }, type: { type: 'string', description: 'Query type', enum: ['JCR-SQL2', 'xpath'], default: 'JCR-SQL2' }, limit: { type: 'number', description: 'Maximum number of results (default: 20)', default: 20 }, host: { type: 'string', description: 'AEM host (default: localhost)', default: 'localhost' }, port: { type: 'number', description: 'AEM port (default: 4502)', default: 4502 }, username: { type: 'string', description: 'AEM username (default: admin)', default: 'admin' }, password: { type: 'string', description: 'AEM password (default: admin)', default: 'admin' } }, required: ['query'] } },
  • Core helper function that executes the HTTP request to AEM's QueryBuilder endpoint (/bin/querybuilder.json) to perform the actual content query.
    async queryContent(config: AEMConfig, query: string, type: string = 'JCR-SQL2', limit: number = 20): Promise<any> { const baseUrl = this.getBaseUrl(config); const authHeader = this.getAuthHeader(config); const params = new URLSearchParams(); params.append('query', query); params.append('type', type); params.append('p.limit', limit.toString()); try { const response = await this.axiosInstance.get( `${baseUrl}/bin/querybuilder.json?${params.toString()}`, { headers: { 'Authorization': authHeader, }, } ); if (response.status === 200) { return { success: true, results: response.data, }; } else { return { success: false, message: `Query failed: HTTP ${response.status}`, }; } } catch (error) { throw new Error(`Query failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } }

Other Tools

Related 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/pradeep-moolemane/aem-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server