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
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'optional filtering and pagination,' which hints at read-only behavior and some constraints, but it doesn't detail important aspects like rate limits, authentication needs, error handling, or the format of returned data. For a tool with 8 parameters and no annotations, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that clearly states the tool's purpose and key features (filtering and pagination). It is front-loaded with the main action and avoids unnecessary details, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of 8 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns, how results are structured, or any behavioral traits beyond basic functionality. For a tool with this level of detail in the schema but lacking output information, more context is needed to be complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, meaning all parameters are well-documented in the input schema. The description adds minimal value beyond this by mentioning 'optional filtering and pagination,' which loosely corresponds to parameters like skip and limit, but it doesn't provide additional semantic context or examples. This meets the baseline score of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get a list of products' specifies the verb (get) and resource (products). It also mentions optional filtering and pagination, which adds useful context. However, since there are no sibling tools, it doesn't need to differentiate from alternatives, so it doesn't reach the highest score of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives or any specific contexts for usage. It mentions optional filtering and pagination, but this is more about functionality than usage scenarios. Without any explicit when/when-not instructions or prerequisites, it falls short of higher scores.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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