Skip to main content
Glama

compare_deals

Analyze and compare multiple deals to identify optimal choices based on your criteria.

Instructions

Compare similar deals and find the best options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dealsYesArray of deals to compare

Implementation Reference

  • src/server.ts:261-274 (registration)
    Registration of the 'compare_deals' tool in the MCP server's list of available tools, including its input schema definition.
    { name: 'compare_deals', description: 'Compare similar deals and find the best options', inputSchema: { type: 'object', properties: { deals: { type: 'array', description: 'Array of deals to compare', }, }, required: ['deals'], }, },
  • The specific handler function for the 'compare_deals' tool that extracts deals from args, calls the aggregator's compareDeals method, and returns a formatted MCP response.
    private async handleCompareDeals(args: any) { const { deals } = args; const bestDeals = this.aggregator.compareDeals(deals); return { content: [ { type: 'text', text: JSON.stringify({ success: true, original_count: deals.length, best_deals_count: bestDeals.length, best_deals: bestDeals }, null, 2), }, ], }; }
  • Core helper function in DealAggregator that implements the comparison logic: groups deals by normalized titles, sorts groups by price/rating, and selects the best deal from each group.
    compareDeals(deals: Deal[]): Deal[] { // Group deals by similar titles and find best deals const groupedDeals = new Map<string, Deal[]>(); deals.forEach(deal => { const normalizedTitle = this.normalizeTitle(deal.title); if (!groupedDeals.has(normalizedTitle)) { groupedDeals.set(normalizedTitle, []); } groupedDeals.get(normalizedTitle)!.push(deal); }); const bestDeals: Deal[] = []; groupedDeals.forEach(similarDeals => { if (similarDeals.length > 1) { // Sort by price (lowest first) or by rating if prices are similar similarDeals.sort((a, b) => { if (a.price && b.price) { const priceDiff = a.price - b.price; if (Math.abs(priceDiff) < 5) { // If prices are within $5, prefer higher rating return (b.rating || 0) - (a.rating || 0); } return priceDiff; } return (b.rating || 0) - (a.rating || 0); }); } bestDeals.push(similarDeals[0]); }); return bestDeals; }

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/karthiksivaramms/bargainer-mcp-client'

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