Skip to main content
Glama

Superprecio MCP Server

by bunkerapps
getMyAlerts.tsβ€’3.48 kB
/** * MCP Tool: Get My Alerts * Get all price alerts with their current status */ import type { SuperPrecioApiClient } from '../client/superPrecioApi.js'; export const getMyAlertsTool = { name: 'get_my_alerts', description: `Get all your active price alerts with their current status. View all products you're monitoring and see: - Current prices vs. target prices - Which alerts have been triggered - How close you are to your target price - Last time prices were checked Perfect for: - Reviewing all your alerts - Finding triggered alerts (good deals!) - Managing your watchlist`, inputSchema: { type: 'object', properties: { userId: { type: 'number', description: 'Optional: Filter alerts by user ID', }, isActive: { type: 'boolean', description: 'Optional: Filter by active/inactive alerts (default: show all)', }, }, }, }; export async function executeGetMyAlerts( client: SuperPrecioApiClient, args: { userId?: number; isActive?: boolean } ) { const response = await client.getPriceAlerts(args); if (!response.success) { return { content: [ { type: 'text', text: `Failed to get price alerts: ${response.message || 'Unknown error'}`, }, ], isError: true, }; } const alerts = response.data; const count = response.count || 0; if (count === 0) { return { content: [ { type: 'text', text: ` No price alerts found. Create your first alert with set_price_alert! Example: Alert me when Coca Cola drops below $800 `, }, ], }; } const triggeredCount = alerts.filter((a: any) => a.currentPrice && a.currentPrice <= a.targetPrice).length; const summary = ` πŸ”” Your Price Alerts (${count} total) ${triggeredCount > 0 ? `πŸŽ‰ ${triggeredCount} ALERT${triggeredCount === 1 ? '' : 'S'} TRIGGERED!` : ''} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ${alerts .map((alert: any, i: number) => { const isTriggered = alert.currentPrice && alert.currentPrice <= alert.targetPrice; const status = isTriggered ? 'πŸŽ‰ TRIGGERED!' : alert.currentPrice ? 'πŸ” Monitoring' : '⏳ Pending check'; const priceDiff = alert.currentPrice ? (alert.currentPrice - alert.targetPrice) : null; return ` ${i + 1}. ${alert.productName} (ID: ${alert.id}) ${status} 🎯 Target: $${alert.targetPrice.toLocaleString('es-AR')} ${alert.currentPrice ? `πŸ’΅ Current: $${alert.currentPrice.toLocaleString('es-AR')}${priceDiff !== null ? ` (${priceDiff >= 0 ? '+' : ''}$${priceDiff.toFixed(2)})` : ''}` : 'πŸ’΅ Current: Not checked yet'} ${alert.barcode ? `🏷️ Barcode: ${alert.barcode}` : ''} ${alert.notifyEnabled ? 'πŸ””' : 'πŸ”•'} Notifications ${alert.isActive ? 'βœ…' : '⏸️'} ${alert.isActive ? 'Active' : 'Paused'} ${alert.lastCheckedAt ? `πŸ“… Last checked: ${new Date(alert.lastCheckedAt).toLocaleDateString('es-AR')}` : ''} `; }) .join('\n')} Actions you can take: - Use check_alert_status to update current prices - Use remove_price_alert to delete an alert ${triggeredCount > 0 ? '\nπŸ›’ Good news! You have triggered alerts - great time to shop!' : ''} `; return { content: [ { type: 'text', text: summary, }, { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; }

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