PerpetuusPerpetuus Developers

AI agents (MCP)

How to integrate the Perpetuus API with artificial intelligence agents through the Model Context Protocol (MCP).

The Perpetuus CRM provides a standalone MCP (Model Context Protocol) server. It lets agents (Claude, ChatGPT, Cursor, and SDKs) read and edit the CRM with the same permissions as your user.

There are two ways to connect:

ForHowCredential
Claude, ChatGPT, and other apps with a Connect buttonRemote URL + OAuth 2.1 sign-inOAuth token chosen at consent (organization + permissions)
Cursor, scripts, and developersRemote URL or stdio + API keyAPI token (ppt_…)

Remote MCP server URL:

https://perpetuus-crm-mcp.services.perpetuus.com.br/mcp

Connect to Claude or ChatGPT (OAuth)

You do not need to install anything or copy a key. The app discovers the Perpetuus sign-in on its own.

Claude (web or desktop): in Settings → Connectors → Add custom connector, paste the MCP URL above and click Connect. ChatGPT: with developer mode turned on, in Settings → Apps & connectors → Create, paste the same URL, choose OAuth authentication, and create it.

A Perpetuus window opens. Sign in with email and password or with Google (if you are already signed in to the app, this step is skipped).

On the Autorizar acesso screen, check the app name and domain, choose one organization, and review the permissions. Anything your role does not allow appears unchecked and locked. Uncheck what the app does not need and click Permitir.

The browser returns to Claude or ChatGPT, already connected. Ask: “list my boards in Perpetuus”.

What the app can do depends on the approved permissions:

PermissionOn the screenUnlocks
crm:readVer dados do CRMContacts, cards, boards, tasks, calendar, and products
crm:writeCriar e editar dados do CRMCreate, update, move, and delete contacts, cards, and tasks
chat:readVer conversasSupport conversations and messages
chat:writeEnviar mensagensReply to and start conversations
ai:controlControlar os agentes de IAPause, resume, and take over AI support
campaign:readVer campanhasCampaigns and results

Even after a permission is approved, every call still goes through the RBAC of your role in the organization: the app never does more than you would do in the interface.

Revoke: in Configurações → Apps conectados (inside the connected organization), click Revogar. Access stops immediately on the backend and within 1 minute on the MCP. To use it again, connect and authorize once more. Each connection applies to one organization; for another organization, connect again.

How it works: without a token, POST /mcp responds 401 with WWW-Authenticate: Bearer resource_metadata="https://perpetuus-crm-mcp.services.perpetuus.com.br/.well-known/oauth-protected-resource/mcp". That document (RFC 9728) points to the authorization server https://api.perpetuus.com.br/oauth. The app requests the token with resource = the MCP URL (RFC 8707), and the MCP only accepts an OAuth token whose audience is itself: a token issued for the API (for example, by Zapier) receives 401 invalid_token on the MCP. Flow details are in OAuth 2.1.

Common problems

SymptomLikely cause
“Este pedido de autorização expirou”The screen stayed open for more than 10 minutes. Go back to the app and click Connect again.
“A autorização expirou ou começou em outro navegador”Sign-in started in one browser and finished in another (the flow cookie does not follow). Do everything in the same browser.
A permission is locked on the screenYour role in the organization does not have that permission. Ask an ADMIN or choose another organization.
The app asks you to connect againThe connection was revoked or stayed unused for more than 30 days.

Connect with an API key (Cursor and developers)

For Cursor, VS Code, scripts, and the Vértice client, the API key (ppt_…) still works, on the remote or local MCP. With an API key, the organization comes from the key; x-tenant-id is optional.

Remote MCP with an API key

.cursor/mcp.json

{
"mcpServers": {
  "perpetuus-crm": {
    "url": "https://perpetuus-crm-mcp.services.perpetuus.com.br/mcp",
    "headers": {
      "Authorization": "Bearer ppt_sua_chave_de_api"
    }
  }
}
}

Quick setup in Cursor (local, stdio)

Generate an API token and note the organization slug.

