evolution-api-mcp
Version:
MCP Server for Evolution API v2 - Integrate WhatsApp functionality with Claude Desktop and other MCP clients
302 lines (228 loc) ⢠8.56 kB
Markdown
# Evolution API MCP Server
[](https://badge.fury.io/js/evolution-api-mcp)
[](https://opensource.org/licenses/MIT)
MCP (Model Context Protocol) server for Evolution API v2 integration. This server allows you to integrate WhatsApp functionality through the Evolution API directly into Claude Desktop and other MCP-compatible clients.
## š Quick Start
### Installation
The easiest way to use this MCP server is via npx (no installation required):
```bash
npx evolution-api-mcp
```
Or install globally:
```bash
npm install -g evolution-api-mcp
```
### Basic Configuration
Set the required environment variables:
```bash
export EVOLUTION_URL=https://your-evolution-api.com
export EVOLUTION_API_KEY=your-global-api-key
```
Or create a `.env` file:
```env
EVOLUTION_URL=https://your-evolution-api.com
EVOLUTION_API_KEY=your-global-api-key
```
### Claude Desktop Integration
Add to your Claude Desktop MCP configuration (`~/.claude/mcp.json`):
```json
{
"mcpServers": {
"evolution-api": {
"command": "npx",
"args": ["evolution-api-mcp"],
"env": {
"EVOLUTION_URL": "https://your-evolution-api.com",
"EVOLUTION_API_KEY": "your-global-api-key"
}
}
}
}
```
## š Features
### Instance Management
- ā
Create and manage WhatsApp instances
- ā
Connect instances with QR code generation
- ā
Restart and delete instances
- ā
Set presence status (online, offline, typing, etc.)
### Message Operations
- ā
Send text messages
- ā
Send media (images, videos, documents, audio)
- ā
Send stickers and reactions
- ā
Send location and contact information
- ā
Send interactive messages (polls, lists, buttons)
### Chat Management
- ā
Find and search messages
- ā
Manage contacts and chats
- ā
Mark messages as read/unread
- ā
Archive and unarchive chats
- ā
Check if number is on WhatsApp
### Group Operations
- ā
Create and manage groups
- ā
Update group settings (name, description, picture)
- ā
Manage participants (add, remove, promote, demote)
- ā
Generate and manage invite codes
### Profile & Settings
- ā
Update profile information
- ā
Manage privacy settings
- ā
Configure webhooks
- ā
Get API information and status
## š ļø Configuration
### Environment Variables
| Variable | Required | Description | Example |
|----------|----------|-------------|---------|
| `EVOLUTION_URL` | ā
| Evolution API base URL | `https://api.example.com` |
| `EVOLUTION_API_KEY` | ā
| Global API key | `your-api-key-here` |
| `MCP_SERVER_NAME` | ā | Server name for MCP | `evolution-api-mcp` |
| `HTTP_TIMEOUT` | ā | Request timeout in ms | `30000` |
| `RETRY_ATTEMPTS` | ā | Number of retry attempts | `3` |
| `RETRY_DELAY` | ā | Delay between retries in ms | `1000` |
### Configuration File
You can also use a configuration file (`evolution-config.json`):
```json
{
"evolutionUrl": "https://your-evolution-api.com",
"evolutionApiKey": "your-global-api-key",
"server": {
"name": "evolution-api-mcp",
"version": "1.0.0"
},
"http": {
"timeout": 30000,
"retryAttempts": 3,
"retryDelay": 1000
}
}
```
Then run with:
```bash
npx evolution-api-mcp --config evolution-config.json
```
## š Usage Examples
### Basic Instance Management
```bash
# In Claude Desktop, you can ask:
"Create a new WhatsApp instance called 'my-bot'"
"Connect the instance 'my-bot' and show me the QR code"
"List all my WhatsApp instances"
```
### Sending Messages
```bash
# In Claude Desktop:
"Send a text message 'Hello World!' to +5511999999999 using instance 'my-bot'"
"Send an image from https://example.com/image.jpg to +5511999999999"
"Send a location (latitude: -23.5505, longitude: -46.6333) to +5511999999999"
```
### Group Management
```bash
# In Claude Desktop:
"Create a group called 'My Group' with participants +5511999999999 and +5511888888888"
"Add +5511777777777 to the group 'My Group'"
"Update the group description to 'Welcome to our group!'"
```
## š§ Development
### Prerequisites
- Node.js 18+
- npm or yarn
- Evolution API v2 instance
### Setup
```bash
# Clone the repository
git clone https://github.com/your-repo/evolution-api-mcp.git
cd evolution-api-mcp
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env
# Edit .env with your Evolution API credentials
# Build the project
npm run build
# Run in development mode
npm run dev
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
```
### Project Structure
```
evolution-api-mcp/
āāā src/
ā āāā cli/ # CLI interface
ā āāā clients/ # HTTP client for Evolution API
ā āāā config/ # Configuration management
ā āāā registry/ # Endpoint definitions
ā āāā server/ # MCP server implementation
ā āāā utils/ # Utilities and helpers
āāā tests/ # Test files
āāā bin/ # Executable files
āāā docs/ # Documentation
```
### Available Scripts
| Script | Description |
|--------|-------------|
| `npm run build` | Build the project |
| `npm run dev` | Run in development mode |
| `npm test` | Run tests |
| `npm run test:watch` | Run tests in watch mode |
| `npm start` | Start the built server |
## š Documentation
### Quick Start Guides
- [Installation Guide](./docs/INSTALLATION.md) - Detailed installation instructions
- [Claude Desktop Guide](./docs/CLAUDE_DESKTOP_GUIDE.md) - Step-by-step Claude Desktop setup
- [Configuration Guide](./docs/CONFIGURATION.md) - Complete configuration reference
### Reference Documentation
- [API Reference](./docs/API_REFERENCE.md) - Complete tool documentation
- [Examples](./docs/EXAMPLES.md) - Usage scenarios and workflows
- [Troubleshooting](./docs/TROUBLESHOOTING.md) - Common issues and solutions
### Developer Resources
- [Contributing Guide](./CONTRIBUTING.md) - How to contribute to the project
- [Changelog](./CHANGELOG.md) - Version history and changes
## š Troubleshooting
### Common Issues
**Connection Failed**
```
Error: Connection to Evolution API failed
```
- Check if `EVOLUTION_URL` is correct and accessible
- Verify `EVOLUTION_API_KEY` is valid
- Ensure Evolution API is running and healthy
**Instance Not Found**
```
Error: Instance 'my-instance' not found
```
- Check if the instance name is correct
- Verify the instance was created successfully
- List all instances to see available ones
**Authentication Error**
```
Error: Authentication failed
```
- Verify your `EVOLUTION_API_KEY` is correct
- Check if the API key has the necessary permissions
- Ensure the API key hasn't expired
For more troubleshooting information, see [TROUBLESHOOTING.md](./docs/TROUBLESHOOTING.md).
## š¤ Contributing
Contributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
### Development Workflow
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Add tests for your changes
5. Ensure tests pass (`npm test`)
6. Commit your changes (`git commit -m 'Add amazing feature'`)
7. Push to the branch (`git push origin feature/amazing-feature`)
8. Open a Pull Request
## š License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## š Acknowledgments
- [Evolution API](https://github.com/EvolutionAPI/evolution-api) - The WhatsApp API this server integrates with
- [Model Context Protocol](https://github.com/modelcontextprotocol) - The protocol specification
- [Claude Desktop](https://claude.ai/desktop) - Primary client for this MCP server
## š Support
- š§ Email: support@example.com
- š¬ Discord: [Join our server](https://discord.gg/example)
- š Issues: [GitHub Issues](https://github.com/your-repo/evolution-api-mcp/issues)
- š Documentation: [Full Documentation](https://docs.example.com)
---
Made with ā¤ļø for the Evolution API and MCP community