listProducts
Retrieve a paginated list of products from the Omnisend catalog, enabling users to manage and access product data efficiently using limit and offset parameters.
Instructions
Retrieve a list of products from the Omnisend catalog with pagination support.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of products to return | |
| offset | No | Skip first N results |
Implementation Reference
- src/tools/products/index.ts:24-48 (handler)MCP tool handler for 'listProducts'. Invokes the API function, filters product fields, serializes to JSON, and returns as text content in MCP format.async (args) => { try { const response = await listProducts(args); // Filter products data to include only defined fields const filteredProducts = response.products.map(filterProductFields); return { content: [ { type: "text", text: JSON.stringify({ products: filteredProducts, paging: response.paging }, null, 2) } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } }
- src/tools/products/index.ts:10-23 (schema)JSON Schema defining the input parameters for the listProducts tool, supporting pagination and various filters.{ additionalProperties: false, properties: { limit: { description: "Maximum number of products to return", type: "number" }, offset: { description: "Skip first N results", type: "number" }, status: { description: "Filter products by status", enum: ["active", "draft", "archived"], type: "string" }, vendor: { description: "Filter products by vendor/brand", type: "string" }, createdAfter: { description: "Filter products created after specified date (ISO format)", type: "string" }, updatedAfter: { description: "Filter products updated after specified date (ISO format)", type: "string" }, categories: { description: "Filter products by categories", items: { type: "string" }, type: "array" }, tags: { description: "Filter products by tags", items: { type: "string" }, type: "array" } }, type: "object" },
- src/tools/products/index.ts:6-49 (registration)Full registration of the listProducts tool on the MCP server, including comment, name, description, schema, and handler.// List products tool server.tool( "listProducts", "Retrieve a list of products from the Omnisend catalog with pagination support. The response includes pagination information (next/previous cursor, limit, offset).", { additionalProperties: false, properties: { limit: { description: "Maximum number of products to return", type: "number" }, offset: { description: "Skip first N results", type: "number" }, status: { description: "Filter products by status", enum: ["active", "draft", "archived"], type: "string" }, vendor: { description: "Filter products by vendor/brand", type: "string" }, createdAfter: { description: "Filter products created after specified date (ISO format)", type: "string" }, updatedAfter: { description: "Filter products updated after specified date (ISO format)", type: "string" }, categories: { description: "Filter products by categories", items: { type: "string" }, type: "array" }, tags: { description: "Filter products by tags", items: { type: "string" }, type: "array" } }, type: "object" }, async (args) => { try { const response = await listProducts(args); // Filter products data to include only defined fields const filteredProducts = response.products.map(filterProductFields); return { content: [ { type: "text", text: JSON.stringify({ products: filteredProducts, paging: response.paging }, null, 2) } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } } );
- Helper function that performs the actual API call to list products from Omnisend using omnisendApi.get.// List products export const listProducts = async (params: ListProductsParams = {}): Promise<ProductsResponse> => { try { const response = await omnisendApi.get<ProductsResponse>('/products', { params }); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error getting products list: ${error.message}`); } else { throw new Error('Unknown error occurred when getting products list'); } } };
- src/types/products/index.ts:37-40 (schema)TypeScript interface defining parameters for the listProducts API helper function.export interface ListProductsParams { limit?: number; offset?: number; }