SendMessageTool

class SendMessageTool(context: Context) : McpTool

Sends an SMS to to with text body via SmsManager (version-checked: system service on API 31+, else getDefault()). The recipient must match phoneRegex or an error is returned; the body is always split with divideMessage/sendMultipartTextMessage. Requires SEND_SMS.

Each part carries an immutable sent-PendingIntent (unique request code, delivered to a non-exported receiver registered for the duration of the call), and the tool waits up to 15 s for the radio to report a result for every part. Output: sent (true only when every part reported RESULT_OK), echoed to, body_length, parts, and status (sent | timeout).

If the radio reports a failure for any part, the tool returns an error (SMS send failed: <reason>). A timeout is deliberately not an error: it returns success with sent: false, status: "timeout" and an error string, because an unconfirmed send may still be delivered and treating it as a failure would invite the caller to resend a duplicate. Exceptions thrown by SmsManager itself (bad address, missing permission) also return a tool error.

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard
open override val annotations: ToolAnnotations
Link copied to clipboard
open override val description: String
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val outputSchema: Map<String, Any>
Link copied to clipboard
open override val parameters: List<ToolParameter>

Functions

Link copied to clipboard
open suspend override fun execute(params: Map<String, Any>): ToolResult