rolldev_magento2_init
Initialize a new Magento 2 project with automatic version configuration. Specify project name and optionally set Magento version and target directory.
Instructions
Initialize a new Magento 2 project using RollDev's magento2-init command with automatic version configuration
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_name | Yes | Name of the Magento 2 project (lowercase letters, numbers, and hyphens only) | |
| magento_version | No | Magento version to install (default: 2.4.x). Examples: 2.4.x, 2.4.7, 2.4.7-p3, 2.4.8 | 2.4.x |
| target_directory | No | Directory to create project in (optional, defaults to current directory). Project will be created in a subdirectory named after the project. |
Implementation Reference
- server.js:264-288 (registration)Tool definition and input schema registration for rolldev_magento2_init in ListToolsRequestSchema handler
{ name: "rolldev_magento2_init", description: "Initialize a new Magento 2 project using RollDev's magento2-init command with automatic version configuration", inputSchema: { type: "object", properties: { project_name: { type: "string", description: "Name of the Magento 2 project (lowercase letters, numbers, and hyphens only)", }, magento_version: { type: "string", description: "Magento version to install (default: 2.4.x). Examples: 2.4.x, 2.4.7, 2.4.7-p3, 2.4.8", default: "2.4.x", }, target_directory: { type: "string", description: "Directory to create project in (optional, defaults to current directory). Project will be created in a subdirectory named after the project.", default: "", }, }, required: ["project_name"], }, }, - server.js:314-314 (handler)Router case dispatching CallToolRequestSchema to magento2Init handler method
case "rolldev_magento2_init": - server.js:859-931 (handler)Main handler method for rolldev_magento2_init - executes 'roll magento2-init' command with project_name, magento_version, and target_directory arguments, with a 15-minute timeout
async magento2Init(args) { try { const { project_name, magento_version = "2.4.x", target_directory = "", } = args; // Build the command arguments const rollCommand = ["magento2-init", project_name]; if (magento_version) { rollCommand.push(magento_version); } if (target_directory) { rollCommand.push(target_directory); } // Determine working directory (current directory or target_directory) const workingDir = target_directory ? resolve(target_directory) : process.cwd(); // 15 minute timeout for full Magento 2 initialization (very long-running) const timeoutMs = 900000; // Execute the magento2-init command const result = await this.executeCommand( "roll", rollCommand, workingDir, timeoutMs, ); const commandStr = `roll ${rollCommand.join(" ")}`; const isSuccess = result.code === 0; if (isSuccess) { const projectPath = target_directory ? `${resolve(target_directory)}/${project_name}` : `${process.cwd()}/${project_name}`; return { content: [ { type: "text", text: `Magento 2 project '${project_name}' initialized successfully!\n\nCommand: ${commandStr}\nMagento Version: ${magento_version}\nProject Path: ${projectPath}\n\nThe command has automatically:\n- Configured compatible software versions\n- Set up the Docker environment\n- Generated SSL certificates\n- Installed Magento via Composer\n- Configured database, Redis, and search engine\n- Created admin user with 2FA\n- Set developer mode\n\nAccess URLs:\n- Frontend: https://app.${project_name}.test/\n- Admin Panel: https://app.${project_name}.test/shopmanager/\n\nAdmin credentials are saved in admin-credentials.txt in the project directory.\n\nOutput:\n${result.stdout}`, }, ], isError: false, }; } else { return { content: [ { type: "text", text: `Failed to initialize Magento 2 project '${project_name}'!\n\nCommand: ${commandStr}\nExit Code: ${result.code}\n\nError: ${result.stderr || "Unknown error"}\n\nOutput:\n${result.stdout || "(no output)"}`, }, ], isError: true, }; } } catch (error) { return { content: [ { type: "text", text: `Failed to execute Magento 2 initialization:\n\nProject Name: ${args.project_name}\nMagento Version: ${args.magento_version || "2.4.x"}\nError: ${error.message}\n\nOutput:\n${error.stdout || "(no output)"}\n\nErrors:\n${error.stderr || "(no errors)"}`, }, ], isError: true, }; } }