> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kaanha.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Server

> Use Kaanha AI as an MCP tool server with Claude Desktop or any MCP-compatible AI assistant

# MCP Server

Kaanha AI includes a built-in MCP (Model Context Protocol) server, enabling AI assistants like Claude to interact with your WhatsApp CRM directly. Send messages, search contacts, check analytics, and manage broadcasts — all through natural language.

## Transports

| Transport | File                 | Best for                                 |
| --------- | -------------------- | ---------------------------------------- |
| **stdio** | `src/mcp/server.mjs` | Claude Desktop, Claude Code              |
| **SSE**   | `/api/mcp/sse`       | Network MCP clients, custom integrations |

## Quick Start (Claude Desktop)

### 1. Install and authorize

```bash theme={null}
npm install -g @kaanha-ai/mcp
kaanha-ai auth login
```

This opens Kaanha AI in your browser. Sign in as the workspace Owner, approve CLI access, then return to your terminal.

### 2. Register the server

```bash theme={null}
claude mcp add kaanha -- npx @kaanha-ai/mcp serve
```

### 3. Verify connection

In Claude Desktop:

> "List my recent WhatsApp conversations"

## Available Tools (21 total)

### Contacts

| Tool             | Description                               |
| ---------------- | ----------------------------------------- |
| `list_contacts`  | List contacts with optional search/filter |
| `get_contact`    | Get contact details by phone or ID        |
| `create_contact` | Create a new contact                      |
| `update_contact` | Update contact name, tags, attributes     |

### Conversations & Messages

| Tool                 | Description                            |
| -------------------- | -------------------------------------- |
| `list_conversations` | List conversations with status filter  |
| `get_conversation`   | Get conversation with recent messages  |
| `send_message`       | Send a WhatsApp text message           |
| `send_template`      | Send an approved template message      |
| `list_messages`      | Get message history for a conversation |

### Templates & Broadcasts

| Tool                  | Description                          |
| --------------------- | ------------------------------------ |
| `list_templates`      | List approved WhatsApp templates     |
| `create_broadcast`    | Create and send a broadcast campaign |
| `get_broadcast_stats` | Get delivery stats for a broadcast   |

### AI Agents

| Tool                  | Description                            |
| --------------------- | -------------------------------------- |
| `list_ai_agents`      | List configured AI agents              |
| `test_ai_agent`       | Test an agent with a sample message    |
| `get_agent_analytics` | Get conversation and performance stats |

### Analytics

| Tool                    | Description                            |
| ----------------------- | -------------------------------------- |
| `get_analytics_summary` | Messages sent/received, delivery rates |
| `get_usage_summary`     | Plan usage vs limits                   |

### Quick Replies & Payments

| Tool                  | Description                         |
| --------------------- | ----------------------------------- |
| `list_quick_replies`  | List saved quick reply snippets     |
| `create_payment_link` | Create a payment link for a contact |
| `list_payment_links`  | List payment links with status      |

### Authentication

| Tool              | Description                               |
| ----------------- | ----------------------------------------- |
| `get_auth_status` | Check connection type and WhatsApp status |

## Authentication

The customer-facing flow is browser authorization through `kaanha-ai auth login`. The CLI stores a revocable workspace credential locally at `~/.kaanha/config.json`; customers do not paste API keys during onboarding.

CLI authorization requires an Owner account on a Starter plan or above.

## SSE Transport (Network Clients)

For non-Claude clients:

```
GET https://app.kaanha.ai/api/mcp/sse
Authorization: Bearer wsk_your_api_key
```

Compatible with older MCP clients that still require SSE. Prefer `@kaanha-ai/mcp` for Claude Desktop, Claude Code, and Codex.

## Rate Limits

MCP tool calls are subject to the same rate limits as the REST API (120 requests/minute). Analytics and list tools are cached for 60 seconds.
