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 웹훅: 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. Clone 및 설치
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 사용법
Health Check
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"
}'🛠️ 사용 가능한 도구
농담 생성기
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 key not found"
.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 deployed
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.
Let Claude or ChatGPT search, read and send your WhatsApp messages over MCP. OAuth sign-in.
Ask questions across your WhatsApp inbox from Claude, ChatGPT, Cursor or any MCP client.
Your own WhatsApp in Claude and ChatGPT: read chats, draft replies, send messages you approve.
1
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
- AlicenseAqualityDmaintenanceEnables Claude to interact with WhatsApp through a unified backend API, providing 20 tools for messaging, media, groups, contacts, and chat management.2240 npmMIT
- AlicenseNot gradedqualityDmaintenanceConnects WhatsApp to Claude Code, enabling message reading, audio transcription, image analysis, and message sending with full codebase context.36 npmMIT
- 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.36 npmMIT