get_my_alerts
Retrieve and monitor active price alerts to track current prices versus target prices, identify triggered deals, and manage your product watchlist for supermarket shopping in Argentina.
Instructions
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
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | No | Optional: Filter alerts by user ID | |
| isActive | No | Optional: Filter by active/inactive alerts (default: show all) |
Implementation Reference
- src/tools/getMyAlerts.ts:36-116 (handler)The main handler function that executes the tool logic: fetches price alerts via API client, handles errors, formats a detailed summary with alert statuses, triggered counts, and returns formatted text content including JSON data.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), }, ], }; }
- src/tools/getMyAlerts.ts:7-34 (schema)Tool schema definition including name 'get_my_alerts', detailed description, and inputSchema with optional parameters for filtering alerts by userId and isActive status.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)', }, }, }, };
- src/index.ts:89-116 (registration)Registration of the tool in the MCP server's listTools handler, where getMyAlertsTool is included in the array of available tools.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ // V1 Tools searchProductsTool, searchByCodeTool, comparePriceTool, getBestDealsTool, sendNotificationTool, subscribeDeviceTool, // V2 Tools - Shopping Lists createShoppingListTool, addItemsToListTool, getShoppingListsTool, optimizeShoppingListTool, removeShoppingListTool, // V2 Tools - Price Alerts setPriceAlertTool, getMyAlertsTool, removePriceAlertTool, // V2 Tools - Location findNearbySupermarketsTool, ], }; });
- src/index.ts:163-164 (registration)Dispatch/execution routing in the main CallToolRequestSchema handler that maps 'get_my_alerts' to the executeGetMyAlerts function.case 'get_my_alerts': return await executeGetMyAlerts(apiClient, args as any);