# CloseBot MCP Server

Full-featured MCP server for the [CloseBot](https://closebot.com) AI chatbot platform. Manage bots, leads, sources, analytics, knowledge base, and more — all from Claude Desktop or any MCP client.

## Features

- **119 tools** across 14 lazy-loaded modules
- **6 rich UI tool apps** with HTML dashboards
- **8 tool groups**: Bot Management, Source Management, Lead Management, Analytics & Metrics, Bot Testing, Library & Knowledge Base, Agency & Billing, Configuration
- **6 visual apps**: Bot Dashboard, Analytics Dashboard, Test Console, Lead Manager, Library Manager, Leaderboard
- Full TypeScript with types generated from CloseBot's OpenAPI spec
- Lazy-loaded modules for minimal context usage

## Setup

### 1. Install dependencies

```bash
npm install
```

### 2. Build

```bash
npm run build
```

### 3. Set your API key

Get your API key from CloseBot's dashboard (Settings → API Keys).

```bash
export CLOSEBOT_API_KEY=your_api_key_here
```

### 4. Add to Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "closebot": {
      "command": "node",
      "args": ["/path/to/closebot-mcp/dist/index.js"],
      "env": {
        "CLOSEBOT_API_KEY": "your_api_key_here"
      }
    }
  }
}
```

## Tool Groups

| Group | Tools | Description |
|---|---|---|
| Bot Management | 18 | CRUD bots, AI creation, publish, versioning, templates, source attach |
| Source Management | 9 | Sources (GHL sub-accounts), calendars, channels, fields, tags |
| Lead Management | 6 | Search, filter, update leads and lead instances |
| Analytics & Metrics | 14 | Agency summary, booking graphs, leaderboards, message analytics, logs |
| Bot Testing | 7 | Test sessions with send/listen, force-step, rollback |
| Library & KB | 11 | Files, web-scraping, source attachment, content management |
| Agency & Billing | 18 | Billing, transactions, wallets, usage tracking, re-billing |
| Configuration | 30 | Personas, FAQs, folders, notifications, live demos, webhooks, API keys |

## Tool Apps

| App | Description |
|---|---|
| `bot_dashboard_app` | Grid view of all bots with status, versions, source count |
| `analytics_dashboard_app` | Agency stats, response/booking/revenue metrics with time range |
| `test_console_app` | Interactive test session viewer with conversation and controls |
| `lead_manager_app` | Searchable lead table with fields and conversation data |
| `library_manager_app` | File list with type indicators, sources, and scrape status |
| `leaderboard_app` | Global/local rankings by responses, bookings, or contacts |

## Environment Variables

| Variable | Required | Description |
|---|---|---|
| `CLOSEBOT_API_KEY` | Yes | Your CloseBot API key |
| `CLOSEBOT_BASE_URL` | No | Override API base URL (default: `https://api.closebot.com`) |

## License

MIT
