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

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
NameRequiredDescriptionDefault
idYesProduct ID

Implementation Reference

  • 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}`);
    }
  • 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) }],
      };
    }

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