Skip to main content
Glama
elgentos

Magento 2 Development MCP Server

by elgentos

Config Set

config-set

Set Magento 2 system configuration values for different scopes to customize store settings, manage website configurations, and update store-specific parameters.

Instructions

Set Magento 2 system configuration values

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
encryptNoEncrypt the value
pathYesConfiguration path to set
scopeNoConfiguration scope (default, website, store)
scopeIdNoScope ID (website ID or store ID)
valueYesValue to set

Implementation Reference

  • Handler function that constructs and executes the magerun2 config:set command using the provided configuration path, value, optional scope, scopeId, and encrypt flag. Handles success and error responses appropriately.
    async ({ path, value, scope, scopeId, encrypt }) => {
      let command = `magerun2 config:set "${path}" "${value}"`;
    
      if (scope) {
        command += ` --scope="${scope}"`;
      }
    
      if (scopeId) {
        command += ` --scope-id="${scopeId}"`;
      }
    
      if (encrypt) {
        command += ` --encrypt`;
      }
    
      const result = await executeMagerun2Command(command);
    
      if (!result.success) {
        return {
          content: [{
            type: "text",
            text: result.error
          }],
          isError: true
        };
      }
    
      return {
        content: [{
          type: "text",
          text: `Configuration set successfully:\n\n${result.data}`
        }]
      };
    }
  • Zod input schema defining the parameters for the config-set tool: path (required string), value (required string), scope (optional string), scopeId (optional string), encrypt (optional boolean).
      path: z.string()
        .describe("Configuration path to set"),
      value: z.string()
        .describe("Value to set"),
      scope: z.string()
        .optional()
        .describe("Configuration scope (default, website, store)"),
      scopeId: z.string()
        .optional()
        .describe("Scope ID (website ID or store ID)"),
      encrypt: z.boolean()
        .optional()
        .describe("Encrypt the value")
    }
  • src/index.ts:781-836 (registration)
    Full server.registerTool registration for the 'config-set' tool, including name, schema/spec, and inline handler function.
    server.registerTool(
      "config-set",
      {
        title: "Config Set",
        description: "Set Magento 2 system configuration values",
        inputSchema: {
          path: z.string()
            .describe("Configuration path to set"),
          value: z.string()
            .describe("Value to set"),
          scope: z.string()
            .optional()
            .describe("Configuration scope (default, website, store)"),
          scopeId: z.string()
            .optional()
            .describe("Scope ID (website ID or store ID)"),
          encrypt: z.boolean()
            .optional()
            .describe("Encrypt the value")
        }
      },
      async ({ path, value, scope, scopeId, encrypt }) => {
        let command = `magerun2 config:set "${path}" "${value}"`;
    
        if (scope) {
          command += ` --scope="${scope}"`;
        }
    
        if (scopeId) {
          command += ` --scope-id="${scopeId}"`;
        }
    
        if (encrypt) {
          command += ` --encrypt`;
        }
    
        const result = await executeMagerun2Command(command);
    
        if (!result.success) {
          return {
            content: [{
              type: "text",
              text: result.error
            }],
            isError: true
          };
        }
    
        return {
          content: [{
            type: "text",
            text: `Configuration set successfully:\n\n${result.data}`
          }]
        };
      }
    );
  • Shared helper function executeMagerun2Command that wraps child_process.exec for running magerun2 commands, handles timeouts, stderr logging, optional JSON parsing, and provides Magento-specific error messages.
    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. While 'Set' implies a write/mutation operation, it doesn't specify whether this requires admin permissions, if changes are reversible, potential side effects (e.g., cache invalidation), or error handling. For a configuration mutation tool, this is a significant gap in transparency.

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 gets straight to the point with zero wasted words. It's appropriately sized for a straightforward configuration-setting tool and is perfectly front-loaded with the essential information.

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?

For a configuration mutation tool with no annotations and no output schema, the description is incomplete. It doesn't address what happens after setting values (e.g., cache implications, need for reindexing), doesn't explain the relationship with sibling tools, and provides no information about return values or error conditions.

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, clearly documenting all 5 parameters. The description adds no additional parameter semantics beyond what's already in the schema (e.g., it doesn't explain path format conventions, scope hierarchy, or value encoding). This meets the baseline expectation when schema coverage is complete.

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 verb ('Set') and resource ('Magento 2 system configuration values'), making the purpose immediately understandable. However, it doesn't explicitly distinguish this tool from its sibling 'config-store-set', which appears to serve a similar configuration-setting function, leaving some ambiguity about when to use one versus the other.

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 like 'config-store-set' or other configuration-related tools in the sibling list. It lacks context about prerequisites, typical use cases, or any 'when-not-to-use' scenarios, leaving the agent to infer usage from the tool name alone.

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