Skip to main content
Glama

compare_deals

Analyze and contrast similar deals to identify optimal choices using the Bargainer MCP Server.

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 tool list, including name, description, and input schema.
    { 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'], }, },
  • MCP tool handler for 'compare_deals' that extracts input deals, calls the aggregator's compareDeals method, and returns a formatted JSON 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 implementation of deal comparison: groups deals by normalized titles, sorts similar deals by price then rating, and selects the best one 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; }
  • Input schema definition for the 'compare_deals' tool, specifying an object with a required 'deals' array.
    inputSchema: { type: 'object', properties: { deals: { type: 'array', description: 'Array of deals to compare', }, }, required: ['deals'], },

Other Tools

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

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