Skip to main content
Glama
bunkerapps

Superprecio MCP Server

by bunkerapps

compare_prices

Analyze product prices across supermarkets to identify the lowest price, calculate potential savings, and make informed buying decisions.

Instructions

Compare prices for a product across all supermarkets and find the best deal.

This tool analyzes prices and provides:

  • Lowest price and which supermarket has it

  • Highest price for comparison

  • Average price across all stores

  • Potential savings

  • Price differences between stores

Perfect for making informed buying decisions and finding the best deals.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productNameYesProduct name to compare (e.g., "arroz tio pelon")
maxResultsNoNumber of results to analyze per store (default: 5)

Implementation Reference

  • The executeComparePrice function that implements the core logic of the 'compare_prices' tool. It searches for products across supermarkets, aggregates prices, calculates statistics (lowest, highest, average, savings), generates a formatted summary, and returns both text and JSON content.
    export async function executeComparePrice(
      client: SuperPrecioApiClient,
      args: { productName: string; maxResults?: number }
    ) {
      if (!args) {
        throw new Error('Missing required arguments');
      }
    
      const { productName, maxResults = 5 } = args;
    
      const response = await client.searchProducts({
        search: productName,
        maxResults,
        order: 'OrderByPriceASC', // Sort by price ascending to find best deals
      });
    
      // Collect all products with prices
      const allProducts: Array<{
        market: string;
        logo: string;
        price: number;
        name: string;
        link: string;
        img: string;
      }> = [];
    
      response.allData.forEach((marketProducts, idx) => {
        const market = response.markets[idx];
        if (marketProducts && marketProducts.length > 0) {
          marketProducts.forEach((product) => {
            allProducts.push({
              market: market.name,
              logo: market.logo,
              price: product.price,
              name: product.desc,
              link: product.link,
              img: product.img,
            });
          });
        }
      });
    
      if (allProducts.length === 0) {
        return {
          content: [
            {
              type: 'text',
              text: `No products found for "${productName}". Try a different search term.`,
            },
          ],
        };
      }
    
      // Find lowest and highest prices
      const sortedByPrice = [...allProducts].sort((a, b) => a.price - b.price);
      const lowest = sortedByPrice[0];
      const highest = sortedByPrice[sortedByPrice.length - 1];
    
      // Calculate average
      const averagePrice =
        allProducts.reduce((sum, p) => sum + p.price, 0) / allProducts.length;
    
      // Calculate savings
      const savings = highest.price - lowest.price;
      const savingsPercent = ((savings / highest.price) * 100).toFixed(1);
    
      const comparison: ProductComparison = {
        productName,
        markets: allProducts.map((p) => ({
          market: p.market,
          logo: p.logo,
          price: p.price,
          link: p.link,
          img: p.img,
        })),
        lowestPrice: {
          market: lowest.market,
          price: lowest.price,
          savings: savings,
        },
        highestPrice: {
          market: highest.market,
          price: highest.price,
        },
        averagePrice: parseFloat(averagePrice.toFixed(2)),
      };
    
      const summary = `
    Price Comparison for "${productName}"
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    
    🏆 BEST DEAL: ${lowest.market}
       $${lowest.price.toLocaleString('es-AR')}
    
    💰 POTENTIAL SAVINGS: $${savings.toLocaleString('es-AR')} (${savingsPercent}%)
       vs. highest price at ${highest.market}
    
    📊 AVERAGE PRICE: $${averagePrice.toLocaleString('es-AR')}
    
    📍 FOUND IN ${response.columns} SUPERMARKETS
    
    Price Breakdown:
    ${sortedByPrice
      .map(
        (p, i) =>
          `${i + 1}. ${p.market}: $${p.price.toLocaleString('es-AR')} ${i === 0 ? '🏆 BEST' : ''}`
      )
      .join('\n')}
    `;
    
      return {
        content: [
          {
            type: 'text',
            text: summary,
          },
          {
            type: 'text',
            text: JSON.stringify(comparison, null, 2),
          },
        ],
      };
    }
  • The comparePriceTool object defines the tool name, description, and input schema for the 'compare_prices' tool used for MCP tool listing and validation.
    export const comparePriceTool = {
      name: 'compare_prices',
      description: `Compare prices for a product across all supermarkets and find the best deal.
    
    This tool analyzes prices and provides:
    - Lowest price and which supermarket has it
    - Highest price for comparison
    - Average price across all stores
    - Potential savings
    - Price differences between stores
    
    Perfect for making informed buying decisions and finding the best deals.`,
      inputSchema: {
        type: 'object',
        properties: {
          productName: {
            type: 'string',
            description: 'Product name to compare (e.g., "arroz tio pelon")',
          },
          maxResults: {
            type: 'number',
            description: 'Number of results to analyze per store (default: 5)',
            minimum: 1,
            maximum: 20,
            default: 5,
          },
        },
        required: ['productName'],
      },
    };
  • src/index.ts:131-132 (registration)
    Registration of the 'compare_prices' tool in the main switch statement that dispatches tool calls to the appropriate handler function.
    case 'compare_prices':
      return await executeComparePrice(apiClient, args as any);
  • src/index.ts:95-95 (registration)
    Inclusion of the comparePriceTool in the list of available tools returned by ListToolsRequestHandler.
    comparePriceTool,
  • src/index.ts:31-31 (registration)
    Import statement that brings in the tool schema and handler function for use in the MCP server.
    import { comparePriceTool, executeComparePrice } from './tools/comparePrice.js';
Behavior2/5

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

No annotations are provided, so the description carries full burden. It describes what the tool provides (lowest price, highest price, average, savings, differences) but doesn't disclose behavioral traits like whether it requires authentication, rate limits, data freshness, or error conditions. The description adds value by outlining outputs but misses key operational context.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The bulleted list efficiently details outputs, and the final sentence reinforces use case. Minor redundancy exists (e.g., 'find the best deal' and 'best deals'), but overall structure is clear with minimal waste.

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

Completeness3/5

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

Given no annotations and no output schema, the description partially compensates by listing output details. However, for a tool with 2 parameters and complex price comparison logic, it lacks completeness regarding behavioral constraints (e.g., data sources, update frequency) and error handling. It's adequate but has clear gaps in operational context.

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?

Schema description coverage is 100%, providing clear parameter documentation. The description doesn't add meaning beyond the schema (e.g., it doesn't explain how 'productName' matching works or 'maxResults' implications). With high schema coverage, baseline 3 is appropriate as the description doesn't compensate but doesn't detract either.

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's purpose with specific verbs ('compare prices', 'find the best deal') and resources ('product across all supermarkets'). It distinguishes from siblings like 'get_best_deals' by focusing on price comparison for a specific product rather than general deals, and from 'search_products' by emphasizing comparative analysis rather than basic search.

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

Usage Guidelines3/5

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

The description implies usage context ('perfect for making informed buying decisions') but doesn't explicitly state when to use this tool versus alternatives like 'get_best_deals' (which might show deals without product-specific comparison) or 'search_products' (which might return product info without price analysis). No explicit exclusions or prerequisites are provided.

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/bunkerapps/superprecio_mcp'

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