fakestore_update_product
Update product details including title, price, description, image, and category in a simulated e-commerce environment for testing and development purposes.
Instructions
Update an existing product (simulation - does not persist)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | New product category | |
| description | No | New product description | |
| id | Yes | Product ID to update | |
| image | No | New product image URL | |
| price | No | New product price | |
| title | No | New product title |
Implementation Reference
- src/tools/products.ts:95-117 (handler)The core handler function that validates input, constructs the update data, and performs the PUT request to the FakeStore API to update the product.export async function updateProduct(args: { id: number; title?: string; price?: number; description?: string; image?: string; category?: string; }): Promise<Product> { const { id, title, price, description, image, category } = args; validatePositiveInteger(id, 'Product ID'); const updateData: Record<string, unknown> = {}; if (title !== undefined) updateData.title = title; if (price !== undefined) updateData.price = price; if (description !== undefined) updateData.description = description; if (image !== undefined) { validateUrl(image, 'Image URL'); updateData.image = image; } if (category !== undefined) updateData.category = category; return put<Product>(`/products/${id}`, updateData); }
- src/index.ts:95-107 (registration)The dispatch logic in the main tool call handler that maps the tool name to the updateProduct function execution.if (name === 'fakestore_update_product') { const result = await updateProduct(args as { id: number; title?: string; price?: number; description?: string; image?: string; category?: string; }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/tools/products.ts:217-249 (schema)The tool schema definition including name, description, and input schema, included in the productTools array for tool listing.name: 'fakestore_update_product', description: 'Update an existing product (simulation - does not persist)', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Product ID to update', }, title: { type: 'string', description: 'New product title', }, price: { type: 'number', description: 'New product price', }, description: { type: 'string', description: 'New product description', }, image: { type: 'string', description: 'New product image URL', }, category: { type: 'string', description: 'New product category', }, }, required: ['id'], }, },