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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Product ID |
Implementation Reference
- src/tools/products.ts:32-36 (handler)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}`); }
- src/tools/products.ts:150-163 (schema)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) }], }; }