Skip to main content
Glama
Demontie

Products API MCP Server

by Demontie

get_products

Retrieve product listings from the Products API MCP Server with filtering options for ID, title, category, brand, price, and rating, plus pagination controls.

Instructions

Get a list of products with optional filtering and pagination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoFilter products by ID
qNoFilter products by title
categoryNoFilter products by category
brandNoFilter products by brand
priceNoFilter products by price
ratingNoFilter products by rating
skipNoNumber of products to skip
limitNoMaximum number of products to return

Implementation Reference

  • The async handler function that implements the core logic of the 'get_products' tool. It fetches products from the dummyjson.com API, supports search (q) and filtering/pagination parameters, parses the JSON response, and returns a formatted MCP text content response.
    handler: async (params: types.ProductParams): Promise<types.McpResponse> => { try { const { q, ...rest } = params; let result: types.ProductsResponse; let response; if (q) { response = await fetch(`https://dummyjson.com/products/search?q=${q}`, { method: "GET", }); } else { const urlParams = new URLSearchParams(); Object.entries(rest).forEach(([key, value]) => { if (value !== undefined) { urlParams.set(key, value.toString()); } }); response = await fetch( `https://dummyjson.com/products?${urlParams.toString()}`, { method: "GET", } ); } result = await response.json(); if (!result.products) { throw new Error("No results returned from API"); } const content: types.McpTextContent = { type: "text", text: `Products Results:\n\n${JSON.stringify( result.products, null, 2 )}`, }; return { content: [content], }; } catch (error) { console.error(error); throw new Error(`Failed to fetch products: ${error.message} ${error}`); } },
  • Zod-based input schema defining optional parameters for filtering (id, q, category, brand, price, rating) and pagination (skip, limit with defaults) for the get_products tool.
    parameters: { id: z.string().optional().describe("Filter products by ID"), q: z.string().optional().describe("Filter products by title"), category: z.string().optional().describe("Filter products by category"), brand: z.string().optional().describe("Filter products by brand"), price: z.number().optional().describe("Filter products by price"), rating: z.number().optional().describe("Filter products by rating"), skip: z .number() .optional() .default(0) .describe("Number of products to skip"), limit: z .number() .optional() .default(10) .describe("Maximum number of products to return"), },
  • src/index.ts:15-19 (registration)
    Registration of the get_products tool on the MCP server instance using the server.tool method, passing the tool's name, description, parameters schema, and handler function.
    getProductsTool.name, getProductsTool.description, getProductsTool.parameters, getProductsTool.handler );

Other Tools

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/Demontie/my-first-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server