Skip to main content
Glama

get_product

Fetch a product's complete data by GID or numeric ID, returning header fields, inventory totals, images, media, and variants with prices, SKUs, and inventory GIDs for downstream inventory management.

Instructions

Fetch a single product's full record by GID or numeric ID. Returns header fields (title, handle, status, vendor, productType, description, tags), inventory totals, the first 10 images and 10 media items, and the first 20 variants with their prices, SKUs, inventory quantities, and inventoryItem GIDs. Returned as JSON for downstream tooling. The variant inventoryItem GIDs are needed by set_inventory_quantity. For more than 20 variants, follow up with list_variants.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesProduct GID (gid://shopify/Product/123...) or numeric ID

Implementation Reference

  • The get_product tool handler: fetches a product by GID or numeric ID via GraphQL, returns JSON with full product details including variants, images, and media.
    server.tool(
      "get_product",
      "Fetch a single product's full record by GID or numeric ID. Returns header fields (title, handle, status, vendor, productType, description, tags), inventory totals, the first 10 images and 10 media items, and the first 20 variants with their prices, SKUs, inventory quantities, and inventoryItem GIDs. Returned as JSON for downstream tooling. The variant inventoryItem GIDs are needed by set_inventory_quantity. For more than 20 variants, follow up with list_variants.",
      getProductSchema,
      async (args) => {
        const data = await client.graphql<{ product: ProductDetail | null }>(
          GET_PRODUCT_QUERY,
          { id: toGid(args.id, "Product") },
        );
        if (!data.product) {
          return {
            content: [{ type: "text" as const, text: `Product not found: ${args.id}` }],
          };
        }
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(data.product, null, 2),
            },
          ],
        };
      },
    );
  • Input schema for get_product: accepts a single 'id' string parameter (Product GID or numeric ID).
    const getProductSchema = {
      id: z
        .string()
        .describe("Product GID (gid://shopify/Product/123...) or numeric ID"),
    };
  • Registration function registerProductTools is called from src/server.ts line 57 with the MCP server and Shopify client, registering all product tools including get_product.
    export function registerProductTools(
      server: McpServer,
      client: ShopifyClient,
    ): void {
  • GraphQL query used by get_product to fetch full product details including variants, images, and media.
    const GET_PRODUCT_QUERY = /* GraphQL */ `
      query GetProduct($id: ID!) {
        product(id: $id) {
          id
          title
          handle
          status
          vendor
          productType
          description
          tags
          totalInventory
          createdAt
          updatedAt
          featuredImage { url altText }
          images(first: 10) { edges { node { url altText } } }
          variants(first: 20) {
            edges {
              node {
                id
                title
                price
                sku
                inventoryQuantity
                inventoryItem { id }
              }
            }
          }
          media(first: 10) {
            edges { node { id mediaContentType } }
          }
        }
      }
    `;
  • Helper function toGid converts numeric IDs to Shopify GID format (e.g., 'gid://shopify/Product/123'), used by the get_product handler.
    export function toGid(id: string, type: string): string {
      if (id.startsWith("gid://")) return id;
      return `gid://shopify/${type}/${id}`;
    }
Behavior4/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 describes the return data in detail (header fields, inventory totals, first 10 images/media, first 20 variants). It does not explicitly confirm it's read-only, but 'fetch' implies safe read. Additional context on downstream usage adds 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 two sentences, front-loaded with the purpose, and efficiently conveys essential information without any extraneous text.

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

Completeness4/5

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

No output schema exists, so the description must explain return values. It does so by listing header fields, inventory totals, images, media, and variants with details. It also addresses limitations (first 20 variants) and provides follow-up guidance. Missing error handling or edge cases, but adequate for a simple fetch tool.

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% coverage with a detailed description of the 'id' parameter. The description repeats the ID type (GID or numeric) and adds context on return format (JSON), but does not add meaning beyond what the schema already provides. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it fetches a single product's full record by GID or numeric ID. It specifies what data is returned and distinguishes itself from other get_* tools for different resources (e.g., get_collection, get_order).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides guidance on follow-up actions: using variant inventoryItem GIDs for set_inventory_quantity and using list_variants for more than 20 variants. It does not explicitly state when not to use this tool or alternatives like list_products, but the context is clear.

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/miller-joe/shopify-mcp'

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