In the repository, go into perpetuus-crm-mcp and run npm install.

Copy the JSON below into .cursor/mcp.json (adjust cwd, tenant, and token).

Restart Cursor and ask: “list my boards in Perpetuus”.

MCP configuration for Cursor

.cursor/mcp.json

{
"mcpServers": {
  "perpetuus-crm": {
    "command": "npx",
    "args": ["tsx", "src/stdio.ts"],
    "cwd": "./perpetuus-crm-mcp",
    "env": {
      "STRAPI_URL": "https://api.perpetuus.com.br",
      "MCP_CRM_TENANT_ID": "sua-organizacao",
      "MCP_CRM_USER_TOKEN": "seu_token_de_api"
    }
  }
}
}

Why MCP?

  • Unified interface: the agent lists boards, searches contacts, moves cards, and creates tasks without memorizing REST paths.
  • Security: the MCP only talks to the REST API — tenant, RBAC, and plan still live in the backend.
  • Separate lifecycle: deploy and auditing are independent from the messaging runtime.

Running locally

STDIO (Cursor / VS Code)

STRAPI_URL=https://api.perpetuus.com.br \
MCP_CRM_TENANT_ID=sua-organizacao \
MCP_CRM_USER_TOKEN=seu_token_de_api \
npx tsx src/stdio.ts

HTTP (remote connections)

STRAPI_URL=https://api.perpetuus.com.br \
MCP_CRM_TENANT_ID=sua-organizacao \
MCP_CRM_USER_TOKEN=seu_token_de_api \
MCP_CRM_HTTP_PORT=3031 \
npx tsx src/http.ts
curl -fsS http://127.0.0.1:3031/health

Tool catalog

Contacts

  • crm_search_contacts, crm_get_contact, crm_create_contact, crm_update_contact
  • crm_upsert_contact: creates or updates by email and/or phone (POST /api/contacts/upsert). Search is limited to the organization, in matchBy order (default: email, then phone), with case-insensitive email and phone in any Brazilian format. Returns meta.created and meta.matchedBy.
  • crm_add_contact_note

Boards and pipeline

  • crm_list_boards, crm_get_board_structure
  • crm_search_cards, crm_create_card, crm_bulk_create_cards, crm_update_card, crm_move_card_phase, crm_delete_card, crm_list_board_members
  • crm_list_card_comments, crm_create_card_comment
  • crm_export_cards, crm_list_saved_filters, crm_get_saved_filter, crm_create_saved_filter, crm_update_saved_filter, crm_delete_saved_filter

Board structure in one call

crm_get_board_structure is the structure read (GET /api/boards/:id/structure): board (with wonPhaseId/lostPhaseId), ordered phases with kind (form, stage, won, lost), fields of each phase (slug, type, required, options), and tags. Optional parameters:

ParameterEffect
includeSections: phases, fields, tags, conditions (field conditionals). Default: phases, fields, tags. fields come inside each phase.
phaseIdOnly that phase (with its fields).
fieldIdOnly that field, inside the phase that contains it.

It replaces the old standalone reads (crm_get_board, crm_list_board_phases, crm_get_board_phase, crm_list_board_fields, crm_get_board_field, crm_list_board_tags).

Saved filters and CSV export

crm_list_saved_filters(boardId) lists the filters the person sees in the board filter menu (personal + shared). Pass the documentId in savedFilterId of crm_search_cards or crm_export_cards to apply the filter exactly as the UI does (quick filters, advanced AND/OR conditions, custom fields, and relative periods such as "últimos 30 dias"). Explicit arguments (tagIds, phaseId, query…) override the saved filter. "Meus cards" filters require meMembershipId.

crm_export_cards generates the same CSV as the Exportar button in the list (card data and all custom fields) and returns url, fileName, and total. Use scope: "selected" with selectedIds to export only some cards. The URL is public: share it only with whoever requested it.

Creating cards (same as the UI form)

The board entry form (phase of order 0) defines which fields are required. Discover them with crm_get_board_structure, then send the values in fields, keyed by the field slug (fields.name becomes the card title):

