update_product
Modify a product's name, category, description, internal product ID, or SKU by providing the product ID and the fields to update.
Instructions
Update a product. PUT /products/{productId}. Optional: name, category, description, internalProductId, sku.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| productId | Yes | Product ID (required) | |
| name | No | Product name | |
| category | No | Category | |
| description | No | Description | |
| internalProductId | No | Internal product ID | |
| sku | No | SKU |
Implementation Reference
- Handler function for the update_product tool. Parses input with Zod schema, extracts productId and remaining body fields, then calls productService.updateProduct.
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("; ")); } const { productId, ...body } = parsed.data; return handleToolCall(() => productService.updateProduct(client, productId, body)); } - Zod input schema for update_product: requires productId, optional fields: name, category, description, internalProductId, sku.
const schema = z.object({ productId: z.string().min(1, "productId is required"), name: z.string().optional(), category: z.string().optional(), description: z.string().optional(), internalProductId: z.string().optional(), sku: z.string().optional(), }); - UpdateProductBody TypeScript interface with optional fields: name, category, description, internalProductId, sku, effectiveStartDate, effectiveEndDate.
export interface UpdateProductBody { name?: string; category?: string; description?: string; internalProductId?: string; sku?: string; effectiveStartDate?: string; effectiveEndDate?: string; } - src/tools/products/updateProduct.ts:16-32 (registration)Tool definition (name: 'update_product') with inputSchema describing the JSON properties for MCP tools/list registration.
const definition = { name: "update_product", description: "Update a product. PUT /products/{productId}. Optional: name, category, description, internalProductId, sku.", inputSchema: { type: "object" as const, properties: { productId: { type: "string", description: "Product ID (required)" }, name: { type: "string", description: "Product name" }, category: { type: "string", description: "Category" }, description: { type: "string", description: "Description" }, internalProductId: { type: "string", description: "Internal product ID" }, sku: { type: "string", description: "SKU" }, }, required: ["productId"], }, }; - src/tools/products/updateProduct.ts:43-46 (registration)Exported updateProductTool constant combining definition and handler as a Tool object.
export const updateProductTool: Tool = { definition, handler, };