fakestore_update_product
Modify product details like title, price, description, image, or category in the Fake Store API simulation for testing and development purposes.
Instructions
Update an existing product (simulation - does not persist)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Product ID to update | |
| title | No | New product title | |
| price | No | New product price | |
| description | No | New product description | |
| image | No | New product image URL | |
| category | No | New product category |
Implementation Reference
- src/tools/products.ts:95-117 (handler)The core handler function implementing the fakestore_update_product tool logic. Validates inputs, constructs update data, and makes a PUT request to the FakeStore API.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/tools/products.ts:216-249 (schema)The tool definition including name, description, and input schema for fakestore_update_product, part of the productTools array used 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'], }, },
- src/index.ts:95-107 (registration)Registration and dispatch logic in the main MCP server 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/index.ts:42-42 (registration)Tool listing handler that includes productTools (containing fakestore_update_product schema) in the list of available tools.tools: [...productTools, ...cartTools, ...userTools],