Search the Shopify Catalog
Agentic commerce is rolling out to Dev Dashboard. Sign up to be notified.
Shopify Catalog contains all eligible products sold across merchants on the Shopify platform. You can use the Catalog MCP server to search for products and retrieve detailed product information for your AI agent.
This tutorial shows you how to authenticate with the Catalog MCP server, search for products, and apply filters to refine results.
Anchor to What you'll learnWhat you'll learn
In this tutorial, you'll learn how to do the following tasks:
- Generate API credentials from Shopify to authenticate with the Catalog MCP server
- Search for products across the global Shopify Catalog using natural language queries
- Apply filters and parameters to refine product search results
- Extract product variant IDs and shop domains for checkout
Anchor to RequirementsRequirements
- Shopify Partner account to access Partner Dashboard and generate API credentials
- Node.js installed on your development machine
Anchor to Step 1: Generate API credentialsStep 1: Generate API credentials
Get your client credentials and generate API keys to authenticate with the Catalog MCP server.
-
Obtain your client credentials (client ID and secret) from the Catalogs section of Dev Dashboard.

-
Make a
POSTrequest to the token endpoint to generate a bearer token you'll use for subsequent requests:Terminal
curl --request POST \--url https://api.shopify.com/auth/access_token \--header 'Content-Type: application/json' \--data '{"client_id": "{your_client_id}","client_secret": "{your_client_secret}","grant_type": "client_credentials"}' -
Create a
.envfile and add your token:.env
BEARER_TOKEN={your_token}
Anchor to Step 2: Search the CatalogStep 2: Search the Catalog
Create a script that sends a query to the Catalog MCP server to search for products using the search_global_products tool.
-
Create a
search-catalog.jsfile that sends a query to the Catalog MCP server:import 'dotenv/config';const bearerToken = process.env.BEARER_TOKEN;fetch('https://discover.shopifyapps.com/global/mcp', {method: 'POST',headers: {'Content-Type': 'application/json','Authorization': `Bearer ${bearerToken}`},body: JSON.stringify({jsonrpc: '2.0',method: 'tools/call',id: 1,params: {name: 'search_global_products',arguments: {query: 'I need a crewneck sweater',context: 'buyer looking for sustainable fashion',limit: 3}}})}).then(res => res.json()).then(data => {// Parse the text field to get the actual offers objectif (data.result && data.result.content && data.result.content[0]) {const offersData = JSON.parse(data.result.content[0].text);console.log(JSON.stringify(offersData, null, 2));}});{"offers": [{"id": "gid://shopify/p/abc123XYZ789defGHI456jk","title": "Classic Crewneck Sweatshirt","description": "A comfortable everyday sweatshirt with a classic fit and soft cotton-polyester blend.","images": [{"url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck.webp?v=1700000001","altText": "Classic Crewneck Sweatshirt","product": {"id": "gid://shopify/Product/1000000000001","title": "Classic Crewneck Sweatshirt","onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456","shop": {"name": "Mock Shop","onlineStoreUrl": "https://mock.shop"}}}],"options": [{"name": "Color","values": [{"value": "Heather Gray","availableForSale": true,"exists": true}]},{"name": "Size","values": [{search-catalog.js
import 'dotenv/config'; const bearerToken = process.env.BEARER_TOKEN; fetch('https://discover.shopifyapps.com/global/mcp', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${bearerToken}` }, body: JSON.stringify({ jsonrpc: '2.0', method: 'tools/call', id: 1, params: { name: 'search_global_products', arguments: { query: 'I need a crewneck sweater', context: 'buyer looking for sustainable fashion', limit: 3 } } }) }) .then(res => res.json()) .then(data => { // Parse the text field to get the actual offers object if (data.result && data.result.content && data.result.content[0]) { const offersData = JSON.parse(data.result.content[0].text); console.log(JSON.stringify(offersData, null, 2)); } });{} Response
{ "offers": [ { "id": "gid://shopify/p/abc123XYZ789defGHI456jk", "title": "Classic Crewneck Sweatshirt", "description": "A comfortable everyday sweatshirt with a classic fit and soft cotton-polyester blend.", "images": [ { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck.webp?v=1700000001", "altText": "Classic Crewneck Sweatshirt", "product": { "id": "gid://shopify/Product/1000000000001", "title": "Classic Crewneck Sweatshirt", "onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456", "shop": { "name": "Mock Shop", "onlineStoreUrl": "https://mock.shop" } } } ], "options": [ { "name": "Color", "values": [ { "value": "Heather Gray", "availableForSale": true, "exists": true } ] }, { "name": "Size", "values": [ { "value": "Medium", "availableForSale": true, "exists": true } ] } ], "priceRange": { "min": { "amount": "45.00", "currencyCode": "USD" }, "max": { "amount": "45.00", "currencyCode": "USD" } }, "products": [ { "id": "gid://shopify/Product/1000000000001", "title": "Classic Crewneck Sweatshirt", "checkoutUrl": "https://mock.shop/cart/2000000000001:1?_gsid=abc123def456&payment=shop_pay", "description": "A comfortable everyday sweatshirt with a classic fit. Made from a soft cotton-polyester blend, this versatile piece features ribbed cuffs and hem for a secure fit. Perfect for layering or wearing on its own.", "featuredImage": { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck.webp?v=1700000001", "altText": "Classic Crewneck Sweatshirt" }, "onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456", "price": { "amount": "45.00", "currencyCode": "USD" }, "rating": null, "availableForSale": true, "shop": { "name": "Mock Shop", "paymentSettings": { "supportedDigitalWallets": [ "SHOPIFY_PAY" ], "acceptedCardBrands": [ "visa", "master", "american_express", "discover", "diners_club", "visadebit", "masterdebit" ] }, "onlineStoreUrl": "https://mock.shop", "privacyPolicy": { "url": "https://checkout.shopify.com/10000000001/policies/20000000001.html?locale=en" }, "refundPolicy": { "url": "https://checkout.shopify.com/10000000001/policies/20000000002.html?locale=en" }, "termsOfService": { "url": "https://checkout.shopify.com/10000000001/policies/20000000003.html?locale=en" }, "shippingPolicy": { "url": "https://checkout.shopify.com/10000000001/policies/20000000004.html?locale=en" }, "id": "gid://shopify/Shop/10000000001", "permanentDomain": "mock-shop.myshopify.com" }, "selectedProductVariant": { "id": "gid://shopify/ProductVariant/2000000000001?shop=10000000001", "availableForSale": true, "options": [ { "name": "Color", "value": "Heather Gray" }, { "name": "Size", "value": "Medium" } ], "price": { "amount": "45.00", "currencyCode": "USD" }, "image": { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck.webp?v=1700000001", "altText": "Classic Crewneck Sweatshirt" } }, "secondhand": false, "requiresSellingPlan": false, "eligibleForNativeCheckout": false } ], "availableForSale": true, "rating": null, "inferredFields": [ "options", "products.secondhand", "products.selectedProductVariant.options", "techSpecs", "sharedAttributes", "uniqueSellingPoint", "topFeatures" ], "uniqueSellingPoint": "Features a soft cotton-polyester blend with ribbed details for comfort and durability.", "topFeatures": [ "50/50 cotton polyester blend provides softness and durability for daily wear", "Classic crewneck design suitable for layering or standalone wear", "Ribbed collar, cuffs, and hem ensure a secure, comfortable fit", "Pre-shrunk fabric maintains shape after washing", "Available in multiple colors and sizes" ], "techSpecs": [ "Weight: 8.0 oz", "Material: 50% cotton, 50% polyester", "Neckline: Crew", "Pattern: Solid", "Available Sizes: S, M, L, XL, 2XL", "Colors: Heather Gray, Navy, Black, White" ], "sharedAttributes": [ { "name": "Fabric", "values": [ "Cotton", "Polyester" ] }, { "name": "Neckline", "values": [ "Crew" ] }, { "name": "Pattern", "values": [ "Solid" ] }, { "name": "Age group", "values": [ "Adults" ] }, { "name": "Target gender", "values": [ "Unisex" ] }, { "name": "Top length type", "values": [ "Medium" ] }, { "name": "Size", "values": [ "Medium (M)" ] }, { "name": "Color", "values": [ "Gray" ] } ], "url": "https://discover.shopifyapps.com/global/v1/p/abc123XYZ789defGHI456jk?_gsid=abc123def456&available_for_sale=1&product_id=1000000000001&query=sweatshirts&ships_to=US&variant_id=2000000000001" }, { "id": "gid://shopify/p/xyz789ABC456mnoPQR123st", "title": "Premium Pullover Hoodie", "description": "A cozy pullover hoodie with kangaroo pocket and drawstring hood for versatile everyday wear.", "images": [ { "url": "https://cdn.shopify.com/s/files/1/0000/0002/0003/files/premium-hoodie.webp?v=1700000005", "altText": "Premium Pullover Hoodie", "product": { "id": "gid://shopify/Product/1000000000003", "title": "Premium Pullover Hoodie", "onlineStoreUrl": "https://shopify.supply/products/premium-pullover-hoodie?variant=2000000000003&_gsid=def456ghi789", "shop": { "name": "Shopify Supply", "onlineStoreUrl": "https://shopify.supply" } } } ], "options": [ { "name": "Color", "values": [ { "value": "Navy", "availableForSale": true, "exists": true }, { "value": "Black", "availableForSale": true, "exists": true }, { "value": "Heather Gray", "availableForSale": true, "exists": true } ] }, { "name": "Size", "values": [ { "value": "Small", "availableForSale": true, "exists": true }, { "value": "Medium", "availableForSale": true, "exists": true }, { "value": "Large", "availableForSale": true, "exists": true } ] } ], "priceRange": { "min": { "amount": "55.00", "currencyCode": "USD" }, "max": { "amount": "65.00", "currencyCode": "USD" } }, "products": [ { "id": "gid://shopify/Product/1000000000003", "title": "Premium Pullover Hoodie", "checkoutUrl": "https://shopify.supply/cart/2000000000003:1?_gsid=def456ghi789&payment=shop_pay", "description": "A cozy pullover hoodie with kangaroo pocket and adjustable drawstring hood. Made from soft fleece blend fabric for warmth and comfort.", "featuredImage": { "url": "https://cdn.shopify.com/s/files/1/0000/0002/0003/files/premium-hoodie.webp?v=1700000005", "altText": "Premium Pullover Hoodie" }, "onlineStoreUrl": "https://shopify.supply/products/premium-pullover-hoodie?variant=2000000000003&_gsid=def456ghi789", "price": { "amount": "55.00", "currencyCode": "USD" }, "rating": { "value": 4.8, "count": 124 }, "availableForSale": true, "shop": { "name": "Shopify Supply", "paymentSettings": { "supportedDigitalWallets": [ "SHOPIFY_PAY" ], "acceptedCardBrands": [ "visa", "master", "american_express", "discover", "diners_club", "visadebit", "masterdebit" ] }, "onlineStoreUrl": "https://shopify.supply", "privacyPolicy": { "url": "https://checkout.shopify.com/10000000002/policies/20000000005.html?locale=en" }, "refundPolicy": { "url": "https://checkout.shopify.com/10000000002/policies/20000000006.html?locale=en" }, "termsOfService": { "url": "https://checkout.shopify.com/10000000002/policies/20000000007.html?locale=en" }, "shippingPolicy": { "url": "https://checkout.shopify.com/10000000002/policies/20000000008.html?locale=en" }, "id": "gid://shopify/Shop/10000000002", "permanentDomain": "shopify-supply.myshopify.com" }, "selectedProductVariant": { "id": "gid://shopify/ProductVariant/2000000000003?shop=10000000002", "availableForSale": true, "options": [ { "name": "Color", "value": "Navy" }, { "name": "Size", "value": "Large" } ], "price": { "amount": "55.00", "currencyCode": "USD" }, "image": { "url": "https://cdn.shopify.com/s/files/1/0000/0002/0003/files/premium-hoodie.webp?v=1700000005", "altText": "Premium Pullover Hoodie" } }, "secondhand": false, "requiresSellingPlan": false, "eligibleForNativeCheckout": false } ], "availableForSale": true, "rating": { "value": 4.8, "count": 124 }, "inferredFields": [ "options", "products.secondhand", "products.selectedProductVariant.options", "techSpecs", "sharedAttributes", "uniqueSellingPoint", "topFeatures" ], "uniqueSellingPoint": "Premium fleece blend with kangaroo pocket provides warmth and convenience.", "topFeatures": [ "Soft fleece blend fabric provides warmth and comfort", "Kangaroo pocket offers convenient storage", "Adjustable drawstring hood for customizable fit", "Ribbed cuffs and hem retain shape", "Available in classic colors" ], "techSpecs": [ "Weight: 10.0 oz", "Material: 60% cotton, 40% polyester", "Neckline: Hooded", "Pattern: Solid", "Available Sizes: S, M, L, XL", "Colors: Navy, Black, Heather Gray" ], "sharedAttributes": [ { "name": "Fabric", "values": [ "Cotton", "Polyester", "Fleece" ] }, { "name": "Neckline", "values": [ "Hooded" ] }, { "name": "Pattern", "values": [ "Solid" ] }, { "name": "Age group", "values": [ "Adults" ] }, { "name": "Target gender", "values": [ "Unisex" ] }, { "name": "Top length type", "values": [ "Medium" ] }, { "name": "Size", "values": [ "Large (L)" ] }, { "name": "Color", "values": [ "Blue" ] } ], "url": "https://discover.shopifyapps.com/global/v1/p/xyz789ABC456mnoPQR123st?_gsid=def456ghi789&available_for_sale=1&product_id=1000000000003&query=sweatshirts&ships_to=US&variant_id=2000000000003" } ], "instructions": "Use markdown to render product titles as links to their respective product pages using the URL property.\n" } -
Execute the script from your terminal:
Terminal
node search-catalog.jsThe response includes product titles, descriptions, pricing, images, and detailed variant information for each matching product. You can use data from the returned
UniversalProductresource to display custom components, so that buyers can interact with individual products. For example:let response = JSON.parse(data.result.content[0].text);let offer = response.offers[buyerSelectedIndex];// Extract product datalet product = {title: offer.title,price: offer.priceRange.min.amount,currency: offer.priceRange.min.currencyCode,image: offer.images[0]?.url,url: offer.url};let card = `<div class="product-card"><img src="${product.image}" alt="${product.title}" /><h3>${product.title}</h3><p>${product.currency} $${parseFloat(product.price).toFixed(2)}</p><a href="${product.url}">View Product</a></div>`;InfoYou can create custom catalogs in Dev Dashboard that allow you to narrow results down to those most relevant to the goals of your agent, which will change the endpoint URLs needed to connect to the MCP server. Learn more about saved catalogs in Dev Dashboard.
Anchor to Step 3: Apply query parametersStep 3: Apply query parameters
Buyers can supply additional context that can be used to refine your catalog search by adding filters for price, shipping location, availability, and other criteria.
-
Limit results to products within a specific price range, that ships to a specific country, and that can be second hand items:
import 'dotenv/config';const bearerToken = process.env.BEARER_TOKEN;fetch('https://discover.shopifyapps.com/global/mcp', {method: 'POST',headers: {'Content-Type': 'application/json','Authorization': `Bearer ${bearerToken}`},body: JSON.stringify({jsonrpc: '2.0',method: 'tools/call',id: 1,params: {name: 'search_global_products',arguments: {query: 'I need a crewneck sweater',context: 'buyer looking for sustainable fashion',include_secondhand: true,min_price: 50,max_price: 200,ships_to: 'US',limit: 3}}})}).then(res => res.json()).then(data => {// Parse the text field to get the actual offers objectif (data.result && data.result.content && data.result.content[0]) {const offersData = JSON.parse(data.result.content[0].text);console.log(JSON.stringify(offersData, null, 2));}});{"offers": [{"id": "gid://shopify/p/abc123XYZ789defGHI456jk","title": "Classic Crewneck Sweatshirt","description": "A comfortable everyday sweatshirt with a classic fit and soft cotton-polyester blend.","images": [{"url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck.webp?v=1700000001","altText": "Classic Crewneck Sweatshirt","product": {"id": "gid://shopify/Product/1000000000001","title": "Classic Crewneck Sweatshirt","onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456","shop": {"name": "Mock Shop","onlineStoreUrl": "https://mock.shop"}}}],"options": [{"name": "Color","values": [{"value": "Heather Gray","availableForSale": true,"exists": true}]},{"name": "Size","values": [{search-catalog.js
import 'dotenv/config'; const bearerToken = process.env.BEARER_TOKEN; fetch('https://discover.shopifyapps.com/global/mcp', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${bearerToken}` }, body: JSON.stringify({ jsonrpc: '2.0', method: 'tools/call', id: 1, params: { name: 'search_global_products', arguments: { query: 'I need a crewneck sweater', context: 'buyer looking for sustainable fashion', include_secondhand: true, min_price: 50, max_price: 200, ships_to: 'US', limit: 3 } } }) }) .then(res => res.json()) .then(data => { // Parse the text field to get the actual offers object if (data.result && data.result.content && data.result.content[0]) { const offersData = JSON.parse(data.result.content[0].text); console.log(JSON.stringify(offersData, null, 2)); } });{} Response
{ "offers": [ { "id": "gid://shopify/p/abc123XYZ789defGHI456jk", "title": "Classic Crewneck Sweatshirt", "description": "A comfortable everyday sweatshirt with a classic fit and soft cotton-polyester blend.", "images": [ { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck.webp?v=1700000001", "altText": "Classic Crewneck Sweatshirt", "product": { "id": "gid://shopify/Product/1000000000001", "title": "Classic Crewneck Sweatshirt", "onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456", "shop": { "name": "Mock Shop", "onlineStoreUrl": "https://mock.shop" } } } ], "options": [ { "name": "Color", "values": [ { "value": "Heather Gray", "availableForSale": true, "exists": true } ] }, { "name": "Size", "values": [ { "value": "Medium", "availableForSale": true, "exists": true } ] } ], "priceRange": { "min": { "amount": "45.00", "currencyCode": "USD" }, "max": { "amount": "45.00", "currencyCode": "USD" } }, "products": [ { "id": "gid://shopify/Product/1000000000001", "title": "Classic Crewneck Sweatshirt", "checkoutUrl": "https://mock.shop/cart/2000000000001:1?_gsid=abc123def456&payment=shop_pay", "description": "A comfortable everyday sweatshirt with a classic fit. Made from a soft cotton-polyester blend, this versatile piece features ribbed cuffs and hem for a secure fit. Perfect for layering or wearing on its own.", "featuredImage": { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck.webp?v=1700000001", "altText": "Classic Crewneck Sweatshirt" }, "onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456", "price": { "amount": "45.00", "currencyCode": "USD" }, "rating": null, "availableForSale": true, "shop": { "name": "Mock Shop", "paymentSettings": { "supportedDigitalWallets": [ "SHOPIFY_PAY" ], "acceptedCardBrands": [ "visa", "master", "american_express", "discover", "diners_club", "visadebit", "masterdebit" ] }, "onlineStoreUrl": "https://mock.shop", "privacyPolicy": { "url": "https://checkout.shopify.com/10000000001/policies/20000000001.html?locale=en" }, "refundPolicy": { "url": "https://checkout.shopify.com/10000000001/policies/20000000002.html?locale=en" }, "termsOfService": { "url": "https://checkout.shopify.com/10000000001/policies/20000000003.html?locale=en" }, "shippingPolicy": { "url": "https://checkout.shopify.com/10000000001/policies/20000000004.html?locale=en" }, "id": "gid://shopify/Shop/10000000001", "permanentDomain": "mock-shop.myshopify.com" }, "selectedProductVariant": { "id": "gid://shopify/ProductVariant/2000000000001?shop=10000000001", "availableForSale": true, "options": [ { "name": "Color", "value": "Heather Gray" }, { "name": "Size", "value": "Medium" } ], "price": { "amount": "45.00", "currencyCode": "USD" }, "image": { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck.webp?v=1700000001", "altText": "Classic Crewneck Sweatshirt" } }, "secondhand": false, "requiresSellingPlan": false, "eligibleForNativeCheckout": false } ], "availableForSale": true, "rating": null, "inferredFields": [ "options", "products.secondhand", "products.selectedProductVariant.options", "techSpecs", "sharedAttributes", "uniqueSellingPoint", "topFeatures" ], "uniqueSellingPoint": "Features a soft cotton-polyester blend with ribbed details for comfort and durability.", "topFeatures": [ "50/50 cotton polyester blend provides softness and durability for daily wear", "Classic crewneck design suitable for layering or standalone wear", "Ribbed collar, cuffs, and hem ensure a secure, comfortable fit", "Pre-shrunk fabric maintains shape after washing", "Available in multiple colors and sizes" ], "techSpecs": [ "Weight: 8.0 oz", "Material: 50% cotton, 50% polyester", "Neckline: Crew", "Pattern: Solid", "Available Sizes: S, M, L, XL, 2XL", "Colors: Heather Gray, Navy, Black, White" ], "sharedAttributes": [ { "name": "Fabric", "values": [ "Cotton", "Polyester" ] }, { "name": "Neckline", "values": [ "Crew" ] }, { "name": "Pattern", "values": [ "Solid" ] }, { "name": "Age group", "values": [ "Adults" ] }, { "name": "Target gender", "values": [ "Unisex" ] }, { "name": "Top length type", "values": [ "Medium" ] }, { "name": "Size", "values": [ "Medium (M)" ] }, { "name": "Color", "values": [ "Gray" ] } ], "url": "https://discover.shopifyapps.com/global/v1/p/abc123XYZ789defGHI456jk?_gsid=abc123def456&available_for_sale=1&product_id=1000000000001&query=sweatshirts&ships_to=US&variant_id=2000000000001" }, { "id": "gid://shopify/p/xyz789ABC456mnoPQR123st", "title": "Premium Pullover Hoodie", "description": "A cozy pullover hoodie with kangaroo pocket and drawstring hood for versatile everyday wear.", "images": [ { "url": "https://cdn.shopify.com/s/files/1/0000/0002/0003/files/premium-hoodie.webp?v=1700000005", "altText": "Premium Pullover Hoodie", "product": { "id": "gid://shopify/Product/1000000000003", "title": "Premium Pullover Hoodie", "onlineStoreUrl": "https://shopify.supply/products/premium-pullover-hoodie?variant=2000000000003&_gsid=def456ghi789", "shop": { "name": "Shopify Supply", "onlineStoreUrl": "https://shopify.supply" } } } ], "options": [ { "name": "Color", "values": [ { "value": "Navy", "availableForSale": true, "exists": true }, { "value": "Black", "availableForSale": true, "exists": true }, { "value": "Heather Gray", "availableForSale": true, "exists": true } ] }, { "name": "Size", "values": [ { "value": "Small", "availableForSale": true, "exists": true }, { "value": "Medium", "availableForSale": true, "exists": true }, { "value": "Large", "availableForSale": true, "exists": true } ] } ], "priceRange": { "min": { "amount": "55.00", "currencyCode": "USD" }, "max": { "amount": "65.00", "currencyCode": "USD" } }, "products": [ { "id": "gid://shopify/Product/1000000000003", "title": "Premium Pullover Hoodie", "checkoutUrl": "https://shopify.supply/cart/2000000000003:1?_gsid=def456ghi789&payment=shop_pay", "description": "A cozy pullover hoodie with kangaroo pocket and adjustable drawstring hood. Made from soft fleece blend fabric for warmth and comfort.", "featuredImage": { "url": "https://cdn.shopify.com/s/files/1/0000/0002/0003/files/premium-hoodie.webp?v=1700000005", "altText": "Premium Pullover Hoodie" }, "onlineStoreUrl": "https://shopify.supply/products/premium-pullover-hoodie?variant=2000000000003&_gsid=def456ghi789", "price": { "amount": "55.00", "currencyCode": "USD" }, "rating": { "value": 4.8, "count": 124 }, "availableForSale": true, "shop": { "name": "Shopify Supply", "paymentSettings": { "supportedDigitalWallets": [ "SHOPIFY_PAY" ], "acceptedCardBrands": [ "visa", "master", "american_express", "discover", "diners_club", "visadebit", "masterdebit" ] }, "onlineStoreUrl": "https://shopify.supply", "privacyPolicy": { "url": "https://checkout.shopify.com/10000000002/policies/20000000005.html?locale=en" }, "refundPolicy": { "url": "https://checkout.shopify.com/10000000002/policies/20000000006.html?locale=en" }, "termsOfService": { "url": "https://checkout.shopify.com/10000000002/policies/20000000007.html?locale=en" }, "shippingPolicy": { "url": "https://checkout.shopify.com/10000000002/policies/20000000008.html?locale=en" }, "id": "gid://shopify/Shop/10000000002", "permanentDomain": "shopify-supply.myshopify.com" }, "selectedProductVariant": { "id": "gid://shopify/ProductVariant/2000000000003?shop=10000000002", "availableForSale": true, "options": [ { "name": "Color", "value": "Navy" }, { "name": "Size", "value": "Large" } ], "price": { "amount": "55.00", "currencyCode": "USD" }, "image": { "url": "https://cdn.shopify.com/s/files/1/0000/0002/0003/files/premium-hoodie.webp?v=1700000005", "altText": "Premium Pullover Hoodie" } }, "secondhand": false, "requiresSellingPlan": false, "eligibleForNativeCheckout": false } ], "availableForSale": true, "rating": { "value": 4.8, "count": 124 }, "inferredFields": [ "options", "products.secondhand", "products.selectedProductVariant.options", "techSpecs", "sharedAttributes", "uniqueSellingPoint", "topFeatures" ], "uniqueSellingPoint": "Premium fleece blend with kangaroo pocket provides warmth and convenience.", "topFeatures": [ "Soft fleece blend fabric provides warmth and comfort", "Kangaroo pocket offers convenient storage", "Adjustable drawstring hood for customizable fit", "Ribbed cuffs and hem retain shape", "Available in classic colors" ], "techSpecs": [ "Weight: 10.0 oz", "Material: 60% cotton, 40% polyester", "Neckline: Hooded", "Pattern: Solid", "Available Sizes: S, M, L, XL", "Colors: Navy, Black, Heather Gray" ], "sharedAttributes": [ { "name": "Fabric", "values": [ "Cotton", "Polyester", "Fleece" ] }, { "name": "Neckline", "values": [ "Hooded" ] }, { "name": "Pattern", "values": [ "Solid" ] }, { "name": "Age group", "values": [ "Adults" ] }, { "name": "Target gender", "values": [ "Unisex" ] }, { "name": "Top length type", "values": [ "Medium" ] }, { "name": "Size", "values": [ "Large (L)" ] }, { "name": "Color", "values": [ "Blue" ] } ], "url": "https://discover.shopifyapps.com/global/v1/p/xyz789ABC456mnoPQR123st?_gsid=def456ghi789&available_for_sale=1&product_id=1000000000003&query=sweatshirts&ships_to=US&variant_id=2000000000003" } ], "instructions": "Use markdown to render product titles as links to their respective product pages using the URL property.\n" }
Anchor to Step 4: Lookup detailed product informationStep 4: Lookup detailed product information
At this point your search has resulted in three products, and the buyer may be interested in investigating additional details about them. Lookup within Catalog allows you to render product details not available already in Search (for example, all variants, detailed pricing, availability, and shop details) so buyers can explore available options and offers.
If the buyer chooses an unavailable option, the API will relax those options to find an available variant.
See the get_global_product_details tool documentation for more information about options preferences.
In this example, you'll modify the script to arbitrarily select a product variant result, then leverage Lookup to get additional information about that product.
-
The Catalog returns products grouped by Universal Product ID (UPID). Each product includes shop information and variant details:
import 'dotenv/config';const bearerToken = process.env.BEARER_TOKEN;fetch('https://discover.shopifyapps.com/global/mcp', {method: 'POST',headers: {'Content-Type': 'application/json','Authorization': `Bearer ${bearerToken}`},body: JSON.stringify({jsonrpc: '2.0',method: 'tools/call',id: 1,params: {name: 'search_global_products',arguments: {query: 'I need a crewneck sweater',context: 'buyer looking for sustainable fashion',include_secondhand: true,min_price: 50,max_price: 200,ships_to: 'US',limit: 3}}})}).then(res => res.json()).then(data => {// Parse the text field to get the actual offers objectif (data.result && data.result.content && data.result.content[0]) {const offersData = JSON.parse(data.result.content[0].text);console.log(JSON.stringify(offersData, null, 2));}// Extract first offer ID and call get_global_product_detailsif (data.result && data.result.content && data.result.content[0]) {const textContent = JSON.parse(data.result.content[0].text);if (textContent.offers && textContent.offers.length > 0) {const fullId = textContent.offers[0].id;// Extract UPID from gid://shopify/p/{UPID}const upid = fullId.split('/p/')[1];console.log('\n✓ Using first offer UPID:', upid);// Call get_global_product_details with the extracted IDreturn fetch('https://discover.shopifyapps.com/global/mcp', {method: 'POST',headers: {'Content-Type': 'application/json','Authorization': `Bearer ${bearerToken}`},body: JSON.stringify({jsonrpc: '2.0',method: 'tools/call',id: 2,params: {name: 'get_global_product_details',arguments: {upid: upid}}})});}}}).then(res => res ? res.json() : null).then(data => {if (data) {console.log('\nProduct Details:');console.log(JSON.stringify(data, null, 2));}}).catch(err => console.error('Request failed:', err));{"id": "gid://shopify/p/abc123XYZ789defGHI456jk","title": "Classic Crewneck Sweatshirt","description": "A comfortable everyday sweatshirt with a classic fit and soft cotton-polyester blend.","images": [{"url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck-front.webp?v=1700000001","altText": "Classic Crewneck Sweatshirt - Front","product": {"id": "gid://shopify/Product/1000000000001","title": "Classic Crewneck Sweatshirt","onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456","shop": {"name": "Mock Shop","onlineStoreUrl": "https://mock.shop"}}},{"url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck-back.webp?v=1700000002","altText": "Classic Crewneck Sweatshirt - Back","product": {"id": "gid://shopify/Product/1000000000001","title": "Classic Crewneck Sweatshirt","onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456","shop": {"name": "Mock Shop","onlineStoreUrl": "https://mock.shop"}}},{"url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck-detail.webp?v=1700000003","altText": "Classic Crewneck Sweatshirt - Detail","product": {"id": "gid://shopify/Product/1000000000001",js
import 'dotenv/config'; const bearerToken = process.env.BEARER_TOKEN; fetch('https://discover.shopifyapps.com/global/mcp', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${bearerToken}` }, body: JSON.stringify({ jsonrpc: '2.0', method: 'tools/call', id: 1, params: { name: 'search_global_products', arguments: { query: 'I need a crewneck sweater', context: 'buyer looking for sustainable fashion', include_secondhand: true, min_price: 50, max_price: 200, ships_to: 'US', limit: 3 } } }) }) .then(res => res.json()) .then(data => { // Parse the text field to get the actual offers object if (data.result && data.result.content && data.result.content[0]) { const offersData = JSON.parse(data.result.content[0].text); console.log(JSON.stringify(offersData, null, 2)); } // Extract first offer ID and call get_global_product_details if (data.result && data.result.content && data.result.content[0]) { const textContent = JSON.parse(data.result.content[0].text); if (textContent.offers && textContent.offers.length > 0) { const fullId = textContent.offers[0].id; // Extract UPID from gid://shopify/p/{UPID} const upid = fullId.split('/p/')[1]; console.log('\n✓ Using first offer UPID:', upid); // Call get_global_product_details with the extracted ID return fetch('https://discover.shopifyapps.com/global/mcp', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${bearerToken}` }, body: JSON.stringify({ jsonrpc: '2.0', method: 'tools/call', id: 2, params: { name: 'get_global_product_details', arguments: { upid: upid } } }) }); } } }) .then(res => res ? res.json() : null) .then(data => { if (data) { console.log('\nProduct Details:'); console.log(JSON.stringify(data, null, 2)); } }) .catch(err => console.error('Request failed:', err));{} Response
{ "id": "gid://shopify/p/abc123XYZ789defGHI456jk", "title": "Classic Crewneck Sweatshirt", "description": "A comfortable everyday sweatshirt with a classic fit and soft cotton-polyester blend.", "images": [ { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck-front.webp?v=1700000001", "altText": "Classic Crewneck Sweatshirt - Front", "product": { "id": "gid://shopify/Product/1000000000001", "title": "Classic Crewneck Sweatshirt", "onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456", "shop": { "name": "Mock Shop", "onlineStoreUrl": "https://mock.shop" } } }, { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck-back.webp?v=1700000002", "altText": "Classic Crewneck Sweatshirt - Back", "product": { "id": "gid://shopify/Product/1000000000001", "title": "Classic Crewneck Sweatshirt", "onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456", "shop": { "name": "Mock Shop", "onlineStoreUrl": "https://mock.shop" } } }, { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck-detail.webp?v=1700000003", "altText": "Classic Crewneck Sweatshirt - Detail", "product": { "id": "gid://shopify/Product/1000000000001", "title": "Classic Crewneck Sweatshirt", "onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456", "shop": { "name": "Mock Shop", "onlineStoreUrl": "https://mock.shop" } } }, { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck-lifestyle.webp?v=1700000004", "altText": "Classic Crewneck Sweatshirt - Lifestyle", "product": { "id": "gid://shopify/Product/1000000000001", "title": "Classic Crewneck Sweatshirt", "onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456", "shop": { "name": "Mock Shop", "onlineStoreUrl": "https://mock.shop" } } } ], "options": [ { "name": "Color", "values": [ { "value": "Heather Gray", "availableForSale": true, "exists": true } ] }, { "name": "Size", "values": [ { "value": "Medium", "availableForSale": true, "exists": true } ] } ], "priceRange": { "min": { "amount": "45.00", "currencyCode": "USD" }, "max": { "amount": "45.00", "currencyCode": "USD" } }, "products": [ { "id": "gid://shopify/Product/1000000000001", "title": "Classic Crewneck Sweatshirt", "checkoutUrl": "https://mock.shop/cart/2000000000001:1?_gsid=abc123def456&payment=shop_pay", "description": "A comfortable everyday sweatshirt with a classic fit. Made from a soft cotton-polyester blend, this versatile piece features ribbed cuffs and hem for a secure fit. Perfect for layering or wearing on its own.", "featuredImage": { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck-front.webp?v=1700000001", "altText": "Classic Crewneck Sweatshirt" }, "onlineStoreUrl": "https://mock.shop/products/classic-crewneck-sweatshirt?variant=2000000000001&_gsid=abc123def456", "price": { "amount": "45.00", "currencyCode": "USD" }, "rating": null, "availableForSale": true, "shop": { "name": "Mock Shop", "paymentSettings": { "supportedDigitalWallets": [ "SHOPIFY_PAY" ], "acceptedCardBrands": [ "visa", "master", "american_express", "discover", "diners_club", "visadebit", "masterdebit" ] }, "onlineStoreUrl": "https://mock.shop", "privacyPolicy": { "url": "https://checkout.shopify.com/10000000001/policies/20000000001.html?locale=en" }, "refundPolicy": { "url": "https://checkout.shopify.com/10000000001/policies/20000000002.html?locale=en" }, "termsOfService": { "url": "https://checkout.shopify.com/10000000001/policies/20000000003.html?locale=en" }, "shippingPolicy": { "url": "https://checkout.shopify.com/10000000001/policies/20000000004.html?locale=en" }, "id": "gid://shopify/Shop/10000000001", "permanentDomain": "mock-shop.myshopify.com" }, "selectedProductVariant": { "id": "gid://shopify/ProductVariant/2000000000001?shop=10000000001", "availableForSale": true, "options": [ { "name": "Color", "value": "Heather Gray" }, { "name": "Size", "value": "Medium" } ], "price": { "amount": "45.00", "currencyCode": "USD" }, "image": { "url": "https://cdn.shopify.com/s/files/1/0000/0001/0002/files/classic-crewneck-front.webp?v=1700000001", "altText": "Classic Crewneck Sweatshirt" }, "selectionState": { "type": "match", "requestedFilters": [] } }, "secondhand": false, "requiresSellingPlan": false, "eligibleForNativeCheckout": false } ], "availableForSale": true, "rating": null, "inferredFields": [ "options", "products.secondhand", "products.selectedProductVariant.options", "techSpecs", "sharedAttributes", "uniqueSellingPoint", "topFeatures" ], "uniqueSellingPoint": "Features a soft cotton-polyester blend with ribbed details for comfort and durability.", "topFeatures": [ "50/50 cotton polyester blend provides softness and durability for daily wear", "Classic crewneck design suitable for layering or standalone wear", "Ribbed collar, cuffs, and hem ensure a secure, comfortable fit", "Pre-shrunk fabric maintains shape after washing", "Available in multiple colors and sizes" ], "techSpecs": [ "Weight: 8.0 oz", "Material: 50% cotton, 50% polyester", "Neckline: Crew", "Pattern: Solid", "Available Sizes: S, M, L, XL, 2XL", "Colors: Heather Gray, Navy, Black, White" ], "sharedAttributes": [ { "name": "Fabric", "values": [ "Cotton", "Polyester" ] }, { "name": "Neckline", "values": [ "Crew" ] }, { "name": "Pattern", "values": [ "Solid" ] }, { "name": "Age group", "values": [ "Adults" ] }, { "name": "Target gender", "values": [ "Unisex" ] }, { "name": "Top length type", "values": [ "Medium" ] }, { "name": "Size", "values": [ "Medium (M)" ] }, { "name": "Color", "values": [ "Gray" ] } ] }Inspect the response related to product variant. You'll see from that response (at
.result.content[0].text.product.products[0].selectedProductVariant) the default selection for the result.InfoIt's at this point that your agent would respond to a buyer's behavior to identify which products, variants, and options to investigate with the
get_global_product_detailstool. In this demo, the first result in the array of resulting products is chosen to stand-in for this behavior. -
Update the script to get updated details for the size the buyer actually wants to order using the
product_optionsargument.import 'dotenv/config';const bearerToken = process.env.BEARER_TOKEN;fetch('https://discover.shopifyapps.com/global/mcp', {method: 'POST',headers: {'Content-Type': 'application/json','Authorization': `Bearer ${bearerToken}`},body: JSON.stringify({jsonrpc: '2.0',method: 'tools/call',id: 1,params: {name: 'search_global_products',arguments: {query: 'vintage leather jacket',include_secondhand: true,max_price: 150,limit: 3}}})}).then(res => res.json()).then(data => {// Extract first offer ID and call get_global_product_detailsif (data.result && data.result.content && data.result.content[0]) {const textContent = JSON.parse(data.result.content[0].text);if (textContent.offers && textContent.offers.length > 0) {const fullId = textContent.offers[0].id;// Extract UPID from gid://shopify/p/{UPID}const upid = fullId.split('/p/')[1];// Call get_global_product_details with the extracted IDreturn fetch('https://discover.shopifyapps.com/global/mcp', {method: 'POST',headers: {'Content-Type': 'application/json','Authorization': `Bearer ${bearerToken}`},body: JSON.stringify({jsonrpc: '2.0',method: 'tools/call',id: 2,params: {name: 'get_global_product_details',arguments: {upid: upid,product_options: [{key: 'Size',values: ['Large (L)']}]}}})});}}}).then(res => res ? res.json() : null).then(data => {if (data) {console.log(JSON.stringify(data, null, 2));}}).catch(err => console.error('Request failed:', err));