Skip to main content
Glama

fakestore_get_products

Retrieve product listings from a fake store API with options to limit results and sort by price for e-commerce testing and development.

Instructions

Get all products from the store. Optionally limit results and sort by price.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoLimit the number of products returned
sortNoSort products by price (asc or desc)

Implementation Reference

  • Core implementation of the fakestore_get_products tool logic: validates inputs, constructs API params, and fetches products from /products endpoint.
    export async function getAllProducts(args: { limit?: number; sort?: SortOrder }): Promise<Product[]> { const { limit, sort } = args; if (limit !== undefined) { validateLimit(limit); } if (sort !== undefined) { validateSortOrder(sort); } const params: Record<string, unknown> = {}; if (limit) params.limit = limit; if (sort) params.sort = sort; return get<Product[]>('/products', params); }
  • Dispatch handler in the MCP callToolRequestHandler that matches the tool name and invokes the getAllProducts function with parsed arguments.
    if (name === 'fakestore_get_products') { const result = await getAllProducts(args as { limit?: number; sort?: 'asc' | 'desc' }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • Input schema and metadata definition for the fakestore_get_products tool, used for tool listing and argument validation.
    { name: 'fakestore_get_products', description: 'Get all products from the store. Optionally limit results and sort by price.', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Limit the number of products returned', }, sort: { type: 'string', enum: ['asc', 'desc'], description: 'Sort products by price (asc or desc)', }, }, }, },
  • src/index.ts:40-44 (registration)
    Registers the fakestore_get_products tool (via productTools) in the MCP server's listTools response.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });

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