mcp-baileys
Provides tools for interacting with WhatsApp across multiple linked accounts, including searching and retrieving chat history, sending messages and media, managing groups and presence, scheduling messages, and handling account linking.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-baileys
WhatsApp MCP server built on Baileys, with an AI bridge daemon and an optional shared MCP hub.
mcp-baileys lets AI agents (Claude, Gemini / Antigravity, or any Model Context Protocol client) read, search and send WhatsApp messages across multiple linked accounts, with local SQLite persistence and a small web dashboard.
Spanish quick start: see GUIA_RAPIDA.md.
Features
Multi-account WhatsApp via Baileys (WhatsApp Web multi-device protocol). Link accounts with a QR code or an 8-digit pairing code.
MCP server over stdio and SSE exposing ~60
whatsapp_*tools (search, history, media, groups, sending, presence, scheduling, live progress cards, account management).SQLite persistence (
better-sqlite3, WAL mode) with FTS5 full-text search over the stored history. Optional mirroring to MongoDB / PostgreSQL.Voice notes: audio transcription (Gemini) and text-to-speech replies as PTT voice notes (Edge TTS / Gemini / ElevenLabs).
Web UI at
/— account management, QR / pairing, chat history search, test sends, chat import, linked-group configuration.Live voice UI at
/live— hands-free PWA voice client talking to the assistant in real time.AI bridge daemon (
bridge/) — HTTP daemon (default port4040) that forwards WhatsApp conversations to an AI agent session (Antigravity / Gemini CLI) and streams answers back.Shared MCP hub (
mcp-hub/, optional) — one process per machine exposing MCP servers over Streamable HTTP, with on-demand stdio backends, tool caching and an optional mesh of peer hubs for failover.Anti-ban safety rails: per-recipient rate limiting, natural typing presence before sending, no automatic cold 1:1 outreach.
Related MCP server: wa-bridge
Architecture
WhatsApp (linked devices)
│ messages / audio / commands
▼
┌──────────────────────────────────────────┐
│ mcp-baileys server (port 3333) │
│ • Baileys multi-account sockets │
│ • SQLite (FTS5) history + media store │
│ • Transcription / TTS │
│ • MCP stdio + SSE, REST API, Web UI │
└───────────────────┬──────────────────────┘
│ POST /v1/chat (streaming)
▼
┌──────────────────────────────────────────┐
│ AI bridge (bridge/, port 4040) │
│ • Session detection / agent CLI shim │
│ • Prompt injection + response streaming │
└───────────────────┬──────────────────────┘
▼
Antigravity / Gemini CLI agentRequirements
Node.js 22+
pnpm (recommended,
corepack enable) or npmBuild toolchain for native modules if no prebuilt binary is available (
python3,make,g++)Optional: a Gemini API key (transcription / TTS), an ElevenLabs API key (TTS)
Install
git clone <your-fork-url> mcp-baileys
cd mcp-baileys
pnpm install # or: npm install
cp .env.example .envThe postinstall hook runs scripts/patch-baileys.js, which applies a few robustness patches to the installed Baileys package (decryption fallbacks, LID group addressing). Make sure install scripts are not disabled.
Build & run
npm run build # compile TypeScript to dist/
npm start # run the compiled server (dist/index.js)
npm run dev # watch mode with tsx
npm test # node:test suiteOpen http://localhost:3333, then scan the QR code from WhatsApp → Linked devices (or request a pairing code from the UI).
The AI bridge runs as a separate process:
npm run bridge:start # TypeScript bridge (bridge/src)
node bridge/headless-bridge.mjs # headless bridge daemonPM2
npm run build
pm2 start ecosystem.config.cjs # starts "mcp-baileys" and "ai-bridge"macOS LaunchAgent
npm run service:install # installs com.mcp.baileys, logs in ~/Library/Logs/mcp-baileys
npm run service:uninstallMCP client configuration
stdio (from source):
{
"mcpServers": {
"whatsapp": {
"command": "node",
"args": ["--import", "tsx", "src/mcp/stdio.ts"],
"cwd": "/path/to/mcp-baileys"
}
}
}stdio (compiled): use "args": ["/path/to/mcp-baileys/dist/mcp/stdio.js"] after npm run build.
SSE: point SSE-capable clients at http://localhost:3333/sse while the server is running.
Docker
docker compose up -d --build
docker compose logs -fSessions are stored in the ./auth_info volume and the database / media in ./data. Values from .env are loaded when present. Expose port 3333 only on trusted networks.
Configuration
All configuration is done through environment variables (see .env.example).
Core
Variable | Default | Description |
|
| HTTP port (Web UI, REST, SSE). |
|
| Bind address. Use |
|
| Pino log level. |
|
| Reconnect sockets automatically. |
|
| Baileys credentials (one subfolder per extra account). |
|
| SQLite database and runtime data. |
|
| Downloaded media. |
|
| Link with a pairing code instead of QR. |
| — | Number used for pairing (international format, digits only, e.g. |
| — | Display name of the default account. |
| — | Comma list of account ids whose incoming messages are marked as read. |
AI / assistant
Variable | Default | Description |
| — | Gemini key for transcription / TTS / live voice. |
| — | Optional ElevenLabs TTS. |
|
| TTS engine. |
| — | Voice id for the selected provider. |
|
| Name the assistant answers to in groups. |
| — | Comma list of extra mention words that also trigger the assistant. |
|
| AI bridge base URL. |
| — | Default group linked to the agent (e.g. |
| — | Group where transcriptions are posted. |
| — | Default agent conversation id. |
|
| Start the bridge integration on boot. |
|
| Automatic acknowledgement reactions on incoming messages. |
Access control & security
Variable | Default | Description |
| — | Comma list of admin phone numbers allowed to run privileged commands. |
| — | Comma list of phone numbers allowed to talk to the assistant. |
| — | Token required for any non-loopback request (sent in the |
| — | Sessions whose outbound messages go through the outbound guard. |
| — | Group for internal alerts (held groups, unanswered acks). |
| — | Optional fixed |
| — | Shared secret between the server and the AI bridge. |
|
| Per-recipient outbound rate limiting. |
|
| Max messages per recipient per window. |
|
| Rate limit window. |
Shared MCP hub (mcp-hub/)
Variable | Description |
| Role / name of this node in the mesh. |
| JSON array describing peer hubs (name, URL) for failover. |
| Public base URL of the optional video GPU node. |
| Name of the peer that hosts GPU-only MCP servers. |
Generate tokens with openssl rand -hex 32. Never commit .env, auth_info*/ or data/.
Responsible use
This project uses the unofficial WhatsApp Web protocol. Automated use can violate the WhatsApp Terms of Service and lead to account restrictions. Use it for your own accounts and conversations where participants expect it:
Do not start unsolicited 1:1 conversations with numbers that have no prior history (no cold outreach, no bulk messaging).
Keep the built-in rate limits enabled and let the server send natural typing presence before messages.
Avoid automatic reactions or replies to every incoming message, and guard against bot-to-bot loops.
Use dedicated, consented numbers for automation; keep credentials and session folders private.
This project is not affiliated with or endorsed by WhatsApp or Meta.
Contributing
See CONTRIBUTING.md.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
WhatsApp for Claude, ChatGPT or any AI agent: search, reply and send. Personal or Business API.
WhatsApp for your AI agent, sent from your own number. Source-available (Elastic License 2.0).
Read-only WhatsApp MCP for your AI agent: it reads the chats you choose. Try the public demo.
WhatsApp CRM for AI agents: search contacts, read chats, manage the sales pipeline, send messages.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with your personal WhatsApp account to search messages, list chats, and send messages. It stores all authentication and message data locally using SQLite for privacy and direct multi-device API connection.1ISC
- AlicenseNot gradedqualityCmaintenanceA self-hosted WhatsApp bridge that exposes a stdio MCP server with ~20 tools for reading conversations, sending messages, managing groups, contacts, and aliases, enabling AI agents to operate WhatsApp directly.4MIT
- AlicenseBqualityDmaintenanceEnables AI agents to control WhatsApp, including sending messages and media, reading chats, managing groups and communities, with QR/pairing auth and session persistence.1415 npm2MIT
- FlicenseNot gradedqualityDmaintenanceOpenWA MCP server that bridges AI agents to the OpenWA WhatsApp API, exposing 40 tools for sessions, messages, contacts, groups, and webhooks so agents can read and send WhatsApp messages through a self-hosted OpenWA gateway.-