b24_read_product_catalog
Read the product catalog structure including sections, properties, prices, and units.
Instructions
Lee la estructura de configuración del catálogo de productos: secciones, propiedades, precios y unidades.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| webhook_url | No | URL del webhook (opcional si está configurado por defecto) |
Implementation Reference
- index.js:158-160 (registration)Registration of the b24_read_product_catalog MCP tool with description and handler
server.tool('b24_read_product_catalog', 'Lee la estructura de configuración del catálogo de productos: secciones, propiedades, precios y unidades.', readProductCatalogSchema.shape, wrap(readProductCatalog)); - Zod schema for input validation: optional webhook_url parameter
export const readProductCatalogSchema = z.object({ webhook_url: z.string().url().optional().describe('URL del webhook (opcional si está configurado por defecto)'), }); - src/tools/read-product-catalog.js:10-30 (handler)Handler function that creates a Bitrix24 client, reads the product catalog via the reader, and returns structured result with summary
export async function readProductCatalog({ webhook_url }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); const reader = new Bitrix24Reader(client); const catalog = await reader.readProductCatalog(); if (catalog.error) { return { portal: client.portal, error: catalog.error }; } return { portal: client.portal, product_catalog: catalog, summary: [ `${catalog.catalogs?.length ?? 0} catálogos`, `${catalog.sections?.length ?? 0} secciones`, `${catalog.properties?.length ?? 0} propiedades`, `${catalog.measures?.length ?? 0} unidades de medida`, `${catalog.price_types?.length ?? 0} tipos de precio`, ].join(', '), }; } - src/bitrix24/reader.js:103-122 (helper)Bitrix24Reader method that fetches all catalog data in parallel: catalogs, sections, properties, measures, and price types via paginated API calls
async readProductCatalog() { const catalog = {}; try { const [catalogs, sections, properties, measures, priceTypes] = await Promise.all([ fetchAllPages(this.client, 'catalog.catalog.list'), fetchAllPages(this.client, 'catalog.section.list'), fetchAllPages(this.client, 'catalog.product.property.list'), fetchAllPages(this.client, 'catalog.measure.list'), fetchAllPages(this.client, 'catalog.price.type.list'), ]); catalog.catalogs = catalogs; catalog.sections = sections; catalog.properties = properties; catalog.measures = measures; catalog.price_types = priceTypes; } catch { catalog.error = 'Catalog scope not available or not enabled in this plan'; } return catalog; } - src/utils/pagination.js:1-23 (helper)Utility function for paginated API calls used by readProductCatalog to fetch all items from Bitrix24 APIs
export async function fetchAllPages(client, method, params = {}) { const results = []; let start = 0; while (true) { const response = await client.call(method, { ...params, start }); const items = response.result; if (!items || (Array.isArray(items) && items.length === 0)) break; if (Array.isArray(items)) { results.push(...items); } else { results.push(items); } const total = response.total ?? 0; start += 50; if (start >= total || items.length < 50) break; } return results; }