Skip to main content
Glama

enhancedPageSearch

Search Adobe Experience Manager pages using intelligent queries with fallback strategies and cross-section search capabilities.

Instructions

Intelligent page search with comprehensive fallback strategies and cross-section search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchTermYes
basePathYes
includeAlternateLocalesNo

Implementation Reference

  • Core handler implementing enhancedPageSearch with fallback strategies: fulltext, title, description searches, and optional cross-locale search using AEM QueryBuilder.
    async enhancedPageSearch(params: EnhancedSearchParams): Promise<SearchResponse> {
      return safeExecute<SearchResponse>(async () => {
        const { searchTerm, basePath, includeAlternateLocales } = params;
        
        // Try multiple search strategies
        const searchStrategies = [
          // Strategy 1: Direct fulltext search
          () => this.searchContent({
            fulltext: searchTerm,
            path: basePath,
            type: 'cq:Page',
            limit: 20
          }),
          
          // Strategy 2: Search by title
          () => this.searchContent({
            'property': 'jcr:title',
            'property.value': searchTerm,
            'property.operation': 'like',
            path: basePath,
            type: 'cq:Page',
            limit: 20
          } as any),
          
          // Strategy 3: Search by description
          () => this.searchContent({
            'property': 'jcr:description',
            'property.value': searchTerm,
            'property.operation': 'like',
            path: basePath,
            type: 'cq:Page',
            limit: 20
          } as any)
        ];
    
        // If includeAlternateLocales is true, add locale-specific searches
        if (includeAlternateLocales) {
          searchStrategies.push(
            // Strategy 4: Search in all locales
            () => this.searchContent({
              fulltext: searchTerm,
              path: basePath.replace(/\/[a-z]{2}(-[A-Z]{2})?$/, ''),
              type: 'cq:Page',
              limit: 20
            })
          );
        }
    
        // Try each strategy until one succeeds
        let lastError: any;
        for (const strategy of searchStrategies) {
          try {
            const result = await strategy();
            if (result.data.results && result.data.results.length > 0) {
              return createSuccessResponse({
                params: {
                  searchTerm,
                  basePath,
                  includeAlternateLocales,
                  strategy: 'enhanced'
                },
                results: result.data.results,
                total: result.data.total,
                searchStrategies: searchStrategies.length
              }, 'enhancedPageSearch') as SearchResponse;
            }
          } catch (error) {
            lastError = error;
            this.logger.warn('Search strategy failed', {
              error: error instanceof Error ? error.message : String(error),
              searchTerm,
              basePath
            });
          }
        }
    
        // If all strategies failed, return empty results
        this.logger.warn('All search strategies failed', {
          searchTerm,
          basePath,
          lastError: lastError instanceof Error ? lastError.message : String(lastError)
        });
    
        return createSuccessResponse({
          params: {
            searchTerm,
            basePath,
            includeAlternateLocales,
            strategy: 'enhanced'
          },
          results: [],
          total: 0,
          searchStrategies: searchStrategies.length,
          allStrategiesFailed: true
        }, 'enhancedPageSearch') as SearchResponse;
      }, 'enhancedPageSearch');
    }
  • MCP tool schema definition specifying input parameters for enhancedPageSearch.
    {
      name: 'enhancedPageSearch',
      description: 'Intelligent page search with comprehensive fallback strategies and cross-section search',
      inputSchema: {
        type: 'object',
        properties: {
          searchTerm: { type: 'string' },
          basePath: { type: 'string' },
          includeAlternateLocales: { type: 'boolean' },
        },
        required: ['searchTerm', 'basePath'],
      },
    },
  • Registration of tool list handler that exposes enhancedPageSearch in the tools array.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools };
    });
  • MCP server tool call handler dispatching to AEM connector's enhancedPageSearch.
    case 'enhancedPageSearch': {
      const result = await aemConnector.enhancedPageSearch(args);
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
  • Internal MCP request handler switch case calling enhancedPageSearch.
    case 'enhancedPageSearch':
      return await this.aemConnector.enhancedPageSearch(params);

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