{
  "boardId": "…",
  "fields": { "name": "Maria Souza", "email": "maria@acme.com", "whatsapp": "+5511999999999", "empresa": "Acme", "cargo": "CEO" },
  "tags": ["linkedin"]
}

For spreadsheets (LinkedIn, CSV) use crm_bulk_create_cards (up to 50 per call, with dryRun to validate without creating). Validation failures return in error.details which fields are missing or invalid, together with the entry form.

Structure builder (blueprint)

  • crm_plan_blueprint, crm_apply_change_set, crm_revert_change_set, crm_list_change_sets, crm_get_change_set

To assemble an entire funnel (board, phases, fields, and tags) — or whenever there are 3 or more entities — describe the structure in a declarative blueprint instead of calling the creation tools one by one. This is the only path to assemble a complete funnel (the old crm_setup_board was removed); to start from a model, use crm_create_board with template. The flow has three steps:

  1. crm_plan_blueprint validates the blueprint and returns a change-set: the ordered list of operations (with title, diff, and status), warnings, and impact (impact.counts of creations, changes, and reuses). It does not change the CRM — it only stores the plan.
  2. Show the plan to the person and, with their confirmation, call crm_apply_change_set with the returned id. Application follows the order board → phases → fields/tags and is idempotent: if it stops in the middle, status becomes partially_applied (or failed) with error; fix the cause and call it again to resume. Check status before saying it is done.
  3. crm_revert_change_set undoes in reverse order (deletes what it created and restores what it changed). Items changed by someone else after the apply are kept (they appear in warnings), and a board/phase that already received cards blocks the revert. Deleting a created board requires the ADMIN role.
{
  "version": 1,
  "board": { "ref": "new", "name": "Vendas B2B" },
  "phases": [
    { "key": "qualificacao", "name": "Qualificação" },
    { "key": "proposta", "name": "Proposta" },
    { "key": "ganho", "name": "Ganho", "kind": "won" },
    { "key": "perdido", "name": "Perdido", "kind": "lost" }
  ],
  "fields": [
    { "key": "empresa", "label": "Empresa", "type": "text", "required": true },
    { "key": "porte", "label": "Porte", "type": "select", "options": ["Pequena", "Média", "Grande"], "phaseKey": "qualificacao" }
  ],
  "tags": [{ "key": "inbound", "name": "Inbound", "color": "#22c55e" }]
}
FieldRules
versionAlways 1.
board{ "ref": "new", "name", "boardType"? } (kanban, chat, or hybrid) creates a board; { "ref": "existing", "documentId" } changes an existing one.
phases[] (up to 30)Local key, name, order?, kind? (form, stage, won, lost), description?. A new board is already born with phase 0 (public form, kind: "form"); won/lost configure the won and lost phases. On an existing board, a phase with the same name is reused.
fields[] (up to 200)Local key, label, type, phaseKey? (without it, the field goes to the public form), required?, options (required on select, multiselect, and radio: text, or { "label", "value" } when the stored value must differ from the label), content + align? (left, center, right; statement only), placeholder?, helpText?. The slug comes from the label and is unique on the board.
tags[] (up to 50)Local key, name, color? (hex). A new board is already born with default tags; a tag with the same name is reused.

The keys only link items inside the blueprint (for example, phaseKey) and are not stored. fieldConditions, distributionQueues, automations, integrations, and members are accepted, but not executed yet: they generate a warning in the plan and nothing is created.

crm_plan_blueprint and crm_list_change_sets accept sessionId to group the change-sets of the same conversation. crm_list_change_sets returns the person's 20 most recent ones (ADMIN sees those of the organization).

The tools require the ADMIN or MANAGER role, and each operation is checked again with the same permission as the equivalent REST route (create board, phase, field, tag…): the change-set never grants what the role does not have. With an API token, plan/apply/revert require crm:write; list and get require crm:read.

Analytics

  • crm_get_board_report, crm_aggregate_card_field

