# Connecting an AI assistant (MCP) Klozzo speaks the [Model Context Protocol](https://modelcontextprotocol.io). An AI assistant can search your contacts, read a person's file, look up your lead stages and your custom field keys, and capture a lead — without you writing a single line of glue code. It is the same API you already have, through a door an assistant understands. **Same token, same permissions, same location.** If a token cannot delete a contact over HTTP, it cannot delete one here either — and in this first version nothing can, because deleting is not a tool you hand to an agent. ## Connect it The server lives at `https://klozzo.com/mcp` and takes a bearer token. Create yours in the CRM under **Settings → AI connection**: turn the connection on for your company, name the connection, pick how long it lasts and copy the token — it is shown once. The token is **read-only** and **tied to one company**: it reads that company's data whichever company you have open in the CRM, and it cannot write. The same screen shows the ready-to-copy blocks below with your token already in them, and lets you revoke the connection at any time. ### Claude Code ```bash claude mcp add --transport http klozzo https://klozzo.com/mcp \ --header "Authorization: Bearer YOUR_API_TOKEN" ``` ### Claude Desktop Claude Desktop reaches remote servers through `mcp-remote`. Add this to `claude_desktop_config.json`: ```json { "mcpServers": { "klozzo": { "command": "npx", "args": [ "mcp-remote", "https://klozzo.com/mcp", "--header", "Authorization:${KLOZZO_AUTH}" ], "env": { "KLOZZO_AUTH": "Bearer YOUR_API_TOKEN" } } } } ``` ### claude.ai on the web and mobile claude.ai connects with OAuth rather than a pasted token. That sign-in is not available yet; until it is, use Claude Code or Claude Desktop. ### ChatGPT and anything else that speaks MCP Add a remote MCP server pointing at `https://klozzo.com/mcp` and set an `Authorization: Bearer YOUR_API_TOKEN` header. Klozzo implements the streamable HTTP transport, which is what current clients use. > The token is a password. Paste it into the client's own credential field — > never into a chat message, a shared config file, or a ticket. What your > assistant reads is sent to your AI provider under your own account. ## What it can do | Tool | What it does | Writes? | |---|---|---| | `search-contacts` | Lists the people in your company, whoever on the team owns them, newest first; returns each one's `ulid`. Filters: `search` (name, email, phone, company), `created_from`/`created_to` (YYYY-MM-DD), `source`, `original_source`, `campaign`, `landing_page`, `whatsapp_campaign` (the `ulid` or exact name of a WhatsApp campaign, see `list-campaigns`; not the same as `campaign`, which is the first-touch UTM) to keep only the people who received it, `whatsapp_campaign_status` (`sent`, `delivered`, `read`, `replied` or `failed`; cumulative, so `replied` also counts as read) to narrow it to how far the message got, `lead_stage` and `owner` (name or id), `contact_type`, `tags` and `custom_fields` (`[{key, op, value}]`, ops `equals`, `not_equals`, `contains`, `in`, `between`, `before`, `after`, `is_empty`, `is_not_empty`). Pages of 50 (up to 200 with `limit`): repeat the call with `next_cursor` → `cursor` until `has_more` is false. `with_total` adds the total count and `include_custom_fields` adds each person's `custom_fields` | No | | `aggregate-contacts` | Counts people in one call, numbers only: the same filters as `search-contacts` — including `whatsapp_campaign` and `whatsapp_campaign_status`, so "how many of the Buen Fin campaign replied, by stage?" is a single call — plus up to two `group_by` dimensions (`source`, `original_source`, `original_campaign`, `original_landing_page`, `lead_stage`, `owner`, `contact_type`, `cf:`, `created:year`, `created:month` in your company's time zone). Top 50 groups plus an `others` line, `total` always; people with no value count under "(sin valor)". Cached for 10 minutes; heavy, so it counts as 5 calls against the rate limit — only for people who can see Reports in your company | No | | `get-contact` | Reads one person by `ulid`, with their owner, who last contacted them and when (`summary`), where they came from (`origin`: original and latest source, medium and campaign, lead score and grade, plus a compact first and latest touch with their UTMs and the WhatsApp ad that brought them), what the AI profile knows (`ai_profile`: what they are looking for, their main problem, temperature and summary), their `tags`, commercial summary — deals, quotes, amount paid and active subscriptions (`commercial`) — a résumé of what you have done with them (`engagement`: campaigns received and replied to, meetings completed and no-shows, next meeting with its host, active follow-up sequence), every custom field, last 20 activity events, open tasks and last 5 notes. Never returns IPs, device fingerprints or click id values | No | | `get-contact-history` | Reads the whole history of one person by `ulid`, one source per call (`type`: `notes`, `calls`, `messages`, `activity`, `touches`, `campaigns`, `meetings` or `followups`), newest first, filterable by `from`/`to` and paginated with `next_cursor` → `cursor` (50 per page, up to 200). Notes in full text, calls with agent, duration and outcome (HubSpot imports included), messages from every channel with the agent who sent them, and the timeline. `touches` lists every time the person arrived or raised their hand: channel, all UTMs, interest, the Facebook or Instagram ad they clicked (`ad`: title, body, source_url, source_type, source_id), form or chat answers (`answers`) and a `has_click_id` yes/no. `campaigns` lists the WhatsApp campaigns they received (campaign `ulid` and name) with status and when each was sent, delivered, read, replied to or clicked, and the meeting booked or the sale won. `meetings` lists the meetings they booked: status (scheduled, cancelled, completed, no-show or rescheduled), meeting type, host, time with its time zone, source (booking page or AI agent), cancellation reason and form answers. `followups` lists the follow-up sequences they were in: sequence name, status, why it stopped (replied, an agent took over, unsubscribed, do-not-disturb, contact deleted or manual), start and end dates, and next send. Never returns IPs, device fingerprints, click id values, signed links, cancellation or video-call links, calendar ids or phone numbers | No | | `search-conversations` | Searches the text of messages and notes of the whole company, to answer "what do my leads ask for most?": `query` (a plain fragment; leave it out for the most recent texts), `source` (`messages`, `notes` or `both`), `direction` (`inbound` by default — what customers wrote —, `outbound` or `any`), `channel` (notes have none, so it limits the search to messages), `from`/`to`, `contact` (a `ulid`) to look inside one person, and `whatsapp_campaign` (the `ulid` or exact name of a WhatsApp campaign, see `list-campaigns`) to look only at the people who received it: with `direction=inbound` it returns only what they wrote **after** receiving it, and notes are limited to those same people. A campaign that does not exist in your company is an error. Without dates it reads the last 12 months and reports it in `range_applied`; pass `from` to go further back. Each hit has date, channel, direction, contact (`ulid` and name) and a plain-text `snippet` of about 300 characters around the match; newest first, paginated with `next_cursor` → `cursor` (50 per page, up to 200). Heavy: counts as 5 calls against the rate limit, so narrow it with dates | No | | `customer-origins` | Where new customers come from in a period: by origin, source/campaign and country (phone and website visits), like the Reports screen — only for people who can see Reports in your company | No | | `follow-up-attention` | What needs follow-up: people waiting for an answer, quotes without reply, stalled deals and overdue tasks, plus this week's new contacts with no open task, sequence or outgoing message — only for people who can see Reports in your company | No | | `list-lead-stages` | Lists the stages this account defines, with their ids | No | | `list-custom-fields` | Lists your custom fields with the exact key each one answers to | No | | `list-deals` | Lists deals, newest first, with amount, stage, owner and the person they belong to. Filters: `status` (`open`, `won`, `lost`), `closed_from`/`closed_to` and `created_from`/`created_to` (YYYY-MM-DD, your company's time zone), `owner` and `stage` (name or id), `contact` (a person's `ulid`), `min_amount`/`max_amount` (whole currency units). Pages of 25 (up to 200 with `limit`): repeat the call with `meta.next_cursor` → `cursor` until `meta.has_more` is false | No | | `sales-summary` | Adds up sales over any period in one call, numbers only: `metric` `won_amount` (default, by close date), `won_count` or `collected` (payments, by payment date), `from`/`to` with no limit, and `group_by` `year`, `month`, `owner`, `customer` (the deal's main contact with their `contact_ulid`; the best customers first), `product` (lines sold, before tax; not with `collected`) or `stage`. Top 10 by default (`limit` up to 100), `totals` always; every amount carries its currency and currencies are never added together. Heavy, so it counts as 5 calls against the rate limit — only for people who can see Reports in your company | No | | `list-campaigns` | Lists the WhatsApp campaigns of your company, newest first, with their results (`totals`: `recipients`, `sent`, `delivered`, `read`, `replied`, `failed`, `skipped`, `meetings_booked`, `deals_won`; the stages are cumulative, so someone who replied also counts as read, delivered and sent). Each row carries the campaign `ulid`, `name`, `status`, `channel`, `template`, `reply_route` and its scheduled, started and completed dates — use that `ulid` as `whatsapp_campaign` to search the conversations and the people who received it. Filters: `status` (`draft`, `scheduled`, `sending`, `paused`, `completed`, `cancelled`, `failed`), `from`/`to` (creation date, YYYY-MM-DD, your company's time zone) and `search` (part of the name); archived campaigns are left out unless `archived` is true. Pages of 25 (up to 200 with `limit`): repeat the call with `meta.next_cursor` → `cursor` until `meta.has_more` is false | No | | `capture-lead` | Records that a person raised their hand | **Yes** | | `create-deal` | Opens a commercial opportunity | **Yes** | | `add-note` | Leaves a note on one person (`ulid`, `body`), written as the connection's user; shows in their notes and timeline. Needs a connection that can make changes | **Yes** | | `create-task` | Creates a follow-up task with a `title`, an optional person (`ulid`), a `due_at` and a team member in charge (`assigned_user_id`, the connection's user by default). Needs a connection that can make changes | **Yes** | | `update-contacts` | Edits up to 500 people at once: `changes` can set `lead_stage` (name or id), `owner` (one team member), `contact_type`, `first_name`, `last_name`, `company_name`, `custom_fields` (by key) and, on a single person, `email` or `phone`. Pick them with `ulids` or a `filter` (the same keys as `search-contacts`; an empty filter is refused). The first call is a preview that changes nothing and returns the exact count, a sample and `confirmation_token`; repeat it with the token to apply. People you may not edit are skipped and listed. Each change is recorded with before and after so it can be undone | **Yes** | | `create-custom-field` | Creates a custom field (key, name, type, dropdown options). Only owners and admins; needs a connection that can make changes. Recorded in the change log so it can be undone | **Yes** | | `update-custom-field` | Renames a custom field or adds options to a dropdown (never removes options, never changes key or type). Only owners and admins; shows a preview and needs your explicit yes first | **Yes** | | `update-deal` | Moves or closes one deal (`deal` = its `ulid` from `list-deals`): `stage` (name or id of its pipeline; a won or lost stage closes it) or `status` (`won`, `lost`, `open` to reopen), plus `lost_reason` (required to lose), `expected_close_date` and `owner` (managers only). It goes through the same service as the web: timeline event, change log, the won notice, the person becomes a customer and the live quotes are withdrawn. The amount comes from the quotes and cannot be set. Shows a preview with before → after and needs your explicit yes first; recorded so it can be undone | **Yes** | | `delete-contacts` | Moves up to 500 people to the trash (soft delete: nobody is erased for good and they can be restored). Pick them with `ulids` or a `filter` (the same keys as `search-contacts`; an empty filter is refused, and more than 500 matches are refused so you can narrow it). The first call deletes nothing: it says "Vas a eliminar N contactos" with the exact number, a sample of 10 (name, email) and `confirmation_token`. The assistant has to tell you that exact number and wait for your explicit yes before repeating the call with the token. People you may not delete are skipped and listed. Each deletion is recorded so it can be undone | **Yes** | | `list-mcp-changes` | Lists what AI connections changed in your company, newest first: tool, time, the record, and what it was before → after in words (the stage "Ganado", not an id). Filters `from`/`to`, `tool`, `batch_ulid`, `subject` (a person's or deal's ulid); pages with `next_cursor`. Owners and admins see everyone's changes, anybody else only their own | No | | `undo-mcp-change` | Undoes one change (`change_id`) or a whole tool call (`batch_ulid`): puts previous values back, restores people sent to the trash, deletes what was created. It never overwrites what somebody changed afterwards: those fields are reported as conflicts. A created custom field that already has values is kept. Shows a preview (count and conflicts) and needs your explicit yes first; the undo is recorded too, so it can be undone | **Yes** | `update-contacts`, `update-deal`, `delete-contacts`, `undo-mcp-change`, `create-custom-field` and `update-custom-field` write directly into your company and are only offered to a connection with changes enabled. The tools that write (`capture-lead`, `create-deal`) map onto one endpoint of [the reference](/docs) and call it the same way an integration would. The ones that only read — including `list-deals`, `list-lead-stages` and `list-custom-fields` — read your company's data directly, with the same visibility the CRM screens give you, so a read-only connection (a token or claude.ai) can use them too. ### What it deliberately cannot do `delete-contacts` only moves people to the trash, and `undo-mcp-change` can bring them back: nothing is erased for good. `add-note` and `create-task` write straight into your company without asking for confirmation, since they only create; every call is logged so it can be undone. There is still no tool for moving a deal between pipelines or for setting its amount (its stage only changes through `update-deal`), because the API has no endpoint for it yet. See [What the API does not cover](/docs/guides/not-covered). ## Permissions, in one paragraph The assistant is not a new kind of user. It authenticates with a token that belongs to a person, and everything it reads or writes is scoped to that token's location — **the one the token is tied to, not the one the person happens to have open in the CRM**. Token abilities apply unchanged: a token without an ability is refused here exactly as it would be refused over HTTP. ## What gets recorded Every write an assistant makes lands in the change log under its own verb, *«escribió por MCP en»*, separate from what a person does. That distinction exists because the question somebody asks three weeks later is rarely "who changed this" — it is "did somebody do this, or did the assistant?". You can read it in the CRM under **Settings → Change log**. The body sent is not recorded: it can carry somebody's email and phone, and the change log is read by the whole team. ## Two things to tell your assistant These are the two mistakes an assistant makes on its own, and the server's instructions already warn about both — but they are worth knowing: 1. **Never guess a lead stage id or a custom field key.** They are a per-account catalogue. Call `list-lead-stages` and `list-custom-fields` first. A custom field key that does not exist is not an error — it is quietly dropped — so a guess fails silently and you find out weeks later. 2. **`capture-lead` is safe to retry; `create-deal` is not.** Capturing the same person twice gives one contact and one touch. Creating the same deal twice gives two deals, so look with `list-deals` before calling it again. ## When something goes wrong The assistant will show you the error the API gave, in the words the API used — a refusal is returned as an error and not as text that looks like a result, so an assistant cannot mistake "no encontrado" for an answer. The [Errors](/docs/guides/errors) page explains every code and which ones are worth retrying. If the client says it cannot connect, the usual cause is the token: check it is not expired under **Settings → API tokens**, and that the `Authorization` header reached the server with the word `Bearer` in front of it.