fakestore_get_product
Retrieve product details by ID from a mock e-commerce API for testing, demos, or learning MCP development.
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)Core handler function that validates the product ID and fetches the product from the FakeStore API using the get utility.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:151-163 (schema)Input schema definition for the fakestore_get_product tool, specifying the required 'id' parameter.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)Dispatch registration in the main tool handler that maps the tool name to the getProductById function and formats the response.if (name === 'fakestore_get_product') { const result = await getProductById(args as { id: number }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }