Skip to main content
Glama
elgentos

Magento 2 Development MCP Server

by elgentos

setup-upgrade

Update Magento 2 database schema and data to apply system changes and maintain database integrity during development.

Instructions

Run Magento 2 setup upgrade to update database schema and data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keepGeneratedNoKeep generated files during upgrade

Implementation Reference

  • The handler function executes the 'magerun2 setup:upgrade' command, optionally appending '--keep-generated' if specified, calls executeMagerun2Command, and returns formatted success or error content.
    async ({ keepGenerated }) => {
      let command = `magerun2 setup:upgrade`;
    
      if (keepGenerated) {
        command += ` --keep-generated`;
      }
    
      const result = await executeMagerun2Command(command);
    
      if (!result.success) {
        return {
          content: [{
            type: "text",
            text: result.error
          }],
          isError: true
        };
      }
    
      return {
        content: [{
          type: "text",
          text: `Setup upgrade completed:\n\n${result.data}`
        }]
      };
    }
  • Input schema defining optional 'keepGenerated' boolean parameter for keeping generated files.
    inputSchema: {
      keepGenerated: z.boolean()
        .optional()
        .describe("Keep generated files during upgrade")
    }
  • src/index.ts:982-1019 (registration)
    Registration of the 'setup-upgrade' tool with server.registerTool, specifying name, title, description, input schema, and inline handler function.
    server.registerTool(
      "setup-upgrade",
      {
        title: "Setup Upgrade",
        description: "Run Magento 2 setup upgrade to update database schema and data",
        inputSchema: {
          keepGenerated: z.boolean()
            .optional()
            .describe("Keep generated files during upgrade")
        }
      },
      async ({ keepGenerated }) => {
        let command = `magerun2 setup:upgrade`;
    
        if (keepGenerated) {
          command += ` --keep-generated`;
        }
    
        const result = await executeMagerun2Command(command);
    
        if (!result.success) {
          return {
            content: [{
              type: "text",
              text: result.error
            }],
            isError: true
          };
        }
    
        return {
          content: [{
            type: "text",
            text: `Setup upgrade 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