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

fakestore_add_product

Add a new product to the Fake Store API for e-commerce demos and testing by providing title, price, description, image URL, and category.

Instructions

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

Input Schema

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

Implementation Reference

  • The `addProduct` function that executes the tool logic: validates input parameters and posts a new product to the FakeStore API.
    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, }); }
  • The input schema definition for the 'fakestore_add_product' tool, specifying required properties and types.
    { 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)
    Dispatch logic in the main tool handler that matches the tool name and invokes the `addProduct` handler function.
    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) }], }; }

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