|
| 1 | +# OWL WhatsApp MCP Integration |
| 2 | + |
| 3 | +This project demonstrates a use case connecting **OWL** (from [CAMEL-AI.org](https://camel-ai.org)) with the **WhatsApp MCP Server**. It enables fully automated, agentic replies within messaging apps—without needing predefined workflows or manual tool selection. Simply send a plain message and let the system handle the rest. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +### What It Does |
| 10 | + |
| 11 | +- **Automated, Agentic Messaging:** |
| 12 | + OWL interacts with the WhatsApp MCP server in real time. Roleplay agents infer the intent behind your messages, automatically selecting the correct toolkit to generate and send responses. |
| 13 | + |
| 14 | +- **Seamless Communication Integration:** |
| 15 | + This integration demonstrates how intelligent agents can operate across different communication platforms with zero manual orchestration. |
| 16 | + |
| 17 | +### Key Features |
| 18 | + |
| 19 | +- **No Predefined Workflow:** |
| 20 | + No need for rigid, pre-set procedures. The system dynamically handles each conversation. |
| 21 | + |
| 22 | +- **Zero Tool Selection Required:** |
| 23 | + Simply send a message; the right toolkit is autonomously selected based on the agent’s inference. |
| 24 | + |
| 25 | +- **Real-Time Interaction:** |
| 26 | + OWL continuously communicates with the WhatsApp MCP server to access message histories, send replies, and manage media files. |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## Technology Stack |
| 31 | + |
| 32 | +- **OWL Framework:** |
| 33 | + An open-source multi-agent collaboration framework from [CAMEL-AI](https://github.com/camel-ai/owl). |
| 34 | +- **WhatsApp MCP Server:** |
| 35 | + An MCP (Model Context Protocol) server that connects directly to WhatsApp via the WhatsApp Web multi-device API. Explore the project on [GitHub](https://github.com/lharries/whatsapp-mcp). |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## How It Works |
| 40 | + |
| 41 | +1. **Message Processing:** |
| 42 | + - A plain text message is sent by a user via a messaging app. |
| 43 | + - The OWL framework receives the message and activates roleplay agents. |
| 44 | + |
| 45 | +2. **Agent Collaboration:** |
| 46 | + - Agents, acting in different roles, infer the intent and formulate a response. |
| 47 | + - The appropriate toolkit is dynamically selected. |
| 48 | + |
| 49 | +3. **Automated Reply:** |
| 50 | + - The system communicates in real time with the WhatsApp MCP server. |
| 51 | + - The response is generated and sent back to the messaging app autonomously. |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## Getting Started |
| 56 | + |
| 57 | +### Prerequisites |
| 58 | + |
| 59 | +- **Go:** Required for the WhatsApp Bridge component. |
| 60 | +- **Python 3.6+:** For running the MCP server and OWL integration. |
| 61 | +- **UV Package Manager:** Install with: |
| 62 | + ```sh |
| 63 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
| 64 | + ``` |
| 65 | +- **FFmpeg (Optional):** Needed for converting and sending audio messages in the correct format (e.g., .ogg Opus). |
| 66 | + |
| 67 | +### Installation Steps |
| 68 | + |
| 69 | +1. **Clone Repositories:** |
| 70 | + - OWL Framework: |
| 71 | + ```sh |
| 72 | + git clone https://github.com/camel-ai/owl.git |
| 73 | + ``` |
| 74 | + - WhatsApp MCP Server: |
| 75 | + ```sh |
| 76 | + git clone https://github.com/lharries/whatsapp-mcp.git |
| 77 | + ``` |
| 78 | + |
| 79 | +2. **Set Up the WhatsApp Bridge:** |
| 80 | + - Navigate to the WhatsApp bridge directory: |
| 81 | + ```sh |
| 82 | + cd whatsapp-mcp/whatsapp-bridge |
| 83 | + go run main.go |
| 84 | + ``` |
| 85 | + - **Authentication:** |
| 86 | + On first run, scan the provided QR code using your WhatsApp app. (Re-authentication may be required after ~20 days.) |
| 87 | + |
| 88 | +3. **Configure MCP Server Integration:** |
| 89 | + - Create a JSON configuration file (e.g., `claude_desktop_config.json` or `mcp.json`) with the following content (ensure you replace the placeholder paths): |
| 90 | + ```json |
| 91 | + { |
| 92 | + "mcpServers": { |
| 93 | + "whatsapp": { |
| 94 | + "command": "<PATH_TO_UV>", |
| 95 | + "args": [ |
| 96 | + "--directory", |
| 97 | + "<PATH_TO_REPO>/whatsapp-mcp/whatsapp-mcp-server", |
| 98 | + "run", |
| 99 | + "main.py" |
| 100 | + ] |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + ``` |
| 105 | + - Place this file in your Claude Desktop configuration directory or your Cursor configuration directory as appropriate. |
| 106 | + |
| 107 | +4. **Running the OWL MCP Integration:** |
| 108 | + - With the WhatsApp Bridge running and MCP configuration set up, start your OWL-powered agent system: |
| 109 | + ```sh |
| 110 | + python owl/community_usecase/Whatsapp-MCP/app.py |
| 111 | + ``` |
| 112 | + - The OWL framework will connect to the MCP server and be ready to process incoming messages. |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## Deep Dive: MCP & OWL Integration |
| 117 | + |
| 118 | +### MCP Overview |
| 119 | +- **What is MCP?** |
| 120 | + MCP (Model Context Protocol) standardizes communication between AI models and external tools and data sources. Learn more at the [MCP Documentation](https://modelcontextprotocol.io/introduction). |
| 121 | + |
| 122 | +- **Basic Architecture:** |
| 123 | + MCP uses a client-server model, where a host application communicates with multiple MCP servers to seamlessly access local and remote data sources. |
| 124 | + |
| 125 | +### OWL Framework |
| 126 | +- **Role-Playing Agents:** |
| 127 | + OWL leverages roleplay agents that deconstruct tasks and work collaboratively, ensuring robust automation. |
| 128 | + |
| 129 | +- **Real-Time Decision-Making:** |
| 130 | + Using methods such as POMDP (Partially Observable Markov Decision Processes), OWL optimizes decisions dynamically. |
| 131 | + |
| 132 | +- **Multi-Modal Tool Integration:** |
| 133 | + From web data scraping to code execution and document processing, OWL integrates various toolkits to empower agent collaboration. |
| 134 | + |
| 135 | +### Code Example Snippet |
| 136 | + |
| 137 | +Below is a simplified version of how to initialize and connect to the MCP toolkit: |
| 138 | + |
| 139 | +```python |
| 140 | +from pathlib import Path |
| 141 | +from mcp_toolkit import MCPToolkit |
| 142 | +
|
| 143 | +# Load configuration and initialize MCP toolkit |
| 144 | +config_path = Path(__file__).parent / "mcp_servers_config.json" |
| 145 | +mcp_toolkit = MCPToolkit(config_path=str(config_path)) |
| 146 | +
|
| 147 | +# Establish asynchronous connection |
| 148 | +await mcp_toolkit.connect() |
| 149 | +``` |
| 150 | + |
| 151 | +Then, construct the agent environment and run the task: |
| 152 | + |
| 153 | +```python |
| 154 | +question = ( |
| 155 | + "I'd like an academic report about Andrew Ng, including his research direction, " |
| 156 | + "published papers, and affiliated institutions. Organize the report in Markdown format and save it to my desktop." |
| 157 | +) |
| 158 | +tools = list(mcp_toolkit.get_tools()) |
| 159 | +society = await construct_society(question, tools) |
| 160 | +answer, chat_history, token_count = await run_society(society) |
| 161 | +print(f"Answer: {answer}") |
| 162 | +``` |
| 163 | + |
| 164 | +For a complete guide on using MCP with the OWL framework, please refer to [the detailed guide](https://www.camel-ai.org/blogs/owl-mcp-toolkit-practice). |
| 165 | + |
| 166 | +--- |
| 167 | + |
| 168 | +## WhatsApp MCP Server Details |
| 169 | + |
| 170 | +- **Capabilities:** |
| 171 | + - **Message Management:** Search, read, and send messages including media (images, videos, documents, audio). |
| 172 | + - **Media Handling:** Supports conversion (with FFmpeg) and downloading of media files. |
| 173 | + |
| 174 | +- **Architecture:** |
| 175 | + - **Go WhatsApp Bridge:** Connects to WhatsApp’s Web API, handles QR code authentication, and stores messages locally using SQLite. |
| 176 | + - **Python MCP Server:** Implements the MCP protocol to relay communications between OWL agents and WhatsApp. |
| 177 | + |
| 178 | +- **Installation & Running:** |
| 179 | + - Follow the instructions under the **Installation Steps** section above. |
| 180 | + - Additional details and troubleshooting tips are available in the [WhatsApp MCP GitHub repository](https://github.com/lharries/whatsapp-mcp). |
| 181 | + |
| 182 | +--- |
| 183 | + |
| 184 | +## Troubleshooting & FAQs |
| 185 | + |
| 186 | +- **QR Code Not Displaying:** |
| 187 | + Ensure your terminal supports displaying QR codes, or try restarting the authentication script. |
| 188 | + |
| 189 | +- **Device Limit Issues:** |
| 190 | + If you reach the maximum number of devices on WhatsApp, remove an existing device from your phone’s linked devices settings. |
| 191 | + |
| 192 | +- **Running on Windows:** |
| 193 | + For Windows setups, ensure that CGO is enabled and a C compiler (e.g., through MSYS2) is installed. See the [Windows Compatibility Guide](#) for step-by-step instructions. |
| 194 | + |
| 195 | +--- |
| 196 | + |
| 197 | +## References & Further Reading |
| 198 | + |
| 199 | +- **MCP Documentation:** [modelcontextprotocol.io](https://modelcontextprotocol.io/introduction) |
| 200 | +- **CAMEL-AI MCP:** [camel-ai.org/mcp](https://www.camel-ai.org/mcp) |
| 201 | +- **WhatsApp MCP Server Repository:** [GitHub](https://github.com/lharries/whatsapp-mcp) |
| 202 | +- **OWL Framework Repository:** [GitHub](https://github.com/camel-ai/owl) |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | + |
| 207 | + |
0 commit comments