Skip to main content
Glama

fakestore_get_product

Retrieve product details by ID from a fake e-commerce API for testing, demos, and development purposes.

Instructions

Get a single product by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesProduct ID

Implementation Reference

  • The core handler function that fetches a single product by ID using the FakeStore API, including validation.
    export async function getProductById(args: { id: number }): Promise<Product> { const { id } = args; validatePositiveInteger(id, 'Product ID'); return get<Product>(`/products/${id}`); }
  • The tool definition in productTools array, providing the name, description, and input schema.
    { name: 'fakestore_get_product', description: 'Get a single product by its ID', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Product ID', }, }, required: ['id'], }, },
  • src/index.ts:61-66 (registration)
    Registration and dispatch in the CallToolRequestHandler that maps the tool name to the getProductById handler.
    if (name === 'fakestore_get_product') { const result = await getProductById(args as { id: number }); 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