Skip to main content
Glama
elgentos

Magento 2 Development MCP Server

by elgentos

Module Create

dev-module-create

Create and register a new Magento 2 module with customizable components including blocks, helpers, models, and setup files for extending e-commerce functionality.

Instructions

Create and register a new Magento 2 module

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addAllNoAdd blocks, helpers and models
addBlocksNoAdd blocks
addComposerNoAdd a composer.json file to generated module
addHelpersNoAdd helpers
addModelsNoAdd models
addReadmeNoAdd a readme.md file to generated module
addSetupNoAdd SQL setup
addStrictTypesNoAdd strict_types declaration to generated PHP files
authorEmailNoAuthor email for readme.md or composer.json
authorNameNoAuthor for readme.md or composer.json
descriptionNoDescription for readme.md or composer.json
enableNoEnable module after creation
minimalNoCreate only module file
modmanNoCreate all files in folder with a modman file
moduleNameYesName of your module
vendorNamespaceYesNamespace (your company prefix)

Implementation Reference

  • src/index.ts:489-638 (registration)
    Registration of the 'dev-module-create' tool with the MCP server, specifying name, metadata, input schema, and handler function.
    server.registerTool(
      "dev-module-create",
      {
        title: "Module Create",
        description: "Create and register a new Magento 2 module",
        inputSchema: {
          vendorNamespace: z.string()
            .describe("Namespace (your company prefix)"),
          moduleName: z.string()
            .describe("Name of your module"),
          minimal: z.boolean()
            .optional()
            .describe("Create only module file"),
          addBlocks: z.boolean()
            .optional()
            .describe("Add blocks"),
          addHelpers: z.boolean()
            .optional()
            .describe("Add helpers"),
          addModels: z.boolean()
            .optional()
            .describe("Add models"),
          addSetup: z.boolean()
            .optional()
            .describe("Add SQL setup"),
          addAll: z.boolean()
            .optional()
            .describe("Add blocks, helpers and models"),
          enable: z.boolean()
            .optional()
            .describe("Enable module after creation"),
          modman: z.boolean()
            .optional()
            .describe("Create all files in folder with a modman file"),
          addReadme: z.boolean()
            .optional()
            .describe("Add a readme.md file to generated module"),
          addComposer: z.boolean()
            .optional()
            .describe("Add a composer.json file to generated module"),
          addStrictTypes: z.boolean()
            .optional()
            .describe("Add strict_types declaration to generated PHP files"),
          authorName: z.string()
            .optional()
            .describe("Author for readme.md or composer.json"),
          authorEmail: z.string()
            .optional()
            .describe("Author email for readme.md or composer.json"),
          description: z.string()
            .optional()
            .describe("Description for readme.md or composer.json")
        }
      },
      async ({
        vendorNamespace,
        moduleName,
        minimal,
        addBlocks,
        addHelpers,
        addModels,
        addSetup,
        addAll,
        enable,
        modman,
        addReadme,
        addComposer,
        addStrictTypes,
        authorName,
        authorEmail,
        description
      }) => {
        let command = `magerun2 dev:module:create "${vendorNamespace}" "${moduleName}"`;
    
        if (minimal) {
          command += ` --minimal`;
        }
    
        if (addBlocks) {
          command += ` --add-blocks`;
        }
    
        if (addHelpers) {
          command += ` --add-helpers`;
        }
    
        if (addModels) {
          command += ` --add-models`;
        }
    
        if (addSetup) {
          command += ` --add-setup`;
        }
    
        if (addAll) {
          command += ` --add-all`;
        }
    
        if (enable) {
          command += ` --enable`;
        }
    
        if (modman) {
          command += ` --modman`;
        }
    
        if (addReadme) {
          command += ` --add-readme`;
        }
    
        if (addComposer) {
          command += ` --add-composer`;
        }
    
        if (addStrictTypes) {
          command += ` --add-strict-types`;
        }
    
        if (authorName) {
          command += ` --author-name="${authorName}"`;
        }
    
        if (authorEmail) {
          command += ` --author-email="${authorEmail}"`;
        }
    
        if (description) {
          command += ` --description="${description}"`;
        }
    
        const result = await executeMagerun2Command(command);
    
        if (!result.success) {
          return {
            content: [{
              type: "text",
              text: result.error
            }],
            isError: true
          };
        }
    
        return {
          content: [{
            type: "text",
            text: `Module ${vendorNamespace}_${moduleName} created successfully:\n\n${result.data}`
          }]
        };
      }
    );
  • Input schema definition using Zod for validating parameters like vendorNamespace, moduleName, and various optional flags for module creation options.
    inputSchema: {
      vendorNamespace: z.string()
        .describe("Namespace (your company prefix)"),
      moduleName: z.string()
        .describe("Name of your module"),
      minimal: z.boolean()
        .optional()
        .describe("Create only module file"),
      addBlocks: z.boolean()
        .optional()
        .describe("Add blocks"),
      addHelpers: z.boolean()
        .optional()
        .describe("Add helpers"),
      addModels: z.boolean()
        .optional()
        .describe("Add models"),
      addSetup: z.boolean()
        .optional()
        .describe("Add SQL setup"),
      addAll: z.boolean()
        .optional()
        .describe("Add blocks, helpers and models"),
      enable: z.boolean()
        .optional()
        .describe("Enable module after creation"),
      modman: z.boolean()
        .optional()
        .describe("Create all files in folder with a modman file"),
      addReadme: z.boolean()
        .optional()
        .describe("Add a readme.md file to generated module"),
      addComposer: z.boolean()
        .optional()
        .describe("Add a composer.json file to generated module"),
      addStrictTypes: z.boolean()
        .optional()
        .describe("Add strict_types declaration to generated PHP files"),
      authorName: z.string()
        .optional()
        .describe("Author for readme.md or composer.json"),
      authorEmail: z.string()
        .optional()
        .describe("Author email for readme.md or composer.json"),
      description: z.string()
        .optional()
        .describe("Description for readme.md or composer.json")
    }
  • Handler function that builds and executes the 'magerun2 dev:module:create' command with user-provided options, handles errors, and formats the response.
    async ({
      vendorNamespace,
      moduleName,
      minimal,
      addBlocks,
      addHelpers,
      addModels,
      addSetup,
      addAll,
      enable,
      modman,
      addReadme,
      addComposer,
      addStrictTypes,
      authorName,
      authorEmail,
      description
    }) => {
      let command = `magerun2 dev:module:create "${vendorNamespace}" "${moduleName}"`;
    
      if (minimal) {
        command += ` --minimal`;
      }
    
      if (addBlocks) {
        command += ` --add-blocks`;
      }
    
      if (addHelpers) {
        command += ` --add-helpers`;
      }
    
      if (addModels) {
        command += ` --add-models`;
      }
    
      if (addSetup) {
        command += ` --add-setup`;
      }
    
      if (addAll) {
        command += ` --add-all`;
      }
    
      if (enable) {
        command += ` --enable`;
      }
    
      if (modman) {
        command += ` --modman`;
      }
    
      if (addReadme) {
        command += ` --add-readme`;
      }
    
      if (addComposer) {
        command += ` --add-composer`;
      }
    
      if (addStrictTypes) {
        command += ` --add-strict-types`;
      }
    
      if (authorName) {
        command += ` --author-name="${authorName}"`;
      }
    
      if (authorEmail) {
        command += ` --author-email="${authorEmail}"`;
      }
    
      if (description) {
        command += ` --description="${description}"`;
      }
    
      const result = await executeMagerun2Command(command);
    
      if (!result.success) {
        return {
          content: [{
            type: "text",
            text: result.error
          }],
          isError: true
        };
      }
    
      return {
        content: [{
          type: "text",
          text: `Module ${vendorNamespace}_${moduleName} created successfully:\n\n${result.data}`
        }]
      };
    }
  • Shared helper function used by 'dev-module-create' (and other tools) to execute magerun2 commands safely with timeout, error handling, and optional JSON parsing.
    async function executeMagerun2Command(command: string, parseJson: boolean = false): Promise<{
      success: true;
      data: any;
      rawOutput: string;
    } | {
      success: false;
      error: string;
      isError: true;
    }> {
      try {
        const { stdout, stderr } = await execAsync(command, {
          cwd: process.cwd(),
          timeout: 30000 // 30 second timeout
        });
    
        if (stderr && stderr.trim()) {
          console.error("magerun2 stderr:", stderr);
        }
    
        if (parseJson) {
          try {
            return { success: true, data: JSON.parse(stdout), rawOutput: stdout };
          } catch (parseError) {
            return {
              success: false,
              error: `Error parsing magerun2 JSON output: ${parseError}\n\nRaw output:\n${stdout}`,
              isError: true
            };
          }
        }
    
        return { success: true, data: stdout.trim(), rawOutput: stdout };
    
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
    
        // Check if magerun2 is not found
        if (errorMessage.includes("command not found") || errorMessage.includes("not recognized")) {
          return {
            success: false,
            error: "Error: magerun2 command not found. Please ensure n98-magerun2 is installed and available in your PATH.\n\nInstallation instructions: https://github.com/netz98/n98-magerun2",
            isError: true
          };
        }
    
        // Check if not in Magento directory
        if (errorMessage.includes("not a Magento installation") || errorMessage.includes("app/etc/env.php")) {
          return {
            success: false,
            error: "Error: Current directory does not appear to be a Magento 2 installation. Please run this command from your Magento 2 root directory.",
            isError: true
          };
        }
    
        return {
          success: false,
          error: `Error executing magerun2 command: ${errorMessage}`,
          isError: true
        };
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates and registers a module, implying a write operation, but lacks details on permissions, side effects, error handling, or what 'register' entails. This is inadequate for a mutation tool with complex parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (16 parameters, mutation tool) and lack of annotations or output schema, the description is insufficient. It doesn't explain behavioral aspects, return values, or usage context, leaving significant gaps for the agent to understand how to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema fully documents all 16 parameters. The description adds no additional parameter semantics beyond what's in the schema, resulting in a baseline score of 3 as the schema handles the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create and register') and the resource ('new Magento 2 module'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'dev-module-list' or other development tools, which would be needed for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, when it's appropriate compared to other module-related tools, or any exclusions, leaving the agent without context for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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