WhatsApp MCP server

Connects AI to WhatsApp accounts using TypeScript and Baileys, enabling message history retrieval, contact search, and secure communication through local SQLite storage and QR code authentication.
Back to servers
Setup instructions
Provider
jlucaso
Release date
Apr 01, 2025
Language
TypeScript
Stats
29 stars

This WhatsApp MCP server allows you to connect your personal WhatsApp account to AI agents like Anthropic Claude, enabling them to search messages, find contacts, list chats, retrieve message history, and send messages. It uses TypeScript and the Baileys library to interface with WhatsApp Web's multi-device API, keeping your data stored locally.

Installation Options

Quick Install via Smithery

The fastest way to install for Claude Desktop:

npx -y @smithery/cli install @jlucaso1/whatsapp-mcp-ts --client claude

Manual Installation

Prerequisites

  • Node.js: Version 23.10.0 or higher (with built-in TypeScript and SQLite support)
  • npm (or yarn/pnpm): For package management
  • AI Client: Anthropic Claude Desktop, Cursor, or another MCP-compatible client

Setup Steps

  1. Clone the repository:

    git clone <repository-url> whatsapp-mcp-ts
    cd whatsapp-mcp-ts
    
  2. Install dependencies:

    npm install
    
  3. Start the server for first-time setup:

    node src/main.ts
    

During first-time setup:

  • A QR code link will open in your browser
  • Scan this QR code with your WhatsApp mobile app (Settings > Linked Devices > Link a Device)
  • Authentication credentials will be saved in auth_info/ directory
  • Messages will sync to a local SQLite database (./data/whatsapp.db)

Configuring Your AI Client

Create Configuration File

Create a JSON configuration file with the following structure:

{
  "mcpServers": {
    "whatsapp": {
      "command": "node",
      "args": [
        "/absolute/path/to/whatsapp-mcp-ts/src/main.ts"
      ],
      "timeout": 15,
      "disabled": false
    }
  }
}

Replace /absolute/path/to/whatsapp-mcp-ts with the actual absolute path to your installation directory.

Save Configuration For Your Client

  • Claude Desktop:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  • Cursor:

    • ~/.cursor/mcp.json

After saving the configuration, restart your AI client so it can detect the WhatsApp MCP server.

Using WhatsApp with Your AI Assistant

Once connected, you can ask your AI assistant to:

  • Search your WhatsApp contacts
  • List your recent chats
  • Retrieve message history for specific conversations
  • Send messages to individuals or groups

Available MCP Tools

The server exposes these capabilities to the AI:

  • search_contacts: Find contacts by name or phone number
  • list_messages: Get message history for specific chats
  • list_chats: View your recent conversations
  • get_chat: Get detailed information about a specific chat
  • get_message_context: See messages before and after a specific message
  • send_message: Send text messages to contacts or groups

Troubleshooting

Authentication Issues

  • QR Code Problems: If the QR code doesn't open automatically, check the console for the URL and open it manually
  • Re-authentication Needed: If logged out, delete the ./auth_info/ directory and restart the server

Message Syncing Issues

  • Initial sync may take time depending on your message history
  • For sync problems, delete both ./auth_info/ and ./data/ directories then restart

Connection Problems

  • Verify the path in your configuration file is correct and absolute
  • Ensure Node.js is properly installed and in your system PATH
  • Check logs in wa-logs.txt and mcp-logs.txt for detailed error messages

Message Sending Errors

Data Storage and Privacy

All your WhatsApp data stays on your device:

  • Authentication credentials stored in ./auth_info/
  • Messages and chats saved in ./data/whatsapp.db (SQLite database)
  • Data is only sent to the AI when it explicitly uses a tool at your request

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "whatsapp" '{"command":"node","args":["{{PATH_TO_REPO}}/src/main.ts"],"timeout":15,"disabled":false}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "whatsapp": {
            "command": "node",
            "args": [
                "{{PATH_TO_REPO}}/src/main.ts"
            ],
            "timeout": 15,
            "disabled": false
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "whatsapp": {
            "command": "node",
            "args": [
                "{{PATH_TO_REPO}}/src/main.ts"
            ],
            "timeout": 15,
            "disabled": false
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later