Skip to main content
Glama
elgentos

Magento 2 Development MCP Server

by elgentos

Get DI Preferences List

get-di-preferences

Retrieve dependency injection preferences for Magento 2 to understand how classes are mapped and overridden across different application scopes.

Instructions

Get Magento 2 dependency injection preferences list using magerun2

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeNoThe scope to get DI preferences forglobal

Implementation Reference

  • The inline anonymous async function that serves as the tool handler. It constructs and executes the magerun2 command for listing DI preferences in the specified scope, handles JSON output, counts entries, and returns formatted text content or an error response.
    async ({ scope = "global" }) => {
      const command = `magerun2 dev:di:preferences:list --format=json ${scope}`;
      const result = await executeMagerun2Command(command, true);
    
      if (!result.success) {
        return {
          content: [{
            type: "text",
            text: result.error
          }],
          isError: true
        };
      }
    
      const preferenceCount = Array.isArray(result.data) ? result.data.length : Object.keys(result.data).length;
    
      return {
        content: [{
          type: "text",
          text: `Found ${preferenceCount} DI preferences for scope '${scope}':\n\n${JSON.stringify(result.data, null, 2)}`
        }]
      };
    }
  • The inputSchema object defining the tool's parameters using Zod schema validation. Includes an optional 'scope' enum with common Magento DI scopes, defaulting to 'global'.
    inputSchema: {
      scope: z.enum([
        "global",
        "adminhtml",
        "frontend",
        "crontab",
        "webapi_rest",
        "webapi_soap",
        "graphql",
        "doc",
        "admin"
      ])
        .default("global")
        .describe("The scope to get DI preferences for")
    }
  • src/index.ts:96-140 (registration)
    The server.registerTool call that registers the 'get-di-preferences' tool with the MCP server, specifying the tool name, metadata (title, description), input schema, and inline handler function.
    server.registerTool(
      "get-di-preferences",
      {
        title: "Get DI Preferences List",
        description: "Get Magento 2 dependency injection preferences list using magerun2",
        inputSchema: {
          scope: z.enum([
            "global",
            "adminhtml",
            "frontend",
            "crontab",
            "webapi_rest",
            "webapi_soap",
            "graphql",
            "doc",
            "admin"
          ])
            .default("global")
            .describe("The scope to get DI preferences for")
        }
      },
      async ({ scope = "global" }) => {
        const command = `magerun2 dev:di:preferences:list --format=json ${scope}`;
        const result = await executeMagerun2Command(command, true);
    
        if (!result.success) {
          return {
            content: [{
              type: "text",
              text: result.error
            }],
            isError: true
          };
        }
    
        const preferenceCount = Array.isArray(result.data) ? result.data.length : Object.keys(result.data).length;
    
        return {
          content: [{
            type: "text",
            text: `Found ${preferenceCount} DI preferences for scope '${scope}':\n\n${JSON.stringify(result.data, null, 2)}`
          }]
        };
      }
    );
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. It states this is a 'Get' operation, implying read-only behavior, but doesn't clarify if it requires specific permissions, has side effects (e.g., caching), rate limits, or what the output format looks like (list structure, pagination). For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 front-loads the core purpose without unnecessary words. Every element ('Get', 'Magento 2 dependency injection preferences list', 'using magerun2') earns its place by specifying the action, resource, and method concisely.

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 (retrieving DI preferences with scope filtering), no annotations, and no output schema, the description is minimally adequate. It identifies the tool's purpose and method but lacks details on behavior, output format, and usage context. The high schema coverage for the single parameter helps, but overall completeness is limited for effective agent use.

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, with the single parameter 'scope' fully documented including enum values and default. The description adds no additional parameter semantics beyond what the schema provides, such as explaining what 'scope' means in the context of DI preferences or how different scopes affect results. This meets the baseline of 3 given high schema coverage.

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 action ('Get') and resource ('Magento 2 dependency injection preferences list') with the specific method ('using magerun2'). It distinguishes from siblings by focusing on DI preferences rather than cache, config, or system operations. However, it doesn't explicitly differentiate from potential similar tools like 'config-show' or 'dev-module-list' that might also retrieve configuration data.

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. It doesn't mention prerequisites (e.g., requiring magerun2 installation), typical use cases (e.g., debugging DI issues), or when other tools like 'config-show' might be more appropriate for related configuration queries.

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