WhatsApp Claude MCP
WhatsApp Claude MCP
Model Context Protocol(MCP)を利用してClaude AIと統合した、高性能なWhatsAppボットです。WhatsAppボットにメッセージを送ると、外部APIやツールにアクセスできるClaudeによるインテリジェントな応答が返ってきます。
🌟 機能
Claude AI連携: インテリジェントな会話にClaude 3.5 Sonnetを使用
MCPツール: Claudeが外部APIと連携するための拡張可能なツールシステム
ジョーク生成: 外部APIからランダムなジョークを取得する組み込みツール
会話メモリ: ユーザーごとに複数のメッセージにわたるコンテキストを保持します
WhatsApp Webhook: WhatsAppサービスと連携するためのシンプルなREST API
簡単なデプロイ: expressサーバーで動作し、クラウドデプロイの準備ができています
Related MCP server: WAHA WhatsApp MCP Server
📋 前提条件
Node.js 18以上
npm または yarn
Anthropic APIキー(console.anthropic.com から取得)
WhatsApp Cloud API アクセス(本番連携用)
🚀 クイックスタート
1. クローンとインストール
git clone https://github.com/yulianheroes-lgtm/whatsapp-claude-mcp.git
cd whatsapp-claude-mcp
npm install2. 環境変数の設定
cp .env.example .env.env を編集して、Anthropic APIキーを追加します:
ANTHROPIC_API_KEY=your_anthropic_api_key_here
PORT=30003. サーバーの起動
npm start次のように表示されるはずです:
✅ WhatsApp Claude MCP Server running on http://localhost:3000
🤖 Ready to process WhatsApp messages!📡 APIの使用方法
ヘルスチェック
curl http://localhost:3000/healthClaudeにメッセージを送信
curl -X POST http://localhost:3000/webhook/whatsapp \
-H "Content-Type: application/json" \
-d '{
"userId": "1234567890",
"message": "Tell me a joke"
}'レスポンス:
{
"success": true,
"userId": "1234567890",
"message": "😂 Here's a programming joke for you!\n\nWhy do programmers prefer dark mode?\n\nBecause light attracts bugs! 🐛"
}会話履歴のクリア
curl -X POST http://localhost:3000/webhook/clear-history \
-H "Content-Type: application/json" \
-d '{
"userId": "1234567890"
}'🛠️ 利用可能なツール
Joke Generator
Claudeは必要に応じてこのツールを自動的に使用できます:
トリガー: ユーザーがジョークを要求したとき
タイプ: random、programming、general
API: Official Joke API
対話例:
User: Tell me a funny programming joke
Bot: [Uses joke_generator tool] 😂 Here's a programming joke...📁 プロジェクト構成
whatsapp-claude-mcp/
├── src/
│ ├── index.js # Main Express server
│ ├── whatsapp-handler.js # Message handling & Claude integration
│ ├── mcp-server.js # MCP tool definitions & execution
│ └── tools/
│ └── joke-generator.js # Joke generator tool implementation
├── .env.example # Environment variables template
├── .gitignore # Git ignore rules
├── package.json # Dependencies
└── README.md # This file🔌 WhatsAppとの連携
オプション1: WhatsApp Cloud API
本番環境では、WhatsApp Cloud API と連携します:
Meta Business Platformでウェブフックを設定します
ウェブフックURLを
https://your-domain.com/webhook/whatsappに指定しますWhatsAppがメッセージを受信したら、このエンドポイントにメッセージを転送します
オプション2: ローカルでのテスト
curl、Postman、テストスクリプトなどのツールを使ってメッセージを送信します:
// test.js
const userId = '1234567890';
const message = 'Tell me a joke';
const response = await fetch('http://localhost:3000/webhook/whatsapp', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ userId, message })
});
const result = await response.json();
console.log(result.message);🧠 動作の仕組み
メッセージ受信 → WhatsAppのウェブフックがメッセージを受信します
Claude処理 → 利用可能なツールとともにメッセージがClaudeに送信されます
ツール選択 → Claudeがツールが必要かどうかを判断します
ツール実行 → MCPサーバーがツールを実行します(例: ジョークの取得)
応答生成 → Claudeがツールの結果を使って応答を生成します
メッセージ送信 → WhatsApp経由で応答が送信されます
🚀 さらにツールを追加する
新しいツール(例: 天気予報、翻訳)を追加するには:
1. ツールファイルの作成
// src/tools/weather.js
export const weatherTool = {
name: 'get_weather',
description: 'Get current weather for a location',
inputSchema: {
type: 'object',
properties: {
location: { type: 'string', description: 'City name' }
}
}
};
export async function executeWeather(location) {
// Fetch weather data
return { /* weather data */ };
}2. MCPサーバーへの登録
// src/mcp-server.js
import { weatherTool, executeWeather } from './tools/weather.js';
export class MCPServer {
constructor() {
this.tools = [
jokeGeneratorTool,
weatherTool // Add here
];
}
async processTool(toolName, toolInput) {
switch (toolName) {
case 'get_weather':
return await executeWeather(toolInput.location);
// ...
}
}
}📚 APIリファレンス
POST /webhook/whatsapp
リクエストボディ:
{
"userId": "string (required)",
"message": "string (required)"
}レスポンス:
{
"success": boolean,
"userId": "string",
"message": "string"
}POST /webhook/clear-history
リクエストボディ:
{
"userId": "string (required)"
}レスポンス:
{
"success": boolean,
"message": "string"
}🔐 セキュリティに関する注意事項
APIキー:
.envファイルをバージョン管理にコミットしないでくださいレート制限: 本番環境ではレート制限の導入を検討してください
入力検証: ウェブフックのポッドを常に検証してください
HTTPS: 本番環境ではHTTPSを使用してください
認証: サイン検証を追加して、WhatsApp連携の安全性を高めてください
📝 環境変数
変数 | 説明 | 設定例 |
| Claude APIキー |
|
| サーバーポート |
|
| 環境 |
|
| ジョークAPIエンドポイント |
|
コントリビューション
自由にフォークして、修正し、コントリビュートしてください!
📄 ライセンス
MIT License – 詳細はLICENSEファイルを参照してください
🛠️ トラブルシューティング
「APIキーが見つかりません」
.envファイルが存在し、ANTHROPIC_API_KEYが設定されていることを確認してくださいconsole.anthropic.com でキーが有効かどうか確認してください
「ツールの実行に失敗しました」
外部APIにアクセスできるか確認してください
ネットワーク接続を確認してください
コンソール出力のエラーログを確認してください
「Claudeから応答がありません」
ANTHROPIC_API_KEYが正しいことを確認してくださいClaudeモデルが利用可能か確認してください
APIのレート制限を確認してください
📞 サポート
問題や質問がある場合は:
トラブルシューティングのセクションを確認してください
Claude APIドキュメントを参照してください
GitHubでイシューを開いてください
🎯 今後の拡張予定
WhatsAppメッセージでの画像・メディアサポート
追加ツール(天気、ニュース、翻訳)
永続的な会話履歴を実現するデータベース
レート制限と認証
監視用の管理ダッシュボード
多言語サポート
ユーザーごとのカスタムClaudeシステムプロンプト
yulianheroes-lgtm が❤️を込めて作成
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables sending, reading, and deleting WhatsApp messages through Claude Desktop and other MCP clients with granular per-chat permissions. Built on whatsapp-web.js using a headless browser to automate WhatsApp Web.6MIT
- AlicenseAqualityCmaintenanceEnables Claude to interact with WhatsApp through a unified backend API, providing 20 tools for messaging, media, groups, contacts, and chat management.22107MIT
- AlicenseNot gradedqualityBmaintenanceConnects WhatsApp to Claude Code, enabling message reading, audio transcription, image analysis, and message sending with full codebase context.51MIT
- AlicenseNot gradedqualityCmaintenanceA local MCP server that connects WhatsApp to Claude via QR code, enabling chat listing, message retrieval, and sending with automatic rate limiting for anti-ban protection.51MIT
Related MCP Connectors
Drive your real WhatsApp inbox from Claude — send, reply, label, assign, and triage via TimelinesAI.
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Security-first WordPress MCP server. 129 tools for Claude, ChatGPT, Gemini. Free on wp.org.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/yulianheroes-lgtm/whatsapp-claude-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server