Skip to main content
Glama
elgentos

Magento 2 Development MCP Server

by elgentos

setup-static-content-deploy

Deploy static content and assets for Magento 2 stores to specific languages and themes using parallel processing for faster deployment cycles.

Instructions

Deploy Magento 2 static content and assets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
forceNoForce deployment even if files exist
jobsNoNumber of parallel jobs
languagesNoLanguages to deploy (e.g., ['en_US', 'de_DE'])
themesNoThemes to deploy

Implementation Reference

  • The handler function that implements the core logic of the 'setup-static-content-deploy' tool. It builds the magerun2 command with optional inputs for languages, themes, jobs, and force flag, executes it via the shared helper, handles errors, and formats the response.
    async ({ languages, themes, jobs, force }) => { let command = `magerun2 setup:static-content:deploy`; if (languages && languages.length > 0) { command += ` ${languages.join(' ')}`; } if (themes && themes.length > 0) { command += ` --theme=${themes.join(' --theme=')}`; } if (jobs) { command += ` --jobs=${jobs}`; } if (force) { command += ` --force`; } const result = await executeMagerun2Command(command); if (!result.success) { return { content: [{ type: "text", text: result.error }], isError: true }; } return { content: [{ type: "text", text: `Static content deployment completed:\n\n${result.data}` }] }; }
  • The Zod inputSchema defining the parameters for the tool: optional arrays of languages and themes, optional number of jobs, and optional force boolean.
    languages: z.array(z.string()) .optional() .describe("Languages to deploy (e.g., ['en_US', 'de_DE'])"), themes: z.array(z.string()) .optional() .describe("Themes to deploy"), jobs: z.number() .optional() .describe("Number of parallel jobs"), force: z.boolean() .optional() .describe("Force deployment even if files exist") } },
  • src/index.ts:1097-1154 (registration)
    The server.registerTool call that registers the 'setup-static-content-deploy' tool with its schema and handler function.
    "setup-static-content-deploy", { title: "Setup Static Content Deploy", description: "Deploy Magento 2 static content and assets", inputSchema: { languages: z.array(z.string()) .optional() .describe("Languages to deploy (e.g., ['en_US', 'de_DE'])"), themes: z.array(z.string()) .optional() .describe("Themes to deploy"), jobs: z.number() .optional() .describe("Number of parallel jobs"), force: z.boolean() .optional() .describe("Force deployment even if files exist") } }, async ({ languages, themes, jobs, force }) => { let command = `magerun2 setup:static-content:deploy`; if (languages && languages.length > 0) { command += ` ${languages.join(' ')}`; } if (themes && themes.length > 0) { command += ` --theme=${themes.join(' --theme=')}`; } if (jobs) { command += ` --jobs=${jobs}`; } if (force) { command += ` --force`; } const result = await executeMagerun2Command(command); if (!result.success) { return { content: [{ type: "text", text: result.error }], isError: true }; } return { content: [{ type: "text", text: `Static content deployment completed:\n\n${result.data}` }] }; } );
  • Shared helper function used by the tool (and all other magerun2 tools) to execute shell commands safely, with consistent error handling, optional JSON parsing, and specific checks for magerun2 availability and Magento context.
    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 }; } }

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