delete_product
Permanently delete a product and all its associated rate plans and related data. Provide the product ID to remove the product completely.
Instructions
Delete a product. DELETE /products/{productId}. Warning: This also deletes associated rate plans and related data (cascading deletion).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| productId | Yes | Product ID (required) |
Implementation Reference
- The handler function that executes the delete_product logic. It validates args with Zod schema, then calls productService.deleteProduct(client, productId).
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.deleteProduct(client, parsed.data.productId)); } - Zod schema for input validation: requires a non-empty string productId.
const schema = z.object({ productId: z.string().min(1, "productId is required"), }); - The service function that performs the HTTP DELETE call to /products/{productId} and returns the result.
export async function deleteProduct( client: Client, productId: string ): Promise<Record<string, unknown>> { const result = await client.delete<Record<string, unknown>>(`/products/${productId}`); return Object.keys(result ?? {}).length ? result : { success: true, message: "Product deleted" }; } - src/tools/products/deleteProduct.ts:32-35 (registration)The Tool object export containing the definition and handler.
export const deleteProductTool: Tool = { definition, handler, }; - src/tools/products/index.ts:16-33 (registration)Product tools registry function that includes deleteProductTool in the list of all product tools.
export function registerProductTools(): Tool[] { return [ listProductsTool, getProductTool, createProductTool, updateProductTool, deleteProductTool, updateProductStatusTool, linkExternalProductTool, unlinkExternalProductTool, ]; } export { listProductsTool } from "./listProducts.js"; export { getProductTool } from "./getProduct.js"; export { createProductTool } from "./createProduct.js"; export { updateProductTool } from "./updateProduct.js"; export { deleteProductTool } from "./deleteProduct.js";