cache-clean
Clear specific Magento 2 cache types or all caches to resolve performance issues and ensure updated content displays correctly.
Instructions
Clear specific Magento 2 cache types or all caches
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| types | No | Specific cache types to clean (leave empty for all caches) |
Implementation Reference
- src/index.ts:158-180 (handler)The handler function for the 'cache-clean' tool. It takes optional cache types, constructs the 'magerun2 cache:clean' command, executes it using executeMagerun2Command, and returns success/error response with output.async ({ types }) => { const cacheTypesArg = types && types.length > 0 ? types.join(' ') : ''; const command = `magerun2 cache:clean ${cacheTypesArg}`.trim(); const result = await executeMagerun2Command(command); if (!result.success) { return { content: [{ type: "text", text: result.error }], isError: true }; } return { content: [{ type: "text", text: `Cache clean completed:\n\n${result.data}` }] }; } );
- src/index.ts:152-156 (schema)Input schema for the 'cache-clean' tool defining an optional array of strings for specific cache types.inputSchema: { types: z.array(z.string()) .optional() .describe("Specific cache types to clean (leave empty for all caches)") }
- src/index.ts:147-180 (registration)Registration of the 'cache-clean' tool with server.registerTool, including title, description, schema, and inline handler function.server.registerTool( "cache-clean", { title: "Cache Clean", description: "Clear specific Magento 2 cache types or all caches", inputSchema: { types: z.array(z.string()) .optional() .describe("Specific cache types to clean (leave empty for all caches)") } }, async ({ types }) => { const cacheTypesArg = types && types.length > 0 ? types.join(' ') : ''; const command = `magerun2 cache:clean ${cacheTypesArg}`.trim(); const result = await executeMagerun2Command(command); if (!result.success) { return { content: [{ type: "text", text: result.error }], isError: true }; } return { content: [{ type: "text", text: `Cache clean completed:\n\n${result.data}` }] }; } );