list_products
Retrieve product listings with filters for status, category, name, and includes. Supports pagination and sorting.
Instructions
List products. GET /products. Optional: include (productRateplan, productRateplanCharge, chargeTier), status (published|draft|archived|disabled), name, category (baseProducts|addOn|bundleProduct|miscellaneous|service), orderBy, sortBy (ASC/DESC), itemPerPage, pageNo.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include | No | Comma-separated includes: productRateplan, productRateplanCharge, chargeTier | |
| status | No | Filter by product status | |
| name | No | Filter by product name | |
| category | No | Filter by product category | |
| orderBy | No | Sort column | |
| sortBy | No | ASC or DESC | |
| itemPerPage | No | Items per page | |
| pageNo | No | Page number (1-based) |
Implementation Reference
- src/tools/products/listProducts.ts:59-62 (handler)Export of the list_products tool. The handler function (lines 51-57) validates args with Zod schema, then calls productService.listProducts(client, parsed.data).
export const listProductsTool: Tool = { definition, handler, }; - src/tools/products/listProducts.ts:51-57 (handler)The actual handler function for list_products: validates input against Zod schema, calls the underlying service function, and wraps the result.
async function handler(client: Client, args: Record<string, unknown> | undefined) { const parsed = schema.safeParse(args); if (!parsed.success) { return errorResult(parsed.error.errors.map((e) => e.message).join("; ")); } return handleToolCall(() => productService.listProducts(client, parsed.data)); } - Zod validation schema for list_products input parameters.
const schema = z.object({ include: z.string().optional(), status: z.enum(["published", "draft", "archived", "disabled"]).optional(), name: z.string().optional(), category: z .enum(["baseProducts", "addOn", "bundleProduct", "miscellaneous", "service"]) .optional(), orderBy: z.string().optional(), sortBy: z.enum(["ASC", "DESC"]).optional(), itemPerPage: z.number().int().min(1).optional(), pageNo: z.number().int().min(1).optional(), }); - MCP tool definition for list_products: name, description, and JSON Schema input schema.
const definition = { name: "list_products", description: "List products. GET /products. Optional: include (productRateplan, productRateplanCharge, chargeTier), status (published|draft|archived|disabled), name, category (baseProducts|addOn|bundleProduct|miscellaneous|service), orderBy, sortBy (ASC/DESC), itemPerPage, pageNo.", inputSchema: { type: "object" as const, properties: { include: { type: "string", description: "Comma-separated includes: productRateplan, productRateplanCharge, chargeTier", }, status: { type: "string", enum: ["published", "draft", "archived", "disabled"], description: "Filter by product status", }, name: { type: "string", description: "Filter by product name" }, category: { type: "string", enum: ["baseProducts", "addOn", "bundleProduct", "miscellaneous", "service"], description: "Filter by product category", }, orderBy: { type: "string", description: "Sort column" }, sortBy: { type: "string", description: "ASC or DESC" }, itemPerPage: { type: "number", description: "Items per page" }, pageNo: { type: "number", description: "Page number (1-based)" }, }, required: [], }, }; - The actual API call for list_products: builds query parameters from optional filters and performs a GET /products request.
export async function listProducts( client: Client, params?: ListProductsParams ): Promise<PaginatedResponse<unknown>> { const search = new URLSearchParams(); if (params?.include) search.append("include", params.include); if (params?.status) search.append("status", params.status); if (params?.name) search.append("name", params.name); if (params?.category) search.append("category", params.category); if (params?.orderBy) search.append("orderBy", params.orderBy); if (params?.sortBy) search.append("sortBy", params.sortBy); if (params?.itemPerPage != null) search.append("itemPerPage", String(params.itemPerPage)); if (params?.pageNo != null) search.append("pageNo", String(params.pageNo)); if (params?.filterId != null) search.append("filterId", String(params.filterId)); if (params?.query) search.append("query", params.query); const q = search.toString(); return client.get<PaginatedResponse<unknown>>(`/products${q ? `?${q}` : ""}`); }