shopify_products
Fetch a paginated product catalog from any Shopify store. Customize page number and product count, up to 250 items per call.
Instructions
Fetch a paginated product catalog from any Shopify store. Up to 250 products per call.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | Shopify store URL | |
| page | No | Page number (default: 1) | |
| limit | No | Products per page, max 250 (default: 50) |
Implementation Reference
- src/tools/shopify.ts:233-268 (handler)The main handler function that fetches paginated products from a Shopify store via /products.json endpoint. Normalizes the URL, clamps limit to 250, fetches products with page/limit params, and returns ShopifyProductsResult.
export async function getShopifyProducts( storeUrl: string, page = 1, limit = 50 ): Promise<ShopifyProductsResult> { const baseUrl = normalizeStoreUrl(storeUrl); const clampedLimit = Math.min(Math.max(1, limit), 250); const headers = { "User-Agent": "Mozilla/5.0 (compatible; IntelligenceAPI/1.0; +https://intelligence-api.io)", Accept: "application/json", }; const res = await fetch( `${baseUrl}/products.json?limit=${clampedLimit}&page=${page}`, { headers } ); if (!res.ok) { throw new Error( `Failed to fetch products from ${baseUrl}: HTTP ${res.status}` ); } const json = (await res.json()) as { products?: ShopifyProduct[] }; const products = json.products ?? []; return { store_url: baseUrl, page, limit: clampedLimit, total_fetched: products.length, products, }; } - src/mcp-stdio.ts:182-190 (handler)MCP tool dispatch handler for 'shopify_products'. Extracts url, page, limit from args and delegates to getShopifyProducts().
case "shopify_products": { const { url, page, limit } = args as { url: string; page?: number; limit?: number; }; result = await getShopifyProducts(url, page, limit); break; } - src/mcp-stdio.ts:48-69 (schema)MCP tool registration with inputSchema defining required 'url' and optional 'page' and 'limit' parameters.
{ name: "shopify_products", description: "Fetch a paginated product catalog from any Shopify store. Up to 250 products per call.", inputSchema: { type: "object", properties: { url: { type: "string", description: "Shopify store URL", }, page: { type: "number", description: "Page number (default: 1)", }, limit: { type: "number", description: "Products per page, max 250 (default: 50)", }, }, required: ["url"], }, - src/tools/shopify.ts:48-54 (schema)TypeScript interface ShopifyProductsResult defining the return shape: store_url, page, limit, total_fetched, and products array.
export interface ShopifyProductsResult { store_url: string; page: number; limit: number; total_fetched: number; products: ShopifyProduct[]; } - src/mcp-stdio.ts:48-70 (registration)MCP tool registration for 'shopify_products' in the ListToolsRequestSchema handler.
{ name: "shopify_products", description: "Fetch a paginated product catalog from any Shopify store. Up to 250 products per call.", inputSchema: { type: "object", properties: { url: { type: "string", description: "Shopify store URL", }, page: { type: "number", description: "Page number (default: 1)", }, limit: { type: "number", description: "Products per page, max 250 (default: 50)", }, }, required: ["url"], }, }, - src/routes/shopify.ts:30-57 (registration)Express route handler at GET /shopify/products that also uses getShopifyProducts().
router.get("/shopify/products", async (req: Request, res: Response) => { const { url, page, limit } = req.query; if (!url || typeof url !== "string") { res.status(400).json({ error: "Missing required query parameter: url", example: "/shopify/products?url=example.myshopify.com&page=1&limit=50", }); return; } const pageNum = page ? parseInt(page as string, 10) : 1; const limitNum = limit ? parseInt(limit as string, 10) : 50; if (isNaN(pageNum) || pageNum < 1) { res.status(400).json({ error: "page must be a positive integer" }); return; } if (isNaN(limitNum) || limitNum < 1 || limitNum > 250) { res.status(400).json({ error: "limit must be between 1 and 250" }); return; } try { const result = await getShopifyProducts(url, pageNum, limitNum); res.json(result); } catch (err) {