check_sms_status
Check the delivery status and view details of SMS messages sent through the 46elks API using the message ID returned upon sending.
Instructions
Check delivery status and details of a sent SMS
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message_id | Yes | 46elks message ID returned when SMS was sent |
Implementation Reference
- src/index.ts:223-257 (handler)Handler for the 'check_sms_status' tool: validates the message_id parameter, retrieves message details using ElksClient.getMessageById, formats the status information including direction, cost, and timestamps, and returns it as a text response.case 'check_sms_status': const { message_id } = args as { message_id: string; }; if (!message_id || typeof message_id !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'message_id is required and must be a string'); } // Get message status via 46elks const elksClientForStatus = new ElksClient(); const messageDetails = await elksClientForStatus.getMessageById(message_id); const cost = messageDetails.cost ? `${messageDetails.cost / 10000} SEK` : 'N/A'; const date = new Date(messageDetails.created).toLocaleString(); const messageDirection = messageDetails.direction === 'outbound' ? '📤 Sent' : '📥 Received'; let statusText = `📱 SMS Status Check\n\n`; statusText += `${messageDirection} Message\n`; statusText += `ID: ${messageDetails.id}\n`; statusText += `Status: ${messageDetails.status}\n`; statusText += `To: ${messageDetails.to}\n`; statusText += `From: ${messageDetails.from}\n`; statusText += `Created: ${date}\n`; statusText += `Cost: ${cost}\n`; statusText += `Message: ${messageDetails.message}`; return { content: [ { type: 'text', text: statusText } ] };
- src/index.ts:86-99 (registration)Registration of the 'check_sms_status' tool in the list of available tools, including name, description, and input schema requiring 'message_id'.{ name: 'check_sms_status', description: 'Check delivery status and details of a sent SMS', inputSchema: { type: 'object', properties: { message_id: { type: 'string', description: '46elks message ID returned when SMS was sent' } }, required: ['message_id'] } },
- src/elks-client.ts:186-207 (helper)Helper method in ElksClient that performs the API call to retrieve SMS message details by ID from 46elks, handles errors, normalizes the direction field ('outgoing' to 'outbound'), and returns typed ElksMessage.async getMessageById(messageId: string): Promise<ElksMessage> { const response = await fetch(`${this.baseUrl}/sms/${messageId}`, { method: 'GET', headers: { 'Authorization': this.auth, 'Content-Type': 'application/x-www-form-urlencoded' } }); if (!response.ok) { const errorText = await response.text(); throw new Error(`Failed to get message: ${response.status} ${response.statusText} - ${errorText}`); } const message = await response.json(); // Convert API response direction terms to our interface return { ...message, direction: message.direction === 'outgoing' ? 'outbound' : 'inbound' }; }