cache-flush
Flush specific Magento 2 cache types or clear all caches to resolve caching issues and ensure updated content displays correctly.
Instructions
Flush specific Magento 2 cache types or all caches
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| types | No | Specific cache types to flush (leave empty for all caches) |
Implementation Reference
- src/index.ts:198-219 (handler)The handler function that executes the `magerun2 cache:flush` command, handling optional cache types input, running the command via executeMagerun2Command, and returning formatted success or error responses.async ({ types }) => { const cacheTypesArg = types && types.length > 0 ? types.join(' ') : ''; const command = `magerun2 cache:flush ${cacheTypesArg}`.trim(); const result = await executeMagerun2Command(command); if (!result.success) { return { content: [{ type: "text", text: result.error }], isError: result.isError }; } return { content: [{ type: "text", text: `Cache flush completed:\n\n${result.data}` }] }; }
- src/index.ts:192-196 (schema)Input schema defining optional array of cache types to flush using Zod validation.inputSchema: { types: z.array(z.string()) .optional() .describe("Specific cache types to flush (leave empty for all caches)") }
- src/index.ts:187-220 (registration)Registration of the 'cache-flush' tool with server.registerTool, including title, description, input schema, and inline handler function.server.registerTool( "cache-flush", { title: "Cache Flush", description: "Flush specific Magento 2 cache types or all caches", inputSchema: { types: z.array(z.string()) .optional() .describe("Specific cache types to flush (leave empty for all caches)") } }, async ({ types }) => { const cacheTypesArg = types && types.length > 0 ? types.join(' ') : ''; const command = `magerun2 cache:flush ${cacheTypesArg}`.trim(); const result = await executeMagerun2Command(command); if (!result.success) { return { content: [{ type: "text", text: result.error }], isError: result.isError }; } return { content: [{ type: "text", text: `Cache flush completed:\n\n${result.data}` }] }; } );