send_image
Send images via WhatsApp with optional captions, footers, and reply functionality using the PyWA MCP Server.
Instructions
Send an image message.
Args: to: Phone number or WhatsApp ID image: Image URL or media ID caption: Optional image caption footer: Optional footer text reply_to_message_id: Message ID to reply to
Returns: Dictionary with success status and message ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | ||
| image | Yes | ||
| caption | No | ||
| footer | No | ||
| reply_to_message_id | No |
Implementation Reference
- tools/messaging.py:62-98 (handler)The send_image tool handler function - implements the core logic for sending image messages to WhatsApp users. It takes parameters (to, image, caption, footer, reply_to_message_id), calls the WhatsApp client's send_image method, and returns a success status with message ID or error details.@mcp.tool() async def send_image( to: str, image: str, caption: Optional[str] = None, footer: Optional[str] = None, *, reply_to_message_id: Optional[str] = None, ) -> dict: """ Send an image message. Args: to: Phone number or WhatsApp ID image: Image URL or media ID caption: Optional image caption footer: Optional footer text reply_to_message_id: Message ID to reply to Returns: Dictionary with success status and message ID """ try: result = wa_client.send_image( to=to, image=image, caption=caption, footer=footer, reply_to_message_id=reply_to_message_id, ) logger.info(f"Image sent to {to}") message_id = getattr(result, 'id', str(result)) if result else None return {"success": True, "message_id": message_id} except Exception as e: logger.error(f"Failed to send image: {str(e)}") return {"success": False, "error": str(e)}
- tools/messaging.py:62-62 (registration)The send_image tool is registered with MCP using the @mcp.tool() decorator, which exposes it as an available tool in the Model Context Protocol server.@mcp.tool()