Skip to main content
Glama
msaelices

WhatsApp MCP Server

by msaelices

Servidor MCP de WhatsApp

Un servidor que proporciona una interfaz de Protocolo de contexto de modelo (MCP) para interactuar con la API de WhatsApp Business mediante FastMCP.

Introducción

El servidor MCP de WhatsApp es una implementación de Python que permite que modelos de lenguaje como Claude interactúen con las funciones de WhatsApp a través de GreenAPI . Aprovecha FastMCP para mejorar el rendimiento, la experiencia del desarrollador y una implementación más limpia.

Related MCP server: YCloud WhatsApp API MCP Server

Características

  • Mensajería : Envía mensajes de texto a contactos de WhatsApp

  • Gestión de grupos : crear grupos, enumerar miembros, agregar o eliminar participantes

  • Manejo de sesiones : Administrar sesiones de la API de WhatsApp

  • Historial de chat : recupera listas de chat e historial de mensajes

Cliente API de WhatsApp

Este proyecto utiliza la biblioteca whatsapp-api-client-python para interactuar con WhatsApp. El cliente proporciona acceso a la API de WhatsApp Cloud, que requiere una cuenta GreenAPI para su uso.

Variables de entorno

Este proyecto utiliza variables de entorno para la configuración:

  • GREENAPI_ID_INSTANCE : Su instancia de ID de GreenAPI

  • GREENAPI_API_TOKEN : Su token de API GreenAPI

Puede configurarlos en su entorno o utilizar el archivo .env proporcionado (consulte las instrucciones de instalación).

Instalación

# Clone the repository
git clone https://github.com/yourusername/whatsapp-mcp-server.git
cd whatsapp-mcp-server

# Install dependencies
pip install -e .

# Set up environment variables
cp .env-template .env
# Edit the .env file with your GreenAPI credentials

Uso

Ejecute el servidor MCP:

# Run the MCP server on default host (127.0.0.1) and port (8000)
whatsapp-mcp

# Specify host and port
whatsapp-mcp --host 0.0.0.0 --port 9000

Para depurar:

whatsapp-mcp --debug

El servidor se comunica mediante el Protocolo de contexto de modelo (MCP) y se puede acceder a él mediante HTTP o WebSockets cuando se ejecuta con FastMCP.

Herramientas disponibles

  • open_session : Abrir una nueva sesión de WhatsApp

  • send_message : Envía un mensaje a un chat

  • get_chats : Obtener una lista de chats

  • create_group : Crea un nuevo grupo de WhatsApp

  • get_group_participants : Obtener los participantes de un grupo

Referencia de la API de FastMCP

El servidor MCP de WhatsApp utiliza FastMCP para proporcionar puntos finales WebSocket y HTTP:

  • WebSocket: ws://localhost:8000/mcp

  • HTTP: http://localhost:8000/mcp

Puedes probar la API directamente usando herramientas como curl:

# List available tools
curl -X POST http://localhost:8000/mcp/listTools

# Call a tool
curl -X POST http://localhost:8000/mcp/callTool \
  -H "Content-Type: application/json" \
  -d '{"name": "open_session", "arguments": {}}'

Cómo agregarlo a Claude Code

Para agregar un servidor de WhatsApp a Claude, use el comando claude mcp add :

# Add the WhatsApp MCP server
$ claude mcp add whatsapp -- whatsapp-mcp

# List existing MCP servers - Validate that the server is running
claude mcp list

# Start claude code
claude

Usando con Claude

Una vez que el servidor MCP de WhatsApp esté en funcionamiento, podrás interactuar con él usando Claude en tus conversaciones:

Autenticación con WhatsApp

Login to WhatsApp

Enviando un mensaje

Send the "Hello" message to John Doe

Uso con Claude Desktop

Para utilizar el servidor MCP de WhatsApp con Claude Desktop, debes agregarlo a tu archivo claude_desktop_config.json :

Usando la instalación pip (recomendado)

"mcpServers": {
  "whatsapp": {
    "command": "python",
    "args": ["-m", "whatsapp_mcp"]
  }
}

Usando el ejecutable

"mcpServers": {
  "whatsapp": {
    "command": "whatsapp-mcp"
  }
}

Usando Docker

"mcpServers": {
  "whatsapp": {
    "command": "docker",
    "args": ["run", "--rm", "-i", "-e", "GREENAPI_ID_INSTANCE=your_instance_id", "-e", "GREENAPI_API_TOKEN=your_api_token", "whatsapp-mcp-server"]
  }
}

Recuerde configurar sus credenciales de GreenAPI como variables de entorno o en su archivo .env antes de iniciar Claude Desktop.

Opciones de línea de comandos

El servidor MCP de WhatsApp acepta estos argumentos de línea de comandos:

  • --debug : Aumenta el nivel de verbosidad para la depuración

  • --host : Host al que vincular el servidor (predeterminado: 127.0.0.1)

  • --port : Puerto al que vincular el servidor (predeterminado: 8000)

