send_message
Send WhatsApp messages directly to phone numbers or existing chats. Use this tool to communicate with contacts through automated browser interaction.
Instructions
Send a WhatsApp message using either a phone number or an existing chat name.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| phone_number | No | Recipient phone number in international or local format. | |
| chat_name | No | Visible WhatsApp chat name to open from the sidebar search. | |
| text | Yes | Message body to send. |
Implementation Reference
- The actual implementation of the send_message tool logic.
async def send_message( self, text: str, phone_number: str | None = None, chat_name: str | None = None, ) -> dict[str, Any]: await self._require_ready() assert self._page is not None target = await self._open_target_chat(phone_number=phone_number, chat_name=chat_name, prefill_text=text) await self._wait_for_message_box() if target["type"] == "chat_name": await self._fill_message_box(text) await self._click_first_visible(SEND_BUTTON_SELECTORS) return { "status": "sent", "target": target, "message": text, } - src/whatsapp_mcp/mcp_server.py:180-198 (registration)Registration and definition of the send_message tool in the MCP server.
"send_message": ToolDefinition( name="send_message", description="Send a WhatsApp message using either a phone number or an existing chat name.", input_schema={ "type": "object", "properties": { "phone_number": {"type": "string", "description": "Recipient phone number in international or local format."}, "chat_name": {"type": "string", "description": "Visible WhatsApp chat name to open from the sidebar search."}, "text": {"type": "string", "description": "Message body to send."}, }, "required": ["text"], "additionalProperties": False, }, handler=lambda args: self.client.send_message( text=args["text"], phone_number=args.get("phone_number"), chat_name=args.get("chat_name"), ), ),