Skip to main content
Glama
elgentos

Magento 2 Development MCP Server

by elgentos

URL List

sys-url-list

Retrieve all Magento 2 store URLs in table, JSON, or CSV format. Filter URLs by store ID to manage and access website links for development and testing workflows.

Instructions

Get all Magento 2 URLs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput formattable
storeIdNoStore ID to filter URLs

Implementation Reference

  • The handler function for the 'sys-url-list' tool. It constructs a magerun2 sys:url:list command with optional format (table/json/csv) and storeId filter, executes it using the shared executeMagerun2Command helper, handles errors, and returns formatted text content with the list of URLs.
      let command = `magerun2 sys:url:list --format=${format}`;
    
      if (storeId) {
        command += ` --store-id=${storeId}`;
      }
    
      const result = await executeMagerun2Command(command, format === "json");
    
      if (!result.success) {
        return {
          content: [{
            type: "text",
            text: result.error
          }],
          isError: true
        };
      }
    
      const responseText = format === "json"
        ? `URL list (${format} format):\n\n${JSON.stringify(result.data, null, 2)}`
        : `URL list (${format} format):\n\n${result.data}`;
    
      return {
        content: [{
          type: "text",
          text: responseText
        }]
      };
    }
  • The schema definition for the 'sys-url-list' tool, including title, description, and input schema with format parameter (enum: table/json/csv, default 'table') and optional storeId string.
      title: "URL List",
      description: "Get all Magento 2 URLs",
      inputSchema: {
        format: z.enum(["table", "json", "csv"])
          .default("table")
          .describe("Output format"),
        storeId: z.string()
          .optional()
          .describe("Store ID to filter URLs")
      }
    },
    async ({ format = "table", storeId }) => {
  • src/index.ts:1334-1378 (registration)
    The registration of the 'sys-url-list' tool on the MCP server using server.registerTool, specifying the tool name, schema, and handler function.
      "sys-url-list",
      {
        title: "URL List",
        description: "Get all Magento 2 URLs",
        inputSchema: {
          format: z.enum(["table", "json", "csv"])
            .default("table")
            .describe("Output format"),
          storeId: z.string()
            .optional()
            .describe("Store ID to filter URLs")
        }
      },
      async ({ format = "table", storeId }) => {
        let command = `magerun2 sys:url:list --format=${format}`;
    
        if (storeId) {
          command += ` --store-id=${storeId}`;
        }
    
        const result = await executeMagerun2Command(command, format === "json");
    
        if (!result.success) {
          return {
            content: [{
              type: "text",
              text: result.error
            }],
            isError: true
          };
        }
    
        const responseText = format === "json"
          ? `URL list (${format} format):\n\n${JSON.stringify(result.data, null, 2)}`
          : `URL list (${format} format):\n\n${result.data}`;
    
        return {
          content: [{
            type: "text",
            text: responseText
          }]
        };
      }
    );
  • Shared helper function used by 'sys-url-list' (and other tools) to execute magerun2 commands safely with timeout, stderr logging, JSON parsing option, and custom error messages for common issues like missing magerun2 or non-Magento directory.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Get all Magento 2 URLs' but does not explain what 'all' entails (e.g., pagination, rate limits, permissions required, or whether it's a read-only operation). This leaves significant gaps in understanding the tool's behavior beyond the basic action.

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 with no wasted words, clearly front-loading the core action. It is appropriately sized for the tool's complexity, making it easy to scan and understand quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is minimal but adequate for the basic purpose. It lacks details on behavioral traits and usage context, which would be needed for full completeness, but it suffices as a starting point without being misleading.

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, documenting both parameters ('format' and 'storeId') with details like default values and enums. The description adds no parameter-specific information beyond what the schema provides, so it meets the baseline of 3 without compensating for any gaps.

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 'Get' and the resource 'all Magento 2 URLs', making the purpose specific and understandable. However, it does not differentiate from sibling tools like 'sys-store-config-base-url-list' or 'sys-store-list', which might also retrieve URL-related information, leaving some ambiguity about uniqueness.

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, such as 'sys-store-config-base-url-list' for base URLs or 'sys-store-list' for store details. It lacks explicit when/when-not instructions or prerequisites, offering only a basic action without context.

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