Skip to main content
Glama

fakestore_add_product

Add new products to a simulated e-commerce store for testing and demonstration purposes. Specify product title, price, description, image URL, and category to create temporary product entries.

Instructions

Add a new product to the store (simulation - does not persist)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesProduct category
descriptionYesProduct description
imageYesProduct image URL
priceYesProduct price
titleYesProduct title

Implementation Reference

  • Core handler function that validates the input parameters and performs a POST request to add a new product to the FakeStore API.
    * Add a new product (simulation - returns the product with an ID) */ export async function addProduct(args: { title: string; price: number; description: string; image: string; category: string; }): Promise<Product> { const { title, price, description, image, category } = args; if (!title || typeof title !== 'string') { throw new Error('Title must be a non-empty string'); } if (typeof price !== 'number' || price <= 0) { throw new Error('Price must be a positive number'); } if (!description || typeof description !== 'string') { throw new Error('Description must be a non-empty string'); } validateUrl(image, 'Image URL'); if (!category || typeof category !== 'string') { throw new Error('Category must be a non-empty string'); } return post<Product>('/products', { title, price, description, image, category, }); }
  • Tool schema definition including input schema with properties, descriptions, and required fields for fakestore_add_product.
    name: 'fakestore_add_product', description: 'Add a new product to the store (simulation - does not persist)', inputSchema: { type: 'object', properties: { title: { type: 'string', description: 'Product title', }, price: { type: 'number', description: 'Product price', }, description: { type: 'string', description: 'Product description', }, image: { type: 'string', description: 'Product image URL', }, category: { type: 'string', description: 'Product category', }, }, required: ['title', 'price', 'description', 'image', 'category'], }, },
  • src/index.ts:82-93 (registration)
    Registration and dispatch logic in the main CallToolRequest handler that matches the tool name and invokes the addProduct handler.
    if (name === 'fakestore_add_product') { const result = await addProduct(args as { title: string; price: number; description: string; image: string; category: string; }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • src/index.ts:40-44 (registration)
    Registration of available tools list handler, which includes the fakestore_add_product tool from productTools.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { 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