Depuración

Para depurar el servidor MCP:

  • Utilice el inspector MCP: npx @modelcontextprotocol/inspector whatsapp-mcp

  • Ver registros en el directorio de registros de Claude Desktop (normalmente ~/Library/Logs/Claude/ en macOS)

  • Acceda a la interfaz web de FastMCP en http://localhost:8000 para obtener documentación de API interactiva

Desarrollo

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
flake8 src/

# Run type checking
mypy src/

El proyecto utiliza una configuración moderna pyproject.toml que incluye:

  • Dependencias básicas necesarias para ejecutar la aplicación

  • Dependencias de desarrollo disponibles con pip install -e ".[dev]"

Licencia

Este proyecto está licenciado bajo la licencia MIT: consulte el archivo de LICENCIA para obtener más detalles.

Available Tools

5 tools
create_groupC
Create a new WhatsApp group.

Parameters:
- group_name: Name of the group to create
- participants: List of participant phone numbers
ParametersJSON Schema
NameRequiredDescriptionDefault
group_nameYes
participantsYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action but doesn't cover critical aspects: whether this requires specific permissions, if it's idempotent, what happens on failure, rate limits, or the expected return format. The description is minimal and lacks necessary operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with a clear heading and bullet points for parameters. Every sentence adds value, and it's front-loaded with the core purpose. No redundant information is present, though it could benefit from more structured behavioral details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a creation tool with no annotations and no output schema, the description is incomplete. It lacks information on success/failure responses, error handling, dependencies (e.g., session requirements), and behavioral traits. For a mutation tool, this leaves significant gaps for an AI agent to operate effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It lists both parameters with brief explanations ('Name of the group to create', 'List of participant phone numbers'), adding basic meaning beyond the schema's titles. However, it doesn't specify format constraints (e.g., phone number format, group name length limits), leaving gaps in parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Create' and resource 'new WhatsApp group', making the purpose unambiguous. However, it doesn't explicitly distinguish this from sibling tools like 'get_chats' or 'send_message', though the creation action is inherently different from retrieval/messaging operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an active session via 'open_session'), exclusions, or comparative context with sibling tools like managing existing groups versus creating new ones.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_chatsC
Get a list of chats.

Parameters:
- limit: Maximum number of chats to return (default: 50)
- offset: Offset for pagination (default: 0)
ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
offsetNo

TDQS

C2.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions parameters for pagination but does not describe key traits like whether this is a read-only operation, potential rate limits, authentication needs, or what the output looks like (e.g., format, fields). For a list tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the main purpose followed by parameter details in a clear list format. Every sentence adds value, with no redundant or wasted words. However, the structure could be slightly improved by integrating the purpose and parameters more seamlessly, but it remains efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a list tool with 2 parameters), lack of annotations, and no output schema, the description is incomplete. It covers basic purpose and parameters but misses critical context like output format, error handling, or how it fits with sibling tools. For adequate agent use, it should provide more behavioral and contextual details beyond the minimal information given.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful semantics beyond the input schema, which has 0% description coverage. It explains that 'limit' is the 'Maximum number of chats to return' with a default of 50, and 'offset' is for 'pagination' with a default of 0, clarifying their purposes. Since there are only 2 parameters and the schema lacks descriptions, this compensates well, though it could detail constraints like min/max values.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Get a list of chats,' which clearly indicates the verb ('Get') and resource ('chats'), providing a basic purpose. However, it lacks specificity about what 'chats' entails (e.g., types, scope) and does not differentiate from sibling tools like 'get_group_participants' or 'open_session,' leaving room for ambiguity. This is a minimal viable description but vague in context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention any context, prerequisites, or exclusions, such as how it relates to sibling tools like 'get_group_participants' for participant details or 'open_session' for active chats. Without such information, the agent must infer usage, which reduces effectiveness.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_group_participantsB
Get the participants of a WhatsApp group.

Parameters:
- group_id: The WhatsApp ID of the group
ParametersJSON Schema
NameRequiredDescriptionDefault
group_idYes

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't mention whether this is a read-only operation, requires authentication, has rate limits, or what the return format looks like. For a tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise: one clear purpose statement followed by a parameter explanation. Every sentence earns its place with no wasted words, and the information is front-loaded appropriately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple single-parameter tool with no output schema, the description covers the basic purpose and parameter meaning adequately. However, the lack of behavioral information (especially with no annotations) and usage guidance relative to siblings leaves gaps that could hinder effective tool selection.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description explicitly documents the single parameter 'group_id' and explains it as 'The WhatsApp ID of the group', adding meaningful context beyond the schema's basic type information. With 0% schema description coverage, this fully compensates for the schema's lack of detail.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('participants of a WhatsApp group'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_chats' which might also involve group data, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_chats' or 'create_group'. It doesn't mention prerequisites, context, or exclusions, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

open_sessionB

