A Model Context Protocol server that connects your personal WhatsApp account to AI agents like Claude, enabling them to search messages, view contacts, retrieve chat history, and send messages via WhatsApp.
This is a Model Context Protocol (MCP) server for WhatsApp, built with TypeScript and using the @whiskeysockets/baileys
library.
It allows you to connect your personal WhatsApp account to an AI agent (like Anthropic Claude via its desktop app or Cursor) enabling it to:
It connects directly to your personal WhatsApp account using the WhatsApp Web multi-device API. All your messages and authentication details are stored locally in a SQLite database (./data/
) and authentication cache (./auth_info/
). Data is only sent to the connected AI agent when it explicitly uses the provided MCP tools (which you control via the agent's interface).
(Optional: Consider adding a screenshot or GIF similar to the reference example here)
User: Send a whatsapp message to "Meu amor" in whatsapp saying "Te amo"
Assistant:
Okay, I need to find the contact first.
Using tool: whatsapp.search_contacts
{ "query": "Meu amor" }
Tool Result:
[ { "jid": "5599xxxxxx@s.whatsapp.net", "name": "Meu Amor" } ]
Assistant:
Found the contact. Now sending the message.
Using tool: whatsapp.send_message
{ "recipient": "5599xxxxxx@s.whatsapp.net", "message": "Te amo" }
Tool Result:
Message sent successfully to 5599xxxxxx@s.whatsapp.net (ID: XXXXXXXXXXX).
The server exposes the following tools to the connected AI agent:
search_contacts
: Search for contacts by name or phone number part (JID).list_messages
: Retrieve message history for a specific chat, with pagination.list_chats
: List your chats, sortable by activity or name, filterable, paginated, optionally includes last message details.get_chat
: Get detailed information about a specific chat.get_message_context
: Retrieve messages sent immediately before and after a specific message ID for context.send_message
: Send a text message to a specified recipient JID (user or group).To install WhatsApp MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @jlucaso1/whatsapp-mcp-ts --client claude
package.json
). You can check your version with node -v
. (Has initial typescript and sqlite builtin support)Clone this repository:
git clone whatsapp-mcp-ts cd whatsapp-mcp-ts
Install dependencies:
npm install # or yarn install / pnpm install
Run the server for the first time:
Use node
to run the main script directly.
node src/main.ts
quickchart.io
and attempt to open it in your default browser.auth_info/
directory (this is ignored by git)../data/whatsapp.db
. This might take some time depending on your history size. Check the wa-logs.txt
and console output for progress.You need to tell your AI client how to start this MCP server.
Prepare the configuration JSON:
Copy the following JSON structure. You'll need to replace {{PATH_TO_REPO}}
with the absolute path to the directory where you cloned this repository.
{ "mcpServers": { "whatsapp": { "command": "node", "args": [ "{{PATH_TO_REPO}}/src/main.ts" ], "timeout": 15, // Optional: Adjust startup timeout if needed "disabled": false } } }
whatsapp-mcp-ts
directory in your terminal and run pwd
. Use this output for {{PATH_TO_REPO}}
.Save the configuration file:
claude_desktop_config.json
in its configuration directory:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
(Likely path, verify if needed)~/.config/Claude/claude_desktop_config.json
(Likely path, verify if needed)mcp.json
in its configuration directory:
~/.cursor/mcp.json
Restart Claude Desktop / Cursor: Close and reopen your AI client. It should now detect the "whatsapp" MCP server and allow you to use its tools.
Once the server is running (either manually via node src/main.ts
or started by the AI client via the config file) and connected to your AI client, you can interact with your WhatsApp data through the agent's chat interface. Ask it to search contacts, list recent chats, read messages, or send messages.
This application is a single Node.js process that:
@whiskeysockets/baileys
to connect to the WhatsApp Web API, handling authentication and real-time events../data/whatsapp.db
) using node:sqlite
.@modelcontextprotocol/sdk
that listens for requests from an AI client over standard input/output (stdio).pino
for logging activity (wa-logs.txt
for WhatsApp events, mcp-logs.txt
for MCP server activity)../auth_info/
directory../data/whatsapp.db
SQLite file.auth_info/
and data/
are included in .gitignore
to prevent accidental commits. Treat these directories as sensitive.list_messages
, send_message
). The server itself does not proactively send your data anywhere else.@whiskeysockets/baileys
@modelcontextprotocol/sdk
node:sqlite
(Bundled SQLite)pino
zod
(for MCP tool inputs)quickchart.io
URL and open it manually.DisconnectReason.loggedOut
error, you need to re-authenticate. Stop the server, delete the ./auth_info/
directory, and restart the server (node src/main.ts
) to get a new QR code.wa-logs.txt
for activity../auth_info/
and ./data/
directories, then restart the server to re-authenticate and resync history.command
and args
(especially the {{PATH_TO_REPO}}
) in your claude_desktop_config.json
or mcp.json
. Ensure the path is absolute and correct.mcp-logs.txt
) for MCP-related errors.number@s.whatsapp.net
for users, groupid@g.us
for groups).wa-logs.txt
for specific errors from Baileys.wa-logs.txt
and mcp-logs.txt
for detailed error messages.For further MCP integration issues, refer to the official MCP documentation.
This project is licensed under the ISC License (see package.json
).
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!