Skip to main content
Glama
op-enny
by op-enny

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
NameRequiredDescriptionDefault
idYesProduct ID to update
titleNoNew product title
priceNoNew product price
descriptionNoNew product description
imageNoNew product image URL
categoryNoNew product category

Implementation Reference

  • 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);
    }
  • 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],

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/op-enny/mcp-server-fakestore'

If you have feedback or need assistance with the MCP directory API, please join our Discord server