get_top_deals
Retrieve trending deals from multiple sources like Slickdeals and RapidAPI. Filter by specific sources or set a limit to find the best offers for comparison.
Instructions
Get top/trending deals from all or specific sources
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of deals to return | |
| sources | No | Specific sources to get deals from |
Implementation Reference
- src/server.ts:315-342 (handler)The primary handler function for the 'get_top_deals' MCP tool. It extracts limit and sources from arguments, fetches top deals via the aggregator, formats them into a JSON response, and returns it in the expected MCP content structure.private async handleGetTopDeals(args: any) { const { limit = 20, sources } = args; const deals = await this.aggregator.getTopDeals(limit, sources); return { content: [ { type: 'text', text: JSON.stringify({ success: true, results: deals.length, deals: deals.map(deal => ({ id: deal.id, title: deal.title, price: deal.price, originalPrice: deal.originalPrice, discountPercentage: deal.discountPercentage, rating: deal.rating, store: deal.store, url: deal.url, source: deal.source, popularity: deal.popularity })) }, null, 2), }, ], }; }
- src/server.ts:179-197 (registration)Tool registration definition returned by listTools, including name, description, and input schema for the 'get_top_deals' tool.{ name: 'get_top_deals', description: 'Get top/trending deals from all or specific sources', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum number of deals to return', default: 20, }, sources: { type: 'array', items: { type: 'string' }, description: 'Specific sources to get deals from', }, }, }, },
- src/services/aggregator.ts:42-63 (helper)Core helper method in the DealAggregator service that fetches top deals in parallel from selected providers, aggregates them, sorts by popularity, and limits the results.async getTopDeals(limit: number = 20, sources?: string[]): Promise<Deal[]> { const selectedProviders = sources && sources.length > 0 ? sources.filter(source => this.providers.has(source)) : Array.from(this.providers.keys()); const dealPromises = selectedProviders.map(async (providerName) => { const provider = this.providers.get(providerName); if (!provider) return []; try { return await provider.getTopDeals(Math.ceil(limit / selectedProviders.length)); } catch (error) { console.error(`Error getting top deals from ${providerName}:`, error); return []; } }); const results = await Promise.all(dealPromises); const allDeals = results.flat(); return this.sortDeals(allDeals, 'popularity', 'desc').slice(0, limit); }