Skip to main content
Glama

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>;

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