MW

msaelices/whatsapp-mcp-server

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

27 stars 9 forks 品質 67 トレンド 11MIT

Whatsapp MCP Server implemented in Python

概要

A server that provides a Model Context Protocol (MCP) interface to interact with WhatsApp Business API using FastMCP. WhatsApp MCP Server is a Python implementation that enables language models like Claude to interact with WhatsApp functionality through GreenAPI. It leverages FastMCP for improved performance, better developer experience, and a cleaner implementation. - : Send text messages to WhatsApp contacts - : Create groups, list members, add/remove participants - : Manage WhatsApp API sessions - : Retrieve chat lists and message history This project uses the whatsapp-api-client-python library to interact with WhatsApp. The client provides access to the WhatsApp Cloud API, which requires a GreenAPI account to use. This project uses environment variables for configuration: - GREENAPI_ID_INSTANCE: Your GreenAPI ID instance - GREENAPI_API_TOKEN: Your GreenAPI API token You can either set these in your environment or use the provided .env file (see Installation instructions).

README

以下は原文 README の抜粋です。原文を見る。

WhatsApp MCP Server

A server that provides a Model Context Protocol (MCP) interface to interact with WhatsApp Business API using FastMCP.

Introduction

WhatsApp MCP Server is a Python implementation that enables language models like Claude to interact with WhatsApp functionality through GreenAPI. It leverages FastMCP for improved performance, better developer experience, and a cleaner implementation.

Features

  • Messaging: Send text messages to WhatsApp contacts
  • Group Management: Create groups, list members, add/remove participants
  • Session Handling: Manage WhatsApp API sessions
  • Chat History: Retrieve chat lists and message history

WhatsApp API Client

This project uses the whatsapp-api-client-python library to interact with WhatsApp. The client provides access to the WhatsApp Cloud API, which requires a GreenAPI account to use.

Environment Variables

This project uses environment variables for configuration:

  • GREENAPI_ID_INSTANCE: Your GreenAPI ID instance
  • GREENAPI_API_TOKEN: Your GreenAPI API token

You can either set these in your environment or use the provided .env file (see Installation instructions).

Installation

# 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

Usage

Run the MCP server:

# 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

For debugging:

whatsapp-mcp --debug

The server communicates using the Model Context Protocol (MCP) and can be accessed via HTTP or WebSockets when running with FastMCP.

Available Tools

  • open_session: Open a new WhatsApp session
  • send_message: Send a message to a chat
  • get_chats: Get a list of chats
  • create_group: Create a new WhatsApp group
  • get_group_participants: Get the participants of a group

FastMCP API Reference

The WhatsApp MCP Server uses FastMCP to provide both WebSocket and HTTP endpoints:

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

You can test the API directly using tools like 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": {}}'

How to add it to Claude Code

To add a WhatsApp server to Claude, use the claude mcp add command:

# 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

Using with Claude

GitHub で README 全文を見る

インストール

docker run --rm -i -e GREENAPI_ID_INSTANCE=your_instance_id -e GREENAPI_API_TOKEN=your_api_token whatsapp-mcp-server
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

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