Skip to main content
Glama
BuyWhere

BuyWhere

Official

compare_prices

Compare 2 to 5 products to identify differences, price range, pros/cons, and the best-value option. Automates product comparison for informed decisions.

Instructions

Compare 2–5 products side-by-side. Returns structured differentiators, price range, pros/cons, and a best-value recommendation — purpose-built for AI agent decision-making.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
product_idsYesArray of 2–5 BuyWhere product IDs to compare

Implementation Reference

  • src/index.ts:242-260 (registration)
    Registration of compare_prices tool in the ListToolsRequestSchema handler. Defines the tool name, description, and input schema (product_ids array of 2–5 strings).
    {
      name: "compare_prices",
      description:
        "Compare 2–5 products side-by-side. Returns structured differentiators, price range, " +
        "pros/cons, and a best-value recommendation — purpose-built for AI agent decision-making.",
      inputSchema: {
        type: "object",
        properties: {
          product_ids: {
            type: "array",
            items: { type: "string" },
            description: "Array of 2–5 BuyWhere product IDs to compare",
            minItems: 2,
            maxItems: 5,
          },
        },
        required: ["product_ids"],
      },
    },
  • Handler for compare_prices tool. Validates 2–5 product_ids, calls POST /v1/products/compare API, then formats the response showing product details, price range, best value recommendation, and key differentiators.
    // ── compare_prices ───────────────────────────────────────────────────────
    if (name === "compare_prices") {
      const productIds = args.product_ids as string[] | undefined;
      if (!productIds || productIds.length < 2) {
        throw new McpError(ErrorCode.InvalidParams, "product_ids must be an array of 2–5 product IDs");
      }
      if (productIds.length > 5) {
        throw new McpError(ErrorCode.InvalidParams, "compare_prices supports at most 5 products at once");
      }
    
      const data = (await apiFetch("/v1/products/compare", { ids: productIds.join(",") })) as Record<string, unknown>;
      const products = (data.products as Array<Record<string, unknown>>) ?? [];
      const comparison = data.comparison as Record<string, unknown> | undefined;
    
      const lines: string[] = [`**Product comparison (${products.length} items):**\n`];
    
      for (const p of products) {
        const price = p.price as Record<string, unknown> | undefined;
        lines.push(
          `**${p.title ?? p.name}** (ID: ${p.product_id ?? p.id})`,
          `  Price: ${price?.currency ?? "SGD"} ${price?.amount ?? "N/A"}`,
          `  Category: ${p.category ?? ""}`,
          `  Merchant: ${(p.merchant as Record<string, unknown>)?.name ?? ""}`,
          `  URL: ${p.source_url ?? ""}`,
          "",
        );
      }
    
      if (comparison) {
        const priceRange = comparison.price_range as Record<string, unknown> | undefined;
        if (priceRange) {
          lines.push(`**Price range:** ${priceRange.currency ?? "SGD"} ${priceRange.min} – ${priceRange.max}`);
        }
        const bestValue = comparison.best_value as Record<string, unknown> | undefined;
        if (bestValue) {
          lines.push(`**Best value:** ${bestValue.title ?? bestValue.product_id} — ${bestValue.rationale ?? ""}`);
        }
        const differentiators = comparison.differentiators as string[] | undefined;
        if (differentiators?.length) {
          lines.push(`\n**Key differences:**`);
          for (const d of differentiators) {
            lines.push(`  • ${d}`);
          }
        }
      }
    
      return {
        content: [{ type: "text", text: lines.join("\n") }],
      };
    }
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses that the tool returns structured data including differentiators and a recommendation, indicating a read-only operation without side effects. No hidden behaviors are mentioned, but the description is adequate.

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 sentence that efficiently conveys the tool's purpose and outputs with no superfluous words. Front-loaded with key action and resource.

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

Completeness5/5

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

For a simple tool with one parameter and no output schema, the description sufficiently covers what the tool does and what it returns. An agent can accurately decide to invoke it for multi-product comparisons.

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 input schema already provides a description for 'product_ids' (array of 2-5 strings). The description adds 'BuyWhere' specificity, but does not significantly enhance understanding beyond the schema. Schema coverage is 100%, so baseline 3 is appropriate.

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

Purpose5/5

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

The description clearly states the tool compares 2-5 products side-by-side and lists specific outputs (differentiators, price range, pros/cons, recommendation). It distinguishes itself from sibling tools like get_price and get_product which handle single products.

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

Usage Guidelines4/5

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

The description implies use for multi-product comparison and mentions it is 'purpose-built for AI agent decision-making.' It does not explicitly state when not to use it or name alternatives, but the context from sibling tools makes it clear.

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/BuyWhere/buywhere-mcp'

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