send_notification
Send push notifications to specific devices or broadcast alerts to all users about price drops, deals, and important shopping updates with custom data like product links.
Instructions
Send a push notification to a specific device or broadcast to all subscribed devices.
This tool can:
Send personalized notifications to specific devices
Broadcast alerts to all users
Include custom data (like product links, images, etc.)
Notify about price drops, deals, or important updates
Note: Requires Firebase Cloud Messaging setup on the Superprecio server.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | Optional: additional data to include (e.g., product URL, image URL) | |
| deviceToken | No | Optional: specific device token to send to. If not provided, broadcasts to all devices. | |
| message | Yes | Notification body/message | |
| title | Yes | Notification title |
Implementation Reference
- src/tools/sendNotification.ts:42-105 (handler)The primary handler function for the 'send_notification' tool. It processes input arguments, sends notifications (targeted or broadcast) using the SuperPrecioApiClient, formats MCP-compliant responses, and handles errors.export async function executeSendNotification( client: SuperPrecioApiClient, args: { title: string; message: string; deviceToken?: string; data?: Record<string, any>; } ) { if (!args) { throw new Error('Missing required arguments'); } const { title, message, deviceToken, data } = args; try { let result; if (deviceToken) { // Send to specific device result = await client.sendNotification({ token: deviceToken, title, body: message, data, }); return { content: [ { type: 'text', text: `Notification sent successfully to device!\n\nTitle: ${title}\nMessage: ${message}`, }, ], }; } else { // Broadcast to all devices result = await client.broadcastNotification({ title, body: message, data, }); return { content: [ { type: 'text', text: `Notification broadcast successfully to all devices!\n\nTitle: ${title}\nMessage: ${message}\n\nResult: ${JSON.stringify(result, null, 2)}`, }, ], }; } } catch (error: any) { return { content: [ { type: 'text', text: `Failed to send notification: ${error.message}`, }, ], isError: true, }; } }
- src/tools/sendNotification.ts:7-40 (schema)Tool definition object containing name, description, and inputSchema for validation of tool parameters.export const sendNotificationTool = { name: 'send_notification', description: `Send a push notification to a specific device or broadcast to all subscribed devices. This tool can: - Send personalized notifications to specific devices - Broadcast alerts to all users - Include custom data (like product links, images, etc.) - Notify about price drops, deals, or important updates Note: Requires Firebase Cloud Messaging setup on the Superprecio server.`, inputSchema: { type: 'object', properties: { title: { type: 'string', description: 'Notification title', }, message: { type: 'string', description: 'Notification body/message', }, deviceToken: { type: 'string', description: 'Optional: specific device token to send to. If not provided, broadcasts to all devices.', }, data: { type: 'object', description: 'Optional: additional data to include (e.g., product URL, image URL)', }, }, required: ['title', 'message'], }, };
- src/index.ts:97-97 (registration)The sendNotificationTool is included in the list of available tools served by the MCP server's ListToolsRequestSchema handler.sendNotificationTool,
- src/index.ts:137-138 (registration)Registration of the tool handler in the switch statement for CallToolRequestSchema, dispatching execution to executeSendNotification.case 'send_notification': return await executeSendNotification(apiClient, args as any);
- src/index.ts:33-33 (registration)Import statement bringing in the tool definition and handler function for use in the MCP server.import { sendNotificationTool, executeSendNotification } from './tools/sendNotification.js';