Calendar and meetings (BETA)

  • crm_list_agenda_events brings together the connected calendar, campaigns, tasks, and card due dates; check meta.partial when a source is unavailable.
  • crm_list_card_meetings lists the Meet tab, and crm_find_meeting_slots queries times on the connected calendar.
  • crm_schedule_card_meeting, crm_update_card_meeting, and crm_cancel_card_meeting require human confirmation: they can change the connected calendar and notify guests.

boardId and cardId are CRM documentId values. The meeting id is also a documentId, but it identifies the meeting, not the card. Flow: query slots, confirm time/timezone/guests, and schedule.

Segments

  • crm_list_segments, crm_get_segment, crm_create_segment, crm_update_segment, crm_delete_segment, crm_preview_segment, crm_resolve_segment, crm_refresh_segment, crm_get_segment_filter_options

The flow matches the Disparos UI: discover fields with get_segment_filter_options, validate reach with preview_segment, then create_segment with { conditions: [...] } (and optionally requiredSegments / excludedSegments).

crm_get_segment returns the contactCount of the last resolution (15 minutes if an active, published automation listens to the segment, otherwise about 6 hours). crm_resolve_segment counts live (the total field). crm_refresh_segment forces immediate resolution and fires the segment.contact_entered / segment.contact_left automation triggers for whoever changed — unlike crm_resolve_segment, which only lists contacts with no side effect.

Products and categories

  • crm_list_products, crm_get_product, crm_create_product, crm_update_product, crm_delete_product
  • crm_list_product_categories, crm_get_product_category, crm_create_product_category, crm_update_product_category, crm_delete_product_category

Creation requires name, sku, and price (SKU unique per organization), as in the CRM form. Product image upload remains in the UI; the MCP covers the rest of the catalog.

Templates

  • WhatsApp: crm_list_whatsapp_templates, crm_create_whatsapp_template, crm_upload_whatsapp_template_media_handle, crm_sync_whatsapp_templates, crm_delete_whatsapp_template
  • Email: crm_list_email_templates, crm_get_email_template, crm_create_email_template, crm_update_email_template, crm_delete_email_template, crm_preview_email_template, crm_send_test_email

Board templates (crm_list_templates / crm_get_template) are read-only — they are used to create funnels, not to register new board templates.

Tasks

  • crm_list_tasks, crm_create_task, crm_update_task (includes taskStatus)

crm_create_task and crm_update_task accept priority (low, medium, high, urgent), recurrence (none, daily, weekly, monthly), and recurrenceInterval (1–365). taskStatus is configured by the board — there is no fixed enum; the interface uses pending, in-progress, completed, and cancelled as the default.

When a recurring task that has a dueDate is completed, the backend automatically creates the next occurrence. Tasks with a due date receive an automatic reminder via cron; the MCP does not expose a reminder field.

Chat, conversations, and templates

The MCP operates the inbox through the Perpetuus API, never directly on the chat provider or Meta. This preserves tenant isolation, RBAC, and CRM auditing.

Conversation IDs (inboxId, conversationId, and message cursors) are numeric. Contact, card, board, and chat-channel IDs are Strapi documentId values. They are not interchangeable.

Scopes and confirmation

  • Reads require chat:read.
  • Writes require chat:write and must be confirmed by a person in the assisted flow, including status changes, read marks, and card linking.
  • Messages, attachments, and starting a conversation can reach a real person on WhatsApp; confirm the recipient, content, and channel before executing them.
  • The backend still applies the user's granular permission, the team scope, and the contracted plan. A token with a scope does not replace RBAC.

Read and reply to an existing conversation

  1. crm_list_conversations (use enriched=true when you need the linked card).
  2. crm_get_conversation and crm_list_conversation_messages.
  3. Confirm the human reply and run crm_send_conversation_message.
  4. Optionally use crm_mark_conversation_seen or crm_update_conversation_status.

To browse history, pass the numeric ID of the last message in before (older) or after (newer). Do not use documentId as a cursor.

