Skip to main content
Glama

clear_cache

Clear cache in SAP Commerce Cloud (Hybris) to resolve data display issues by removing outdated cached content, with optional targeting of specific cache types.

Instructions

Clear the Hybris cache

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cacheTypeNoSpecific cache type to clear (optional, clears all if not specified)

Implementation Reference

  • Primary handler implementation for clearing Hybris cache using a Groovy script that invokes cacheController.clearCache() or general cache clear.
    async clearCache(cacheType?: string): Promise<{ success: boolean; message: string }> { // Use Groovy script to clear cache const escapedType = cacheType ? this.escapeGroovyString(cacheType) : ''; const script = ` import de.hybris.platform.core.Registry def cacheType = "${escapedType}" if (cacheType == "all" || cacheType == "") { Registry.getCurrentTenant().getCache().clear() println "All caches cleared" return "SUCCESS" } else { // Clear specific cache region if supported try { def cacheController = spring.getBean("cacheController") cacheController.clearCache() println "Cache cleared: " + cacheType return "SUCCESS" } catch (Exception e) { Registry.getCurrentTenant().getCache().clear() println "Cleared all caches (specific cache type not supported)" return "SUCCESS" } } `; const result = await this.executeGroovyScript(script); const output = result.output || ''; const execResult = String(result.result || ''); const success = output.includes('cleared') || execResult === 'SUCCESS'; return { success, message: success ? 'Cache cleared successfully' : `Failed to clear cache: ${output || execResult || 'Unknown error'}`, }; }
  • MCP tool call handler dispatch for 'clear_cache', validates input and calls hybrisClient.clearCache()
    case 'clear_cache': result = await hybrisClient.clearCache( validateString(args, 'cacheType', false) ); break;
  • Tool definition including name, description, and input schema for 'clear_cache' used for registration and validation
    { name: 'clear_cache', description: 'Clear the Hybris cache', inputSchema: { type: 'object', properties: { cacheType: { type: 'string', description: 'Specific cache type to clear (optional, clears all if not specified)', }, }, }, },
  • src/index.ts:359-361 (registration)
    Registration of the tools list handler, which exposes the clear_cache tool via ListToolsRequest
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
  • Direct call to Hybris cacheController.clearCache() within the Groovy script for specific cache clearing.
    def cacheController = spring.getBean("cacheController") cacheController.clearCache()

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/Emenowicz/hybris-mcp'

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