subscribe_device
Register a device to receive price drop alerts, special deal notifications, and promotional messages from Superprecio's price comparison service.
Instructions
Subscribe a device to receive push notifications about deals and price alerts.
This tool registers a device token with the Superprecio notification system. Once subscribed, devices will receive:
Price drop alerts
Special deal notifications
New product announcements
Custom promotional messages
Note: Requires a valid Firebase Cloud Messaging device token.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceToken | Yes | Firebase Cloud Messaging device token |
Implementation Reference
- src/tools/subscribeDevice.ts:31-63 (handler)The main handler function that executes the subscribe_device tool logic. It validates arguments, calls the API client's subscribeDevice method, formats success/error responses.export async function executeSubscribeDevice( client: SuperPrecioApiClient, args: { deviceToken: string } ) { if (!args) { throw new Error('Missing required arguments'); } const { deviceToken } = args; try { const result = await client.subscribeDevice(deviceToken); return { content: [ { type: 'text', text: `Device subscribed successfully!\n\nYou will now receive notifications about:\n- Price drops\n- Special deals\n- New products\n- Promotional offers\n\nDevice Token: ${deviceToken.substring(0, 20)}...\n\nResult: ${JSON.stringify(result, null, 2)}`, }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Failed to subscribe device: ${error.message}`, }, ], isError: true, }; } }
- src/tools/subscribeDevice.ts:7-29 (schema)Tool definition including name, description, and input schema for validation.export const subscribeDeviceTool = { name: 'subscribe_device', description: `Subscribe a device to receive push notifications about deals and price alerts. This tool registers a device token with the Superprecio notification system. Once subscribed, devices will receive: - Price drop alerts - Special deal notifications - New product announcements - Custom promotional messages Note: Requires a valid Firebase Cloud Messaging device token.`, inputSchema: { type: 'object', properties: { deviceToken: { type: 'string', description: 'Firebase Cloud Messaging device token', }, }, required: ['deviceToken'], }, };
- src/index.ts:140-141 (registration)Registration in the tool execution switch statement in the MCP server.case 'subscribe_device': return await executeSubscribeDevice(apiClient, args as any);
- src/index.ts:98-98 (registration)Inclusion of the tool in the listTools response.subscribeDeviceTool,
- src/client/superPrecioApi.ts:111-118 (helper)API client method that performs the actual HTTP POST to subscribe the device token.async subscribeDevice(token: string): Promise<any> { try { const response = await this.client.post('/devices/suscribe', { token }); return response.data; } catch (error) { throw this.handleError(error); } }