Skip to main content
Glama
boldcommerce

Magento 2 MCP Server

by boldcommerce

get_product_attributes

Retrieve all product attributes from a Magento 2 store using the product SKU to access detailed specifications and properties.

Instructions

Get all attributes for a product by SKU

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
skuYesThe SKU (Stock Keeping Unit) of the product

Implementation Reference

  • The handler function that implements the core logic of the get_product_attributes tool. It fetches the product data from the Magento API using the provided SKU, extracts both base attributes and custom attributes, formats them into a structured object, and returns the JSON stringified response or an error message.
    async ({ sku }) => {
      try {
        const productData = await callMagentoApi(`/products/${sku}`);
        
        // Extract and format attributes
        const attributes = {
          base_attributes: {
            id: productData.id,
            sku: productData.sku,
            name: productData.name,
            price: productData.price,
            status: productData.status,
            visibility: productData.visibility,
            type_id: productData.type_id
          },
          custom_attributes: {}
        };
        
        if (productData.custom_attributes && Array.isArray(productData.custom_attributes)) {
          productData.custom_attributes.forEach(attr => {
            attributes.custom_attributes[attr.attribute_code] = attr.value;
          });
        }
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(attributes, null, 2)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error fetching product attributes: ${error.message}`
            }
          ],
          isError: true
        };
      }
    }
  • The input schema defined using Zod for the get_product_attributes tool, specifying that it requires a 'sku' parameter as a string.
      sku: z.string().describe("The SKU (Stock Keeping Unit) of the product")
    },
  • mcp-server.js:619-669 (registration)
    The registration of the get_product_attributes tool with the MCP server, including the tool name, description, input schema, and handler function reference.
    server.tool(
      "get_product_attributes",
      "Get all attributes for a product by SKU",
      {
        sku: z.string().describe("The SKU (Stock Keeping Unit) of the product")
      },
      async ({ sku }) => {
        try {
          const productData = await callMagentoApi(`/products/${sku}`);
          
          // Extract and format attributes
          const attributes = {
            base_attributes: {
              id: productData.id,
              sku: productData.sku,
              name: productData.name,
              price: productData.price,
              status: productData.status,
              visibility: productData.visibility,
              type_id: productData.type_id
            },
            custom_attributes: {}
          };
          
          if (productData.custom_attributes && Array.isArray(productData.custom_attributes)) {
            productData.custom_attributes.forEach(attr => {
              attributes.custom_attributes[attr.attribute_code] = attr.value;
            });
          }
          
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(attributes, null, 2)
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error fetching product attributes: ${error.message}`
              }
            ],
            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 full burden. It implies a read operation ('Get') but doesn't disclose behavioral traits such as authentication needs, rate limits, error handling, or what 'all attributes' entails (e.g., format, data types). This is a significant gap for a tool with no annotation coverage.

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 zero waste, front-loading the core action and resource. It's appropriately sized for a simple tool, earning full marks for conciseness.

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?

Given no annotations, no output schema, and multiple sibling tools, the description is incomplete. It lacks details on return values, error cases, and usage context, making it inadequate for an agent to confidently invoke this tool without additional assumptions.

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 description adds minimal meaning beyond the input schema, which has 100% coverage and documents the 'sku' parameter well. It clarifies that attributes are retrieved 'by SKU', but this is redundant with the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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 resource ('all attributes for a product'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_product_by_sku' or 'update_product_attribute', which could handle similar product data, so it misses the highest score.

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. With siblings like 'get_product_by_sku' and 'search_products' available, there's no indication of context, prerequisites, or exclusions, leaving the agent to guess based on tool names 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/boldcommerce/magento2-mcp'

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