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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| limit | No |
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'); }
- src/mcp-server.ts:683-687 (handler)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) }] }; }
- src/mcp-server.ts:219-230 (schema)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'], }, },
- src/mcp-server.ts:578-580 (registration)Registration of the tools list handler, which exposes executeJCRQuery in the MCP tools list.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/aem-connector-new.ts:170-172 (handler)Delegation handler in AEMConnector that forwards the call to SearchOperations module.async executeJCRQuery(query: string, limit?: number) { return this.searchOps.executeJCRQuery(query, limit); }