Skip to main content
Glama
smithery-ai

Shopify Update MCP Server

by smithery-ai

update-product-price

Update product prices across all variants using product ID. Modify pricing data in Shopify to reflect changes in inventory costs or promotional adjustments.

Instructions

Update the price of a product by its ID for all variants

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productIdYesID of the product to update
priceYesPrice of the product to update to

Implementation Reference

  • src/index.ts:193-218 (registration)
    MCP tool registration including input schema (zod), description, and thin wrapper handler calling ShopifyClient.updateProductPrice
    server.tool(
      "update-product-price",
      "Update the price of a product by its ID for all variants",
      {
        productId: z.string()
          .describe("ID of the product to update"),
        price: z.string()
        .describe("Price of the product to update to"),
      },
      async ({ productId, price }) => {
        const client = new ShopifyClient();
        try {
          const response = await client.updateProductPrice(
            SHOPIFY_ACCESS_TOKEN,
            MYSHOPIFY_DOMAIN,
            productId,
            price
          );
          return {
            content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
          };
        } catch (error) {
          return handleError("Failed to update product price", error);
        }
      }
    );
  • Core implementation of the price update via GraphQL productUpdate mutation, updating price for all product variants.
    async updateProductPrice(
      accessToken: string,
      shop: string,
      productId: string,
      price: string
    ): Promise<UpdateProductPriceResponse> {
      const myshopifyDomain = await this.getMyShopifyDomain(accessToken, shop);
      
      const graphqlQuery = gql`
        mutation productUpdate($input: ProductInput!) {
          productUpdate(input: $input) {
            product {
              id
              priceRangeV2 {
                minVariantPrice {
                  amount
                  currencyCode
                }
                maxVariantPrice {
                  amount
                  currencyCode
                }
              }
              variants(first: 100) {
                edges {
                  node {
                    id
                    price
                  }
                }
              }
            }
            userErrors {
              field
              message
            }
          }
        }
      `;
    
      const variables = {
        input: {
          id: productId,
          variants: {
            price: price
          }
        }
      };
    
      const res = await this.shopifyGraphqlRequest<{
        data: {
          productUpdate: {
            product: {
              id: string;
              priceRangeV2: {
                minVariantPrice: {amount: string; currencyCode: string};
                maxVariantPrice: {amount: string; currencyCode: string};
              };
              variants: {
                edges: Array<{
                  node: {
                    id: string;
                    price: string;
                  };
                }>;
              };
            };
            userErrors: Array<{field: string; message: string}>;
          };
        };
      }>({
        url: `https://${myshopifyDomain}/admin/api/${this.SHOPIFY_API_VERSION}/graphql.json`,
        accessToken,
        query: graphqlQuery,
        variables
      });
    
      const data = res.data.data;
      
      if (data.productUpdate.userErrors.length > 0) {
        return {
          success: false,
          errors: data.productUpdate.userErrors
        };
      }
    
      return {
        success: true,
        product: data.productUpdate.product
      };
    }
  • Zod input schema for the tool parameters: productId (string) and price (string).
    {
      productId: z.string()
        .describe("ID of the product to update"),
      price: z.string()
      .describe("Price of the product to update to"),
    },
  • TypeScript type definition for the output response of updateProductPrice, including success flag, errors, and updated product details.
    export type UpdateProductPriceResponse ={
      success: boolean;
      errors?: Array<{field: string; message: string}>;
      product?: {
        id: string;
        variants: {
          edges: Array<{
            node: {
              price: string;
            };
          }>;
        };
      };
    }
  • Interface method signature in ShopifyClientPort defining the updateProductPrice method.
    updateProductPrice(
      accessToken: string,
      shop: string,
      productId: string,
      price: string
    ): Promise<UpdateProductPriceResponse>;
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 it's an update operation but doesn't mention permissions required, whether changes are reversible, rate limits, or error conditions. This is a significant gap for a mutation tool.

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. It is front-loaded with the core action and scope, making it easy to parse quickly.

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 this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks behavioral details like side effects, return values, or error handling, which are crucial for safe usage.

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?

Schema description coverage is 100%, so the schema already documents both parameters fully. The description adds no additional meaning beyond what the schema provides, such as price format or ID sourcing. Baseline 3 is appropriate when the schema does the heavy lifting.

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 the action ('Update'), the target resource ('price of a product'), and the scope ('for all variants'), distinguishing it from sibling tools like 'get-products' or 'get-variants-by-ids'. It specifies the verb and resource precisely without being tautological.

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, prerequisites, or exclusions. It lacks context such as whether it applies to draft or published products, or if there are limitations on price changes.

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/smithery-ai/shopify-mcp-server-main-1'

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