Open a new WhatsApp session.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Open a new WhatsApp session' implies initialization or connection, it lacks critical details: whether this requires credentials, if it's idempotent, what happens to existing sessions, potential side effects, or error conditions. This leaves significant behavioral gaps for a session management tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose with zero wasted words. It's appropriately sized for a simple tool and front-loaded with the essential information, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of session management (which often involves authentication, state persistence, and error handling), the description is insufficient. With no annotations, no output schema, and minimal behavioral context, it fails to provide complete guidance. The agent would need to guess about return values, success/failure states, and operational constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the absence of inputs. The description appropriately doesn't discuss parameters, maintaining focus on the tool's purpose without redundancy. A baseline of 4 is appropriate for zero-parameter tools when the schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Open') and target resource ('a new WhatsApp session'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from its siblings like 'create_group' or 'send_message', which would require explicit differentiation for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_chats' or 'send_message'. There's no mention of prerequisites (e.g., authentication status), timing considerations, or explicit exclusions, leaving the agent with minimal contextual direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

send_messageC
Send a message to a chat.

Parameters:
- phone_number: The phone number of the recipient
- content: The content of the message to send
- reply_to: ID of the message to reply to (optional)
ParametersJSON Schema
NameRequiredDescriptionDefault
contentYes
phone_numberYes
reply_toNo

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Send a message' implies a write/mutation operation, the description doesn't address critical behavioral aspects like required permissions, rate limits, whether messages are encrypted, delivery confirmation, or what happens on failure. This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by a bulleted parameter list. Every sentence serves a purpose, though the parameter explanations could be slightly more detailed given the lack of schema descriptions. The formatting is clean and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 3-parameter mutation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (success/failure indicators, message ID, etc.), doesn't address error conditions, and provides minimal behavioral context. The parameter explanations help but don't compensate for the overall contextual gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description explicitly lists all three parameters with brief explanations, adding meaningful context beyond the schema's 0% description coverage. It clarifies that 'reply_to' is optional and identifies what each parameter represents. However, it doesn't provide format details (e.g., phone number format, content length limits) or deeper semantic constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Send a message') and the target resource ('to a chat'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from potential sibling tools like 'create_group' or 'open_session', which might also involve messaging functionality in some contexts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'create_group' for group messaging or 'get_chats' for retrieving messages. There's no mention of prerequisites, appropriate contexts, or exclusions for this messaging operation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv1.0.0
    • First observedcreate_group
    • First observedget_chats
    • First observedget_group_participants
    • First observedopen_session
    • First observedsend_message

TDQS

B3.2/5.0

Scored across 5 tools

Disambiguation4/5

Most tools have distinct purposes: creating groups, listing chats, getting group participants, opening sessions, and sending messages. However, 'get_chats' could potentially overlap with group-related functionality since groups are a type of chat, but the descriptions clarify their focus areas.

Naming Consistency4/5

The naming follows a consistent verb_noun pattern (e.g., create_group, get_chats, send_message) with clear, descriptive names. The only minor deviation is 'open_session', which uses a verb_adjective_noun structure but remains readable and fits the pattern conceptually.

Tool Count4/5

With 5 tools, the count is reasonable for a WhatsApp server, covering core operations like messaging, group management, and session handling. It might benefit from additional tools for actions like deleting messages or managing contacts, but it's well-scoped for basic functionality.

Completeness3/5

The toolset covers key areas such as sending messages, creating groups, and retrieving chats/participants, but has notable gaps. For example, there are no tools for updating or deleting groups, managing contacts, or handling message reactions, which could limit agent workflows in a messaging domain.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

  • WhatsMCP connects Claude and other MCP-compatible AI agents directly to WhatsApp. Send and receive text, images, documents, and voice notes; manage groups (create, add/remove members, promote admins); look up contacts and profiles; follow channels; and read call and message history — all through a standard MCP interface. For voice use cases, WhatsMCP offers SIP-based calling plans (inbound-only, or full inbound/outbound) so AI voice agents can answer and place WhatsApp calls, plus low-latency WebSocket integrations with voice agent providers like ElevenLabs. Multiple WhatsApp accounts can be paired and managed per workspace, with webhook support for real-time inbound message delivery to your own infrastructure.

  • Your own WhatsApp in Claude and ChatGPT: read chats, draft replies, send messages you approve.

    1
  • Your WhatsApp Business inbox in Claude or ChatGPT: who's waiting, follow-ups and replies.

    1
  • WhatsApp for AI agents — your own number or the official Cloud API: messages, media, templates.

Related MCP Servers

  • A
    license
    C
    quality
    F
    maintenance
    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.
    7
    11 npm
    74
    ISC
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables interaction with WhatsApp through local stdio or remote HTTP/SSE connections. It allows users to send messages, manage groups, and access chat history using natural language.
    23 npm
    3
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that connects Claude and other LLM clients to WhatsApp via the Baileys library. Enables sending and receiving messages, listing chats, downloading media, and more.
    19 npm
    MIT