First contact (same as the UI)

  1. Find/create the CRM contact.
  2. Run crm_sync_contact_to_chat.
  3. Discover the inboxId with crm_list_chat_inboxes and the channelId with crm_list_chat_channels.
  4. Outside the 24-hour window, list the HSM with crm_list_whatsapp_templates(channelId).
  5. After human confirmation, call crm_start_conversation with message: { content, template_params: { name, category, language, processed_params } } — the same shape as the new-conversation UI. Free text only inside the window.

Before opening one, use crm_list_contact_conversations to avoid a duplicate thread.

Create / switch card (same as the UI)

  1. Create a card: crm_get_conversation → crm_list_inbox_board_links(inboxId) → crm_create_card_from_conversation(boardLinkId).
  2. Switch card: crm_list_contact_conversation_cards(contactId, conversationId) → crm_switch_conversation_card(targetCardId).

WhatsApp and the 24-hour window

In an already existing conversation, send an HSM with crm_send_conversation_message (template_params + content_type/content_attributes). To create a template with a media HEADER: crm_upload_whatsapp_template_media_handle → crm_create_whatsapp_template → crm_sync_whatsapp_templates.

Conversation catalog

GroupTools
Inboxcrm_list_chat_inboxes, crm_get_chat_inbox, crm_list_inbox_board_links
Conversationscrm_list_conversations, crm_get_conversation, crm_get_conversations_meta, crm_list_contact_conversations, crm_get_conversation_unread_counts
Messagescrm_list_conversation_messages, crm_send_conversation_message, crm_send_conversation_attachment, crm_start_conversation
Shared statecrm_update_conversation_status, crm_mark_conversation_seen, crm_mark_conversation_unread
Relationship with CRMcrm_get_conversation_card, crm_list_contact_conversation_cards, crm_create_card_from_conversation, crm_link_conversation_to_card, crm_switch_conversation_card, crm_list_chat_cards
Chat contactscrm_search_chat_contacts, crm_sync_contact_to_chat

crm_send_conversation_attachment uses the backend multipart endpoint, but the tool receives each file as base64, filename, and mimeType. The backend validates the supported type and limits each file to 50 MB.

WhatsApp channels and templates

Use crm_list_chat_channels to discover the channelId (documentId) and crm_get_channel_connection_status before operating a channel with a problem. crm_list_channel_boards returns the channel-board links; the linkId from that result is required in crm_create_card_from_conversation.

crm_get_channel_connection_status(channelId) confirms whether the channel is actually connected: it validates the inbox and, on WhatsApp, the account health on Meta. It returns connected, message, error, inbox, and health, without changing the channel (with a token, chat:read is enough). If it is not connected, reconnection is done on the integrations screen — credentials never pass through the agent.

Defines which board receives cards from the conversations of each WhatsApp channel.

ToolWhat it does
crm_list_channel_boardsLists links by boardId (channels that feed the board), by channelId (boards fed by the channel), or by both. Read only.
crm_link_channel_boardLinks channelId to boardId. Optionals: autoCreateCard (default true), priority (0–1000; lower = preferred), isPrimary, contactToCardMapping, idempotencyKey.
crm_update_channel_boardChanges active, autoCreateCard, priority, isPrimary, or contactToCardMapping of a link (boardId + linkId). active: false pauses without deleting.
crm_unlink_channel_boardDeletes the link (boardId + linkId). Existing cards and conversations are kept; if it was the board's last link, the board chat is turned off. Destructive.

The linkId comes from crm_list_channel_boards (links[].linkId). New cards always enter the board's initial phase — there is no entry phase per link (use an automation to move them). Linking fails if the channel is already linked to the board, and it turns on the board chat.

contactToCardMapping says how the contact/conversation fills the new card:

