Skip to main content
Glama

aem_clear_cache

Clear AEM caches including dispatcher, clientlibs, or all cached data. Specify host, port, and credentials to manage cache directly from the AEM MCP Server.

Instructions

Clear various AEM caches

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cacheTypeNoType of cache to clearall
hostNoAEM host (default: localhost)localhost
passwordNoAEM password (default: admin)admin
portNoAEM port (default: 4502)
usernameNoAEM username (default: admin)admin

Implementation Reference

  • The main tool handler function in AEMTools class that extracts config and cacheType from args, calls the AEMClient.clearCache method, formats the results into a text response, and returns it in MCP format.
    async clearCache(args: any) { const config = this.getConfig(args); const { cacheType = 'all' } = args; const result = await this.aemClient.clearCache(config, cacheType); let cacheText = `Cache Clear Result: Cache Type: ${cacheType} Success: ${result.success} `; if (result.success && result.results) { cacheText += `\nResults:\n`; result.results.forEach((res: any) => { cacheText += `- ${res.type}: ${res.success ? 'Success' : 'Failed'} - ${res.message}\n`; }); } else { cacheText += `Message: Failed to clear cache`; } return { content: [ { type: 'text', text: cacheText, }, ], }; }
  • Core implementation in AEMClient that performs the actual HTTP requests to clear clientlibs and/or dispatcher caches based on the cacheType, collecting results from each operation.
    async clearCache(config: AEMConfig, cacheType: string = 'all'): Promise<any> { const baseUrl = this.getBaseUrl(config); const authHeader = this.getAuthHeader(config); const results: any[] = []; try { if (cacheType === 'clientlibs' || cacheType === 'all') { // Clear client libraries cache const clientlibsResponse = await this.axiosInstance.post( `${baseUrl}/libs/granite/ui/content/dumplibs.rebuild.html`, {}, { headers: { 'Authorization': authHeader, }, } ); results.push({ type: 'clientlibs', success: clientlibsResponse.status === 200, message: clientlibsResponse.status === 200 ? 'Client libraries cache cleared' : 'Failed to clear client libraries cache', }); } if (cacheType === 'dispatcher' || cacheType === 'all') { // Invalidate dispatcher cache (if available) try { const dispatcherResponse = await this.axiosInstance.post( `${baseUrl}/dispatcher/invalidate.cache`, {}, { headers: { 'Authorization': authHeader, }, } ); results.push({ type: 'dispatcher', success: dispatcherResponse.status === 200, message: dispatcherResponse.status === 200 ? 'Dispatcher cache invalidated' : 'Failed to invalidate dispatcher cache', }); } catch (error) { results.push({ type: 'dispatcher', success: false, message: 'Dispatcher cache invalidation not available or failed', }); } } return { success: true, results: results, }; } catch (error) { throw new Error(`Cache clearing failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
  • Input schema definition for the aem_clear_cache tool, including properties for cacheType, host, port, username, and password with defaults.
    name: 'aem_clear_cache', description: 'Clear various AEM caches', inputSchema: { type: 'object', properties: { cacheType: { type: 'string', description: 'Type of cache to clear', enum: ['dispatcher', 'clientlibs', 'all'], default: 'all' }, 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' } } } }
  • src/index.ts:367-368 (registration)
    Registration of the tool handler in the MCP CallToolRequest switch statement, delegating execution to AEMTools.clearCache method.
    case 'aem_clear_cache': return await this.aemTools.clearCache(args);

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