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';

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