{
  "enabled": true,
  "mappings": [
    { "source": "contact.name", "target": "title" },
    { "source": "contact.phone_number", "target": "whatsapp", "required": true },
    { "source": "contact.custom_attributes.empresa", "target": "empresa", "transform": "trim" },
    { "target": "origem", "transform": "static:WhatsApp" }
  ]
}
  • source: contact.name, contact.email, contact.phone_number, contact.identifier, conversation.id, conversation.display_id, conversation.status, inbox.name, message.content, or contact.custom_attributes.<key>. Omit it only with transform: "static:<value>".
  • target: title, description, dueDate, or the slug of a field in the board's public form (phase 0).
  • transform: trim, uppercase, prefix:<text>, or static:<fixed value>.

With autoCreateCard: true, every required field of the public form must be mapped, otherwise the backend rejects the link. Without a mapping, the default is contact.name → title.

Writes require the ADMIN or MANAGER role and human confirmation. link, update, and unlink return undo with the call that undoes the operation (update also returns previous). None of these tools accept or return secrets: sensitive values come back masked.

OperationTool
List Meta templates of the channelcrm_list_whatsapp_templates
Upload media handle (HEADER)crm_upload_whatsapp_template_media_handle
Create a Meta templatecrm_create_whatsapp_template
Delete a Meta templatecrm_delete_whatsapp_template
Sync the inbox catalogcrm_sync_whatsapp_templates

crm_list_whatsapp_templates uses the canonical route GET /chat-channels/:channelId/templates; the old global route without a channel is not used. Creating templates submits an external asset to Meta; deleting can break campaigns, and syncing changes the inbox catalog. All of them require human confirmation.

Email templates

crm_list_email_templates and crm_get_email_template use documentId. crm_preview_email_template renders content with a safe example contact and does not send email. The available writes are crm_create_email_template, crm_update_email_template, and crm_delete_email_template; the last one is destructive.

crm_send_test_email sends a real message to a single recipient and ignores the suppression list. Always preview and ask for confirmation before the test. These tools require the tenant to have the campaigns feature and the appropriate permission.

Operations intentionally not exposed

For security, the MCP does not expose global chat configuration/disablement, embedded signup, deletion of conversation context, writing of email configuration with secrets, or webhooks.

The complete tool specification is in the README of the perpetuus-crm-mcp package. For the REST contract, use the API Reference or download /export/docs.json.

WhatsApp templates with image or video

In crm_create_campaign and crm_update_campaign, send messageConfig.headerMedia with type (image or video) and a public HTTPS url. In chat, crm_send_conversation_message uses template_params.processed_params.header with media_type and media_url; variables remain in processed_params.body.

The MCP receives URLs, with no generic local file upload for sending. The handle from crm_upload_whatsapp_template_media_handle is a sample for Meta approval, not the media used in the send. See the media and receipt examples. That page is currently available in Portuguese.

crm_get_campaign_stats passes through sent, delivered, and read from the backend. Acceptance does not confirm delivery, and finishing the queue does not confirm a read.

WhatsApp Light

The mode is in local homologation and depends on enablement per organization. The MCP uses the Perpetuus backend; it does not connect directly to WAHA and does not receive provider credentials.

ToolLight behavior
crm_list_whatsapp_templatesLocal catalog; check origin, status, and usable
crm_create_whatsapp_templateCreates a local ACTIVE or DRAFT template; media uses HEADER.assetId. Recreating an archived name publishes version+1
crm_delete_whatsapp_templateArchives using hsm_id equal to the local ID
crm_sync_whatsapp_templatesReturns the local catalog; does not request Meta approval
crm_upload_whatsapp_light_assetUploads PNG/JPEG/MP4/PDF up to 16 MB and returns a reference restricted to the organization/inbox; write with confirmation
crm_preview_whatsapp_light_templateRenders the template and variables without sending a message
crm_get_whatsapp_light_delivery_issuesQueries pending/uncertain forwards
crm_get_channel_connection_statusQueries Light state through the connection endpoint, including provisioningState

The Meta handle upload is not used for Light. There are no MCP tools for Light provisioning, resume of creation, QR, pairing, reconnection, or disconnection: use the product interface for those actions. Light campaigns remain blocked by API and worker. See the channel contract. That page is currently available in Portuguese.

On this page