Skip to main content
Glama
elgentos

Magento 2 Development MCP Server

by elgentos

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
NameRequiredDescriptionDefault
typesNoSpecific cache types to clean (leave empty for all caches)

Implementation Reference

  • 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}`
          }]
        };
      }
    );
  • 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}`
          }]
        };
      }
    );

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/elgentos/magento2-dev-mcp'

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