Skip to main content
Glama

executeJCRQuery

Execute queries on Adobe Experience Manager's Java Content Repository to retrieve content, components, or assets using JCR syntax.

Instructions

Execute JCR query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Implementation Reference

  • Core handler function that executes the JCR query via AEM QueryBuilder API, with input validation and security checks.
    async executeJCRQuery(query: string, limit = 20): Promise<JCRQueryResponse> { return safeExecute<JCRQueryResponse>(async () => { if (!query || typeof query !== 'string' || query.trim().length === 0) { throw new Error('Query is required and must be a non-empty string. Note: Only QueryBuilder fulltext is supported, not JCR SQL2.'); } // Basic security validation const lower = query.toLowerCase(); if (/drop|delete|update|insert|exec|script|\.|<script/i.test(lower) || query.length > 1000) { throw new Error('Query contains potentially unsafe patterns or is too long'); } const response = await this.httpClient.get('/bin/querybuilder.json', { params: { path: '/content', type: 'cq:Page', fulltext: query, 'p.limit': limit } }); return { query, results: response.data.hits || [], total: response.data.total || 0, limit }; }, 'executeJCRQuery'); }
  • MCP server tool call handler that extracts parameters and delegates to AEM connector.
    case 'executeJCRQuery': { const { query, limit } = args as { query: string; limit: number }; const result = await aemConnector.executeJCRQuery(query, limit); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
  • Input schema definition for the executeJCRQuery tool, specifying query (required) and optional limit.
    { name: 'executeJCRQuery', description: 'Execute JCR query', inputSchema: { type: 'object', properties: { query: { type: 'string' }, limit: { type: 'number' }, }, required: ['query'], }, },
  • Registration of the tools list handler, which exposes executeJCRQuery in the MCP tools list.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
  • Delegation handler in AEMConnector that forwards the call to SearchOperations module.
    async executeJCRQuery(query: string, limit?: number) { return this.searchOps.executeJCRQuery(query, 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