WhatsApp MCP Server
WhatsApp MCP サーバー
FastMCP を使用して WhatsApp Business API と対話するためのモデル コンテキスト プロトコル (MCP) インターフェイスを提供するサーバー。
導入
WhatsApp MCPサーバーは、Claudeなどの言語モデルがGreenAPIを介してWhatsApp機能と連携できるようにするPython実装です。FastMCPを活用することで、パフォーマンスの向上、開発者エクスペリエンスの向上、そしてよりクリーンな実装を実現します。
Related MCP server: YCloud WhatsApp API MCP Server
特徴
メッセージング: WhatsAppの連絡先にテキストメッセージを送信する
グループ管理: グループの作成、メンバーの一覧表示、参加者の追加/削除
セッション処理: WhatsApp APIセッションを管理する
チャット履歴: チャットリストとメッセージ履歴を取得します
WhatsApp APIクライアント
このプロジェクトではwhatsapp-api-client-pythonライブラリを使用してWhatsAppとやり取りします。クライアントはWhatsApp Cloud APIへのアクセスを提供しますが、使用するにはGreenAPIアカウントが必要です。
環境変数
このプロジェクトでは、構成に環境変数を使用します。
GREENAPI_ID_INSTANCE: GreenAPI IDインスタンスGREENAPI_API_TOKEN: GreenAPI APIトークン
これらを環境で設定するか、提供されている.envファイルを使用することもできます (インストール手順を参照)。
インストール
# 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使用法
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デバッグの場合:
whatsapp-mcp --debugサーバーはモデルコンテキストプロトコル (MCP) を使用して通信し、FastMCP で実行している場合は HTTP または WebSocket 経由でアクセスできます。
利用可能なツール
open_session: 新しいWhatsAppセッションを開くsend_message: チャットにメッセージを送信するget_chats: チャットのリストを取得するcreate_group: 新しいWhatsAppグループを作成するget_group_participants: グループの参加者を取得する
FastMCP API リファレンス
WhatsApp MCP サーバーは FastMCP を使用して、WebSocket と HTTP エンドポイントの両方を提供します。
WebSocket:
ws://localhost:8000/mcpHTTP:
http://localhost:8000/mcp
curl などのツールを使用して API を直接テストできます。
# 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": {}}'クロードコードに追加する方法
WhatsApp サーバーを Claude に追加するには、 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クロードと一緒に使う
WhatsApp MCP サーバーが実行される場合は、会話の中で Claude を使用してサーバーと対話できます。
WhatsAppで認証する
Login to WhatsAppメッセージを送信する
Send the "Hello" message to John DoeClaude Desktopでの使用
Claude Desktop で WhatsApp MCP サーバーを使用するには、 claude_desktop_config.jsonファイルに追加する必要があります。
pip インストールの使用(推奨)
"mcpServers": {
"whatsapp": {
"command": "python",
"args": ["-m", "whatsapp_mcp"]
}
}実行ファイルの使用
"mcpServers": {
"whatsapp": {
"command": "whatsapp-mcp"
}
}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"]
}
}Claude Desktop を起動する前に、GreenAPI 資格情報を環境変数として、または.envファイルで設定することを忘れないでください。
コマンドラインオプション
WhatsApp MCP サーバーは次のコマンドライン引数を受け入れます。
--debug: デバッグの詳細レベルを上げる--host: サーバーをバインドするホスト (デフォルト: 127.0.0.1)--port: サーバーをバインドするポート (デフォルト: 8000)
デバッグ
MCP サーバーのデバッグの場合:
MCP インスペクターを使用する:
npx @modelcontextprotocol/inspector whatsapp-mcpClaude デスクトップのログディレクトリ(macOS では通常
~/Library/Logs/Claude/)でログを表示します。インタラクティブな API ドキュメントについては、FastMCP Web インターフェース ( http://localhost:8000)にアクセスしてください。
発達
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
flake8 src/
# Run type checking
mypy src/このプロジェクトでは、以下を含む最新のpyproject.toml構成を使用します。
アプリケーションの実行に必要なコア依存関係
開発依存関係は
pip install -e ".[dev]"で利用可能
ライセンス
このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細については LICENSE ファイルを参照してください。
Available Tools
5 toolscreate_groupC
Create a new WhatsApp group.
Parameters:
- group_name: Name of the group to create
- participants: List of participant phone numbers
| Name | Required | Description | Default |
|---|---|---|---|
| group_name | Yes | ||
| participants | Yes |
TDQS
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.
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.
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.
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.
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.
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)
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No |
TDQS
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.
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.
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.
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.
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.
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
| Name | Required | Description | Default |
|---|---|---|---|
| group_id | Yes |
TDQS
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.
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.
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.
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.
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.
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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
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.
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.
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.
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.
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.
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)
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| phone_number | Yes | ||
| reply_to | No |
TDQS
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.
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.
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.
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.
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.
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.
5 tool updates
v1.0.0- First observed
create_group - First observed
get_chats - First observed
get_group_participants - First observed
open_session - First observed
send_message
TDQS
Scored across 5 tools
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.
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.
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.
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
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.
1Your WhatsApp Business inbox in Claude or ChatGPT: who's waiting, follow-ups and replies.
1WhatsApp for AI agents — your own number or the official Cloud API: messages, media, templates.
Related MCP Servers
- AlicenseCqualityFmaintenanceA 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.711 npm74ISC
- FlicenseCqualityFmaintenanceA server that enables AI models like Claude to directly interact with YCloud WhatsApp API through natural language, automatically generating tools from the OpenAPI specification.1911-
- AlicenseNot gradedqualityDmaintenanceA 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 npm3MIT
- AlicenseNot gradedqualityDmaintenanceAn 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 npmMIT