Update a product
deonpay_update_productUpdate your product's price, name, stock quantity, or active status by specifying its UUID or SKU. Only changed fields are applied.
Instructions
Update an existing product (resolved by UUID or SKU). Only fields you send are changed. Use this for price adjustments, renaming, toggling is_active, updating stock_quantity, or swapping the image_url. Note: under the hood the API uses HTTP PATCH (not PUT).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Product UUID or SKU. | |
| name | No | ||
| description | No | ||
| unit_amount | No | New unit price in centavos. | |
| currency | No | ||
| image_url | No | ||
| sku | No | ||
| is_active | No | ||
| stock_tracking | No | ||
| stock_quantity | No | ||
| metadata | No |
Implementation Reference
- src/tools/products.ts:120-122 (handler)The handler function for deonpay_update_product. It destructures `id` from args for the URL path and calls `client.patch()` on `/products/{id}` with the remaining fields compacted (stripping empty/undefined values).
safeHandler(async ({ id, ...rest }) => { return client.patch(`/products/${encodeURIComponent(id)}`, compact(rest)); }), - src/tools/products.ts:106-118 (schema)Zod input schema for deonpay_update_product. Requires `id` (UUID or SKU string), with optional fields: name, description, unit_amount (min 100 centavos), currency, image_url, sku, is_active, stock_tracking, stock_quantity, and metadata.
inputSchema: { id: z.string().min(1).describe("Product UUID or SKU."), name: z.string().min(1).max(255).optional(), description: z.string().max(1000).optional(), unit_amount: z.number().int().min(100).optional().describe("New unit price in centavos."), currency: z.string().length(3).optional(), image_url: z.string().url().optional(), sku: z.string().max(100).optional(), is_active: z.boolean().optional(), stock_tracking: z.boolean().optional(), stock_quantity: z.number().int().min(0).optional(), metadata: z.record(z.unknown()).optional(), }, - src/tools/products.ts:100-123 (registration)Registration of the tool named 'deonpay_update_product' on the MCP server via `server.registerTool()`, including its title, description, input schema, and handler.
server.registerTool( "deonpay_update_product", { title: "Update a product", description: "Update an existing product (resolved by UUID or SKU). Only fields you send are changed. Use this for price adjustments, renaming, toggling is_active, updating stock_quantity, or swapping the image_url. Note: under the hood the API uses HTTP PATCH (not PUT).", inputSchema: { id: z.string().min(1).describe("Product UUID or SKU."), name: z.string().min(1).max(255).optional(), description: z.string().max(1000).optional(), unit_amount: z.number().int().min(100).optional().describe("New unit price in centavos."), currency: z.string().length(3).optional(), image_url: z.string().url().optional(), sku: z.string().max(100).optional(), is_active: z.boolean().optional(), stock_tracking: z.boolean().optional(), stock_quantity: z.number().int().min(0).optional(), metadata: z.record(z.unknown()).optional(), }, }, safeHandler(async ({ id, ...rest }) => { return client.patch(`/products/${encodeURIComponent(id)}`, compact(rest)); }), ); - src/tools/index.ts:24-24 (registration)The tool is registered as part of the module, called via `registerProductTools(server, client)` in the central `registerAllTools` registry function.
registerProductTools(server, client); - src/tools/_helpers.ts:83-91 (helper)The `compact` helper used by the handler to strip undefined/null/empty-string values before sending the PATCH body.
export function compact<T extends Record<string, unknown>>(obj: T): Partial<T> { const out: Record<string, unknown> = {}; for (const [key, value] of Object.entries(obj)) { if (value === undefined || value === null) continue; if (typeof value === "string" && value.trim() === "") continue; out[key] = value; } return out as Partial<T>; }