Skip to main content
Glama

warden_init_project

Initialize a new Magento 2 development environment with Warden by setting up PHP, MySQL, Node.js, Redis, and other required services for local development.

Instructions

Initialize a new Warden project with Magento 2 environment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYesPath where the project should be initialized
project_nameYesName for the Warden environment
environment_typeNoEnvironment type (default: magento2)magento2
php_versionNoPHP version (default: 8.3)8.3
mysql_distributionNoMySQL distribution (default: mariadb)mariadb
mysql_versionNoMySQL version (default: 10.6)10.6
node_versionNoNode.js version (default: 20)20
composer_versionNoComposer version (default: 2)2
opensearch_versionNoOpenSearch version (default: 2.12)2.12
redis_versionNoRedis version (default: 7.2)7.2
enable_redisNoEnable Redis (default: true)
enable_opensearchNoEnable OpenSearch (default: true)
enable_varnishNoEnable Varnish (default: true)
enable_rabbitmqNoEnable RabbitMQ (default: true)
enable_xdebugNoEnable Xdebug (default: true)

Implementation Reference

  • The function that executes the 'warden_init_project' tool logic. It creates the project directory, runs 'warden env init' command, updates the .env file with provided configuration parameters like versions and enabled services, and returns structured success or error response.
    async initProject(args) { try { const { project_path, project_name, environment_type = "magento2", php_version = "8.3", mysql_distribution = "mariadb", mysql_version = "10.6", node_version = "20", composer_version = "2", opensearch_version = "2.12", redis_version = "7.2", enable_redis = true, enable_opensearch = true, enable_varnish = true, enable_rabbitmq = true, enable_xdebug = true, } = args; const absoluteProjectPath = resolve(project_path); // Create project directory if it doesn't exist execSync(`mkdir -p "${absoluteProjectPath}"`); // Change to project directory and initialize warden environment const result = await this.executeCommand( "warden", ["env", "init", project_name, environment_type], absoluteProjectPath, ); if (result.code !== 0) { throw new Error(`Warden init failed: ${result.stderr}`); } // Read the generated .env file and update it with custom parameters const envFilePath = join(absoluteProjectPath, ".env"); if (existsSync(envFilePath)) { let envContent = readFileSync(envFilePath, "utf8"); // Update environment variables const updates = { PHP_VERSION: php_version, MYSQL_DISTRIBUTION: mysql_distribution, MYSQL_DISTRIBUTION_VERSION: mysql_version, NODE_VERSION: node_version, COMPOSER_VERSION: composer_version, OPENSEARCH_VERSION: opensearch_version, REDIS_VERSION: redis_version, WARDEN_REDIS: enable_redis ? "1" : "0", WARDEN_OPENSEARCH: enable_opensearch ? "1" : "0", WARDEN_VARNISH: enable_varnish ? "1" : "0", WARDEN_RABBITMQ: enable_rabbitmq ? "1" : "0", PHP_XDEBUG_3: enable_xdebug ? "1" : "0", }; // Update each environment variable for (const [key, value] of Object.entries(updates)) { const regex = new RegExp(`^${key}=.*$`, "m"); if (envContent.match(regex)) { envContent = envContent.replace(regex, `${key}=${value}`); } else { envContent += `\n${key}=${value}`; } } writeFileSync(envFilePath, envContent); } return { content: [ { type: "text", text: `Warden project initialized successfully!\n\nProject Path: ${absoluteProjectPath}\nProject Name: ${project_name}\nEnvironment Type: ${environment_type}\n\nConfiguration:\n- PHP Version: ${php_version}\n- MySQL: ${mysql_distribution} ${mysql_version}\n- Node.js: ${node_version}\n- Composer: ${composer_version}\n- OpenSearch: ${opensearch_version} (${enable_opensearch ? "enabled" : "disabled"})\n- Redis: ${redis_version} (${enable_redis ? "enabled" : "disabled"})\n- Varnish: ${enable_varnish ? "enabled" : "disabled"}\n- RabbitMQ: ${enable_rabbitmq ? "enabled" : "disabled"}\n- Xdebug: ${enable_xdebug ? "enabled" : "disabled"}\n\nNext steps:\n1. Navigate to: ${absoluteProjectPath}\n2. Run: warden env up\n3. Your environment will be available at: https://${project_name}.test\n\nOutput:\n${result.stdout}`, }, ], isError: false, }; } catch (error) { return { content: [ { type: "text", text: `Failed to initialize Warden project:\n\nProject Path: ${args.project_path}\nProject Name: ${args.project_name}\nError: ${error.message}\n\nOutput:\n${error.stdout || "(no output)"}\n\nErrors:\n${error.stderr || "(no errors)"}`, }, ], isError: true, }; } }
  • Input schema definition for the 'warden_init_project' tool, specifying parameters like project_path, project_name, versions for PHP/MySQL/Node/etc., and booleans to enable services like Redis, OpenSearch, Varnish.
    inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path where the project should be initialized", }, project_name: { type: "string", description: "Name for the Warden environment", }, environment_type: { type: "string", description: "Environment type (default: magento2)", default: "magento2", }, php_version: { type: "string", description: "PHP version (default: 8.3)", default: "8.3", }, mysql_distribution: { type: "string", description: "MySQL distribution (default: mariadb)", default: "mariadb", }, mysql_version: { type: "string", description: "MySQL version (default: 10.6)", default: "10.6", }, node_version: { type: "string", description: "Node.js version (default: 20)", default: "20", }, composer_version: { type: "string", description: "Composer version (default: 2)", default: "2", }, opensearch_version: { type: "string", description: "OpenSearch version (default: 2.12)", default: "2.12", }, redis_version: { type: "string", description: "Redis version (default: 7.2)", default: "7.2", }, enable_redis: { type: "boolean", description: "Enable Redis (default: true)", default: true, }, enable_opensearch: { type: "boolean", description: "Enable OpenSearch (default: true)", default: true, }, enable_varnish: { type: "boolean", description: "Enable Varnish (default: true)", default: true, }, enable_rabbitmq: { type: "boolean", description: "Enable RabbitMQ (default: true)", default: true, }, enable_xdebug: { type: "boolean", description: "Enable Xdebug (default: true)", default: true, }, }, required: ["project_path", "project_name"], },
  • server.js:231-314 (registration)
    Tool registration in the ListToolsRequestSchema handler, providing name, description, and input schema for discovery.
    { name: "warden_init_project", description: "Initialize a new Warden project with Magento 2 environment", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "Path where the project should be initialized", }, project_name: { type: "string", description: "Name for the Warden environment", }, environment_type: { type: "string", description: "Environment type (default: magento2)", default: "magento2", }, php_version: { type: "string", description: "PHP version (default: 8.3)", default: "8.3", }, mysql_distribution: { type: "string", description: "MySQL distribution (default: mariadb)", default: "mariadb", }, mysql_version: { type: "string", description: "MySQL version (default: 10.6)", default: "10.6", }, node_version: { type: "string", description: "Node.js version (default: 20)", default: "20", }, composer_version: { type: "string", description: "Composer version (default: 2)", default: "2", }, opensearch_version: { type: "string", description: "OpenSearch version (default: 2.12)", default: "2.12", }, redis_version: { type: "string", description: "Redis version (default: 7.2)", default: "7.2", }, enable_redis: { type: "boolean", description: "Enable Redis (default: true)", default: true, }, enable_opensearch: { type: "boolean", description: "Enable OpenSearch (default: true)", default: true, }, enable_varnish: { type: "boolean", description: "Enable Varnish (default: true)", default: true, }, enable_rabbitmq: { type: "boolean", description: "Enable RabbitMQ (default: true)", default: true, }, enable_xdebug: { type: "boolean", description: "Enable Xdebug (default: true)", default: true, }, }, required: ["project_path", "project_name"], }, },
  • server.js:341-342 (registration)
    Handler dispatch registration in the CallToolRequestSchema switch statement, mapping the tool name to the initProject method.
    case "warden_init_project": return await this.initProject(request.params.arguments);

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/run-as-root/warden-mcp-server'

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