mergeon-mcp 1.114.0 → 1.117.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,7 @@ Y Claude usa el MCP para hacerlo directamente contra tu backend de MergeOn.
17
17
 
18
18
  1. [¿Qué expone el MCP?](#qué-expone-el-mcp)
19
19
  2. [Setup en Claude Desktop / Claude Code](#setup)
20
- 3. [Tools disponibles (354)](#tools-disponibles)
20
+ 3. [Tools disponibles (363)](#tools-disponibles)
21
21
  4. [Skills incluidos](#skills-incluidos)
22
22
  5. [Variables de entorno](#variables-de-entorno)
23
23
  6. [Desarrollo local](#desarrollo-local)
@@ -36,7 +36,7 @@ Cada tool es una función que Claude puede invocar. Internamente, el MCP autenti
36
36
 
37
37
  > **Cross-tenant (`ecommerce_id` override):** todas las tools aceptan un parámetro opcional `ecommerce_id` para apuntar a otro tenant (ej. `agent_prompts_update({ wpp_prompt_text: "...", ecommerce_id: "57" })`). La key de ecommerce 1 (superadmin) puede apuntar a **cualquier** tenant; una key de **implementador** puede apuntar a los ecommerces que gestiona; cualquier otra key solo opera sobre el suyo. El backend (`authorize_ecommerce_target`) valida la propiedad y devuelve 403 si no aplica.
38
38
 
39
- Las 357 tools cubren los principales dominios de MergeOn: **CRM, pedidos, productos, conversaciones, flujos de automatización (con catálogo de triggers/conditions/actions descubrible y filtros por reel específico via `media_ids`), calendario, marketing masivo, analytics legacy, analítica de ventas (revenue, top productos, comparativas y filtros por canal), eventos a Meta CAPI (auditoría + reenvío), nurturing/hidratación de leads, formularios dinámicos con tracking codes + UTMs, videos sociales con auto-tracking y funnel de conversión, webhooks entrantes y salientes (incluido el relay de conversaciones a un agente externo), workers, reparto automático de contactos entre asesores con avisos dirigidos por WhatsApp, admin, configuración del agente IA (prompts + tools), business context (conocimiento dinámico para el agente), plantillas de WhatsApp avanzadas, **correo saliente** (desde qué dominio sale, plantillas y bajas), configuración general del ecommerce y el **registro de actividad** (quién cambió qué y cuándo, incluidos los borrados)**.
39
+ Las 363 tools cubren los principales dominios de MergeOn: **CRM, pedidos, productos, conversaciones, flujos de automatización (con catálogo de triggers/conditions/actions descubrible y filtros por reel específico via `media_ids`), calendario, marketing masivo, analytics legacy, analítica de ventas (revenue, top productos, comparativas y filtros por canal), eventos a Meta CAPI (auditoría + reenvío), nurturing/hidratación de leads, formularios dinámicos con tracking codes + UTMs, videos sociales con auto-tracking y funnel de conversión, webhooks entrantes y salientes (incluido el relay de conversaciones a un agente externo), workers, reparto automático de contactos entre asesores con avisos dirigidos por WhatsApp, asesorías del plan que el propio cliente separa en el calendario de quien lo atiende, admin, configuración del agente IA (prompts + tools), business context (conocimiento dinámico para el agente), plantillas de WhatsApp avanzadas, **correo saliente** (desde qué dominio sale, plantillas y bajas), configuración general del ecommerce y el **registro de actividad** (quién cambió qué y cuándo, incluidos los borrados)**.
40
40
 
41
41
  ### B. Skills (guías de experto instalables en `CLAUDE.md`)
42
42
 
@@ -130,7 +130,7 @@ npx mergeon-mcp skills list
130
130
 
131
131
  ## Tools disponibles
132
132
 
133
- 357 tools organizadas en 42 dominios. Cada nombre corresponde a la cadena exacta que verás en Claude Desktop.
133
+ 363 tools organizadas en 43 dominios. Cada nombre corresponde a la cadena exacta que verás en Claude Desktop.
134
134
 
135
135
  > 💡 Los dominios marcados con **(catálogo descubrible)** exponen un tool `<dominio>_get_catalog` que devuelve los enums, shapes y reglas válidas. Llámalo SIEMPRE antes de crear/modificar para no inventar campos.
136
136
 
@@ -420,6 +420,21 @@ Para integrar y debuggear, instala el skill `webhooks-usage`.
420
420
 
421
421
  > Reparto y avisos son **configuración + flows**, no lógica fija: `assign_advisor` y `notify_advisor` sirven en cualquier flow (`sold`, `lead_status_change`, `query_created`, `human_attention`…), y la config solo aplica cuando el negocio no tiene flows de ese trigger.
422
422
 
423
+ ### Asesorías del plan (6 tools)
424
+
425
+ Las sesiones de acompañamiento que un plan incluye y que el **cliente separa él mismo** desde su panel. Dos lados en el mismo dominio, y conviene no confundirlos: el cupo lo gasta el negocio que PIDE, la cita vive en el calendario del que ATIENDE (su implementador si lo tiene, el soporte directo de MergeOn si no).
426
+
427
+ | Tool | Qué hace |
428
+ |---|---|
429
+ | `advisory_panel_get` | Lo que ve el cliente: cupo del mes, cuántas quedan, quién lo atiende, días agendables y lo que ya pidió. Cuando no puede agendar, `blocked_reason` dice por qué (`unpaid`, `no_plan`, `plan_sin_cupo`, `cupo_agotado`, `sin_soporte`) — cada motivo se arregla distinto. |
430
+ | `advisory_slots` | Horas libres de un día, ya cruzadas contra el Google Calendar de quien atiende. Vacío = ese día está lleno o el negocio no puede agendar. |
431
+ | `advisory_book` | Separa una asesoría: gasta un cupo del mes y crea la cita con enlace de Meet en la agenda de quien atiende. `topic` es obligatorio a propósito. |
432
+ | `advisory_cancel` | La suelta y **devuelve el cupo**. Solo antes de que empiece. |
433
+ | `advisory_support_get` / `advisory_support_set` | El reparto del negocio que ATIENDE: quién entra, con qué cupo relativo, horario y límites. El reparto reparte **clientes, no sesiones**: al primero que abre su panel se le asigna un dueño y se queda, para que su segunda asesoría la atienda el mismo. `members` vacío = nadie puede agendar, y el panel del cliente lo dice. |
434
+ | `advisory_agenda` / `advisory_agenda_set_status` | Lo que este negocio tiene que atender, y marcar qué pasó. `no_show` **no** devuelve el cupo: el cliente reservó media hora del equipo y no llegó. |
435
+
436
+ > El cupo sale del plan **pagado**, no del asignado: en MergeOn se le pone el plan al negocio para que lo pague después, así que lo decide `ecommerce.paid`. La prueba gratuita no da asesorías. El cupo vive en `plans.advisory_sessions_per_month` (columna, no `metadata`: desde que decide un permiso dejó de ser algo que solo se muestra).
437
+
423
438
  ### Custom Tools (6 tools)
424
439
  | Tool | Qué hace |
425
440
  |---|---|
@@ -0,0 +1,3 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { MergeOnClient } from "../client.js";
3
+ export declare function registerAdvisoryTools(server: McpServer, client: MergeOnClient): void;
@@ -0,0 +1,116 @@
1
+ import { z } from "zod";
2
+ function text(data) {
3
+ return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
4
+ }
5
+ // Asesorías del plan: las sesiones de acompañamiento que un negocio incluye en
6
+ // su plan y que su administrador separa él mismo desde el panel.
7
+ //
8
+ // Dos cosas que hay que tener claras para no leer mal estas tools:
9
+ //
10
+ // 1. El cupo sale del plan PAGADO. En MergeOn se le asigna el plan al negocio
11
+ // para que lo pague después, así que tener plan no es tener servicio: lo
12
+ // decide `ecommerce.paid`. La prueba gratuita no da asesorías.
13
+ // 2. El negocio que PIDE y el que ATIENDE son distintos. El cupo lo gasta el
14
+ // cliente; la cita vive en el calendario de su implementador (si lo tiene) o
15
+ // del soporte directo de MergeOn. `/panel` es la vista del que pide,
16
+ // `/support` y `/agenda` la del que atiende.
17
+ export function registerAdvisoryTools(server, client) {
18
+ server.tool("advisory_panel_get", "Get this business's plan advisory sessions: how many 30-minute sessions its plan includes this month, how many are left, who will attend them (their implementer if they have one, otherwise someone from MergeOn support), which days are open for booking, and every session already requested. When it can't book, 'blocked_reason' says why — 'unpaid' (plan assigned but not paid), 'no_plan', 'plan_sin_cupo' (plan includes none), 'cupo_agotado' (used them all this month) or 'sin_soporte' (nobody set up to attend). Read this before offering to book anything: each reason is fixed a different way.", {}, async () => text(await client.get("/advisory/panel")));
19
+ server.tool("advisory_slots", "List the free times for one day, already crossed against the Google Calendar of whoever attends this business. Returns an empty list when the business can't book (check advisory_panel_get first to know why) or when that day is full. Times are in the attending team's timezone, not the caller's.", {
20
+ date: z.string().describe("YYYY-MM-DD in the attending team's timezone"),
21
+ }, async ({ date }) => text(await client.get(`/advisory/slots?date=${encodeURIComponent(date)}`)));
22
+ server.tool("advisory_book", "Book one of the plan's advisory sessions. Spends one from this month's quota and creates the appointment in the calendar of whoever attends, with a Google Meet link. 'topic' is required on purpose: half an hour that starts with 'tell me what you need' is worth half, so write what the business actually wants to solve. Fails with a reason in the error when the quota is gone, the plan isn't paid, or someone else took that time while you were asking.", {
23
+ date: z.string().describe("YYYY-MM-DD, must be one of panel.open_dates"),
24
+ time: z.string().describe("HH:MM, must be one returned by advisory_slots for that date"),
25
+ topic: z
26
+ .string()
27
+ .min(3)
28
+ .max(1000)
29
+ .describe("What the business wants to solve. Concrete beats polite: 'the agent isn't offering sizes' over 'need help'"),
30
+ }, async (args) => text(await client.post("/advisory/book", args)));
31
+ server.tool("advisory_cancel", "Cancel a scheduled advisory session and give the month's quota back to the business. Only works before it starts; one that already began or was attended can't be cancelled. Deletes the appointment from the attending team's calendar too.", {
32
+ session_id: z.number().int().describe("Session id from advisory_panel_get"),
33
+ reason: z.string().max(500).optional().describe("Why it's being cancelled. Shows in the record"),
34
+ }, async ({ session_id, reason }) => text(await client.post(`/advisory/${session_id}/cancel`, { reason: reason ?? null })));
35
+ // ── Lado de quien atiende ────────────────────────────────────────────
36
+ server.tool("advisory_support_get", "Get how THIS business attends the advisory sessions of its clients: whether it's on, who is in the rotation with their relative share, the weekly schedule, and the booking limits. Only meaningful for MergeOn (ecommerce 1) and for implementers — any other business gets an empty config, which is the truth: it attends nobody. Read this before changing the rotation so you don't wipe somebody's share.", {}, async () => text(await client.get("/advisory/support")));
37
+ server.tool("advisory_support_set", `Set who attends the advisory sessions of this business's clients, and when. Sends the FULL config, so call advisory_support_get first — anyone left out of 'members' stops receiving new clients.
38
+
39
+ The rotation distributes CLIENTS, not sessions: the first time an eligible client opens its panel it gets an owner and keeps it, so its second session is attended by the same person who took the first. Weights are RELATIVE (2/1/1 means the first gets half the new clients, not that it gets two).
40
+
41
+ Who is in the rotation is an explicit list and not a rule by role, on purpose: "every advisor" would also pull in test users and anyone created tomorrow for a trial. An empty 'members' list means nobody can book, and the client's panel says so instead of silently assigning someone nobody chose.`, {
42
+ enabled: z.boolean().describe("false = clients still see their quota but can't book"),
43
+ members: z
44
+ .array(z.object({
45
+ worker_id: z.number().int().describe("Worker of THIS business. One from another business is rejected"),
46
+ weight: z
47
+ .number()
48
+ .int()
49
+ .min(1)
50
+ .max(100)
51
+ .optional()
52
+ .default(1)
53
+ .describe("Relative share of new clients. Not a cap"),
54
+ is_active: z
55
+ .boolean()
56
+ .optional()
57
+ .default(true)
58
+ .describe("false = stops receiving NEW clients but keeps the ones already assigned"),
59
+ }))
60
+ .describe("The rotation. Empty = nobody attends and no client can book"),
61
+ timezone: z.string().optional().default("America/Bogota"),
62
+ duration_minutes: z
63
+ .number()
64
+ .int()
65
+ .min(5)
66
+ .max(240)
67
+ .optional()
68
+ .default(30)
69
+ .describe("Default length. The client's plan overrides it when the plan defines one"),
70
+ weekly_hours: z
71
+ .record(z.array(z.array(z.string())))
72
+ .optional()
73
+ .describe('Schedule: {"1": [["09:00","12:00"],["14:00","18:00"]]} with 1=Monday … 7=Sunday. No schedule = no slots at all'),
74
+ date_overrides: z
75
+ .record(z.array(z.array(z.string())))
76
+ .optional()
77
+ .describe('Per-date exceptions: {"2027-12-25": []} closes that day'),
78
+ min_notice_minutes: z
79
+ .number()
80
+ .int()
81
+ .min(0)
82
+ .optional()
83
+ .default(240)
84
+ .describe("Minimum notice. 240 = can't book for less than 4 hours from now"),
85
+ max_days_ahead: z.number().int().min(1).max(365).optional().default(30),
86
+ slot_step_minutes: z
87
+ .number()
88
+ .int()
89
+ .min(5)
90
+ .max(240)
91
+ .optional()
92
+ .describe("How often a slot starts. Omit for back-to-back"),
93
+ max_per_day: z
94
+ .number()
95
+ .int()
96
+ .min(0)
97
+ .optional()
98
+ .default(0)
99
+ .describe("Cap per day PER PERSON in the rotation. 0 = no cap"),
100
+ }, async (args) => text(await client.put("/advisory/support", args)));
101
+ server.tool("advisory_agenda", "List the advisory sessions this business has to attend, its clients' ones. Includes the last few days backwards because the open question isn't only what's coming but what happened with Tuesday's: one that already passed still needs someone to mark it. Returns the client's ecommerce_id, who it was assigned to, the topic and the status.", {
102
+ days_back: z
103
+ .number()
104
+ .int()
105
+ .min(0)
106
+ .max(180)
107
+ .optional()
108
+ .default(7)
109
+ .describe("How many days backwards to include"),
110
+ }, async ({ days_back }) => text(await client.get(`/advisory/agenda?days_back=${days_back ?? 7}`)));
111
+ server.tool("advisory_agenda_set_status", "Mark what happened with an advisory session you attend. 'no_show' does NOT give the quota back — the client reserved half an hour of the team and didn't show up. 'completed' doesn't either. 'scheduled' exists to undo a wrong click. To give the quota back, the client has to cancel before it starts (advisory_cancel).", {
112
+ session_id: z.number().int().describe("Session id from advisory_agenda"),
113
+ status: z.enum(["completed", "no_show", "scheduled"]),
114
+ }, async ({ session_id, status }) => text(await client.post(`/advisory/agenda/${session_id}/status?status=${status}`, {})));
115
+ }
116
+ //# sourceMappingURL=advisory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advisory.js","sourceRoot":"","sources":["../../src/tools/advisory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,SAAS,IAAI,CAAC,IAAS;IACrB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACvF,CAAC;AAED,+EAA+E;AAC/E,iEAAiE;AACjE,EAAE;AACF,mEAAmE;AACnE,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,kEAAkE;AAClE,6EAA6E;AAC7E,gFAAgF;AAChF,wEAAwE;AACxE,gDAAgD;AAChD,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAqB;IAC5E,MAAM,CAAC,IAAI,CACT,oBAAoB,EACpB,mlBAAmlB,EACnlB,EAAE,EACF,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CACtD,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,gBAAgB,EAChB,wSAAwS,EACxS;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE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C,CAAC;aACV,QAAQ,CAAC,oCAAoC,CAAC;KAClD,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,8BAA8B,SAAS,IAAI,CAAC,EAAE,CAAC,CAAC,CAChG,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,4BAA4B,EAC5B,8TAA8T,EAC9T;QACE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;QACxE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;KACtD,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,CAC/B,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,oBAAoB,UAAU,kBAAkB,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CACxF,CAAC;AACJ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { AiTreeSchema } from "./ai-tree.js";
2
3
  function text(data) {
3
4
  return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
4
5
  }
@@ -45,10 +46,15 @@ export function registerAgentsRegistryTools(server, client) {
45
46
  server.tool("agents_get", "Get one agent by id, including its full prompt_text and the usages it serves.", {
46
47
  agent_id: z.number().describe("Agent id (see agents_list)"),
47
48
  }, async ({ agent_id }) => text(await client.get(`/ai-agents/${agent_id}`)));
48
- server.tool("agents_create", "Create a new AI agent for this business: a named prompt that can be plugged into one or more usages. Pass `usages` to put it to work immediately (a usage only has one agent — assigning it here takes it away from whoever had it). Use agents_usages_get first to see what is available and who serves what.", {
49
- name: z.string().min(1).max(120).describe("Agent name, e.g. 'Vendedor principal' or 'Agente de comentarios'"),
50
- prompt_text: z.string().describe("The agent's system prompt"),
49
+ server.tool("agents_create", "Create a new AI agent, of one of two kinds. `kind: 'generative'` (the default, what agents have always been) is a named prompt: the AI writes its own answers. `kind: 'faq'` is a bot ON RAILS: instead of a prompt it carries `tree`, and the AI's only job is to pick which of YOUR written replies applies — it cannot invent a price, change the tone or leak an internal note. Either kind can be plugged into one or more usages. Pass `usages` to put it to work immediately (a usage only has one agent — assigning it here takes it away from whoever had it). Use agents_usages_get first to see what is available and who serves what.", {
50
+ name: z.string().min(1).max(120).describe("Agent name, e.g. 'Vendedor principal' or 'Preguntas frecuentes'"),
51
+ prompt_text: z.string().describe("The agent's system prompt. Leave empty for a 'faq' agent — its brain is the tree"),
51
52
  description: z.string().max(500).optional().describe("Short note on what this agent is for"),
53
+ kind: z
54
+ .enum(["generative", "faq"])
55
+ .optional()
56
+ .describe("'faq' = on rails: the AI only picks a branch and never writes. Use it when the business says 'I don't want the AI making things up' or 'it should only answer what I write'"),
57
+ tree: AiTreeSchema.optional().describe("Required for kind 'faq'. Validate it with ai_tree_validate and check it with ai_tree_dry_run BEFORE creating the agent"),
52
58
  usages: z.array(UsageEnum).optional().describe("Usages this agent should serve right away"),
53
59
  is_active: z.boolean().optional().describe("Inactive agents keep their prompt but stop answering (default true)"),
54
60
  }, async (params) => text(await client.post("/ai-agents", params)));
@@ -57,6 +63,8 @@ export function registerAgentsRegistryTools(server, client) {
57
63
  name: z.string().min(1).max(120).optional().describe("New name"),
58
64
  prompt_text: z.string().optional().describe("New system prompt"),
59
65
  description: z.string().max(500).optional().describe("New description"),
66
+ kind: z.enum(["generative", "faq"]).optional().describe("Switch the agent between a written prompt and a rails tree"),
67
+ tree: AiTreeSchema.optional().describe("New tree for a 'faq' agent. REPLACES the whole tree — read the current one with agents_get first, or you will drop branches the business wrote"),
60
68
  usages: z.array(UsageEnum).optional().describe("Full replacement set of usages this agent serves"),
61
69
  is_active: z.boolean().optional().describe("Enable or disable the agent"),
62
70
  }, async ({ agent_id, ...body }) => text(await client.patch(`/ai-agents/${agent_id}`, body)));
@@ -1 +1 @@
1
- {"version":3,"file":"ag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Q,EAAE;KAC/B,EACD,KAAK,EAAE,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CACnC,IAAI,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,0BAA0B,aAAa,EAAE,EAAE,IAAI,CAAC,CAAC,CAC5E,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,oBAAoB,EACpB,wKAAwK,EACxK;QACE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;KAC3E,EACD,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAC1B,IAAI,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,0BAA0B,aAAa,EAAE,CAAC,CAAC,CACvE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,187 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { MergeOnClient } from "../client.js";
4
+ export declare const AiTreeSchema: z.ZodObject<{
5
+ root_node_id: z.ZodString;
6
+ nodes: z.ZodArray<z.ZodObject<{
7
+ id: z.ZodString;
8
+ ask: z.ZodOptional<z.ZodString>;
9
+ intent: z.ZodOptional<z.ZodString>;
10
+ slots: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
+ name: z.ZodString;
12
+ ask: z.ZodString;
13
+ type: z.ZodOptional<z.ZodEnum<["text", "number", "phone", "email", "date", "address"]>>;
14
+ required: z.ZodOptional<z.ZodBoolean>;
15
+ hint: z.ZodOptional<z.ZodString>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ name: string;
18
+ ask: string;
19
+ type?: "number" | "text" | "email" | "date" | "address" | "phone" | undefined;
20
+ required?: boolean | undefined;
21
+ hint?: string | undefined;
22
+ }, {
23
+ name: string;
24
+ ask: string;
25
+ type?: "number" | "text" | "email" | "date" | "address" | "phone" | undefined;
26
+ required?: boolean | undefined;
27
+ hint?: string | undefined;
28
+ }>, "many">>;
29
+ options: z.ZodArray<z.ZodObject<{
30
+ id: z.ZodString;
31
+ when: z.ZodString;
32
+ reply: z.ZodString;
33
+ examples: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
34
+ actions: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">>;
35
+ next_node_id: z.ZodOptional<z.ZodString>;
36
+ end: z.ZodOptional<z.ZodBoolean>;
37
+ end_message: z.ZodOptional<z.ZodString>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ id: string;
40
+ when: string;
41
+ reply: string;
42
+ actions?: Record<string, any>[] | undefined;
43
+ examples?: string[] | undefined;
44
+ next_node_id?: string | undefined;
45
+ end?: boolean | undefined;
46
+ end_message?: string | undefined;
47
+ }, {
48
+ id: string;
49
+ when: string;
50
+ reply: string;
51
+ actions?: Record<string, any>[] | undefined;
52
+ examples?: string[] | undefined;
53
+ next_node_id?: string | undefined;
54
+ end?: boolean | undefined;
55
+ end_message?: string | undefined;
56
+ }>, "many">;
57
+ on_no_match: z.ZodOptional<z.ZodEnum<["retry", "escalate", "free_ai", "end"]>>;
58
+ max_retries: z.ZodOptional<z.ZodNumber>;
59
+ invalid_message: z.ZodOptional<z.ZodString>;
60
+ min_confidence: z.ZodOptional<z.ZodNumber>;
61
+ }, "strip", z.ZodTypeAny, {
62
+ options: {
63
+ id: string;
64
+ when: string;
65
+ reply: string;
66
+ actions?: Record<string, any>[] | undefined;
67
+ examples?: string[] | undefined;
68
+ next_node_id?: string | undefined;
69
+ end?: boolean | undefined;
70
+ end_message?: string | undefined;
71
+ }[];
72
+ id: string;
73
+ ask?: string | undefined;
74
+ intent?: string | undefined;
75
+ slots?: {
76
+ name: string;
77
+ ask: string;
78
+ type?: "number" | "text" | "email" | "date" | "address" | "phone" | undefined;
79
+ required?: boolean | undefined;
80
+ hint?: string | undefined;
81
+ }[] | undefined;
82
+ on_no_match?: "end" | "retry" | "escalate" | "free_ai" | undefined;
83
+ max_retries?: number | undefined;
84
+ invalid_message?: string | undefined;
85
+ min_confidence?: number | undefined;
86
+ }, {
87
+ options: {
88
+ id: string;
89
+ when: string;
90
+ reply: string;
91
+ actions?: Record<string, any>[] | undefined;
92
+ examples?: string[] | undefined;
93
+ next_node_id?: string | undefined;
94
+ end?: boolean | undefined;
95
+ end_message?: string | undefined;
96
+ }[];
97
+ id: string;
98
+ ask?: string | undefined;
99
+ intent?: string | undefined;
100
+ slots?: {
101
+ name: string;
102
+ ask: string;
103
+ type?: "number" | "text" | "email" | "date" | "address" | "phone" | undefined;
104
+ required?: boolean | undefined;
105
+ hint?: string | undefined;
106
+ }[] | undefined;
107
+ on_no_match?: "end" | "retry" | "escalate" | "free_ai" | undefined;
108
+ max_retries?: number | undefined;
109
+ invalid_message?: string | undefined;
110
+ min_confidence?: number | undefined;
111
+ }>, "many">;
112
+ on_no_match: z.ZodOptional<z.ZodEnum<["retry", "escalate", "free_ai", "end"]>>;
113
+ min_confidence: z.ZodOptional<z.ZodNumber>;
114
+ history_turns: z.ZodOptional<z.ZodNumber>;
115
+ ttl_seconds: z.ZodOptional<z.ZodNumber>;
116
+ farewell_message: z.ZodOptional<z.ZodString>;
117
+ escalate_message: z.ZodOptional<z.ZodString>;
118
+ }, "strip", z.ZodTypeAny, {
119
+ root_node_id: string;
120
+ nodes: {
121
+ options: {
122
+ id: string;
123
+ when: string;
124
+ reply: string;
125
+ actions?: Record<string, any>[] | undefined;
126
+ examples?: string[] | undefined;
127
+ next_node_id?: string | undefined;
128
+ end?: boolean | undefined;
129
+ end_message?: string | undefined;
130
+ }[];
131
+ id: string;
132
+ ask?: string | undefined;
133
+ intent?: string | undefined;
134
+ slots?: {
135
+ name: string;
136
+ ask: string;
137
+ type?: "number" | "text" | "email" | "date" | "address" | "phone" | undefined;
138
+ required?: boolean | undefined;
139
+ hint?: string | undefined;
140
+ }[] | undefined;
141
+ on_no_match?: "end" | "retry" | "escalate" | "free_ai" | undefined;
142
+ max_retries?: number | undefined;
143
+ invalid_message?: string | undefined;
144
+ min_confidence?: number | undefined;
145
+ }[];
146
+ on_no_match?: "end" | "retry" | "escalate" | "free_ai" | undefined;
147
+ min_confidence?: number | undefined;
148
+ history_turns?: number | undefined;
149
+ ttl_seconds?: number | undefined;
150
+ farewell_message?: string | undefined;
151
+ escalate_message?: string | undefined;
152
+ }, {
153
+ root_node_id: string;
154
+ nodes: {
155
+ options: {
156
+ id: string;
157
+ when: string;
158
+ reply: string;
159
+ actions?: Record<string, any>[] | undefined;
160
+ examples?: string[] | undefined;
161
+ next_node_id?: string | undefined;
162
+ end?: boolean | undefined;
163
+ end_message?: string | undefined;
164
+ }[];
165
+ id: string;
166
+ ask?: string | undefined;
167
+ intent?: string | undefined;
168
+ slots?: {
169
+ name: string;
170
+ ask: string;
171
+ type?: "number" | "text" | "email" | "date" | "address" | "phone" | undefined;
172
+ required?: boolean | undefined;
173
+ hint?: string | undefined;
174
+ }[] | undefined;
175
+ on_no_match?: "end" | "retry" | "escalate" | "free_ai" | undefined;
176
+ max_retries?: number | undefined;
177
+ invalid_message?: string | undefined;
178
+ min_confidence?: number | undefined;
179
+ }[];
180
+ on_no_match?: "end" | "retry" | "escalate" | "free_ai" | undefined;
181
+ min_confidence?: number | undefined;
182
+ history_turns?: number | undefined;
183
+ ttl_seconds?: number | undefined;
184
+ farewell_message?: string | undefined;
185
+ escalate_message?: string | undefined;
186
+ }>;
187
+ export declare function registerAiTreeTools(server: McpServer, client: MergeOnClient): void;
@@ -0,0 +1,112 @@
1
+ import { z } from "zod";
2
+ function text(data) {
3
+ return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
4
+ }
5
+ /** Los parámetros que de verdad llegaron, como strings: es lo que pide client.get. */
6
+ function query(params) {
7
+ const salida = {};
8
+ for (const [clave, valor] of Object.entries(params)) {
9
+ if (valor !== undefined && valor !== null)
10
+ salida[clave] = String(valor);
11
+ }
12
+ return salida;
13
+ }
14
+ // El árbol de un bot sobre rieles. Es el mismo formato en los dos sitios donde
15
+ // puede vivir: el `tree` de un agente con `kind: faq`, y el
16
+ // `actions[0].ai_tree` de un flujo con `trigger_type: ai_tree`.
17
+ //
18
+ // La idea entera del formato cabe en dos campos de cada rama: `when` dice
19
+ // cuándo aplica —y es lo ÚNICO que el modelo lee para decidir— y `reply` es el
20
+ // texto exacto que sale al cliente, que el modelo no toca. Si `when` está mal
21
+ // escrito, la rama no se elige nunca; si `reply` está mal escrito, el cliente
22
+ // lee eso tal cual.
23
+ const SlotSchema = z.object({
24
+ name: z.string().describe("Field name, e.g. 'talla', 'ciudad'. Also the {{placeholder}} you can use in any reply"),
25
+ ask: z.string().describe("What is sent to the customer to ask for it, e.g. '¿Qué talla usas?'"),
26
+ type: z.enum(["text", "number", "phone", "email", "date", "address"]).optional(),
27
+ required: z.boolean().optional().describe("Required slots block the branch until filled (default true)"),
28
+ hint: z.string().optional().describe("Hint for the extractor, e.g. 'S, M, L o XL'"),
29
+ });
30
+ const OptionSchema = z.object({
31
+ id: z.string().describe("Branch id, e.g. 'precio'. The model returns this and nothing else"),
32
+ when: z
33
+ .string()
34
+ .describe("When this branch applies, in the business's own language — THE most important field. It is the only thing the model reads to choose. Write it like you would explain it to a new hire: 'El cliente pregunta cuánto cuesta algo o pide precios'"),
35
+ reply: z
36
+ .string()
37
+ .describe("The EXACT text sent to the customer, written by the business. The model never rewrites it. Supports {{placeholders}} from the CRM, the order and the node's slots; if one cannot be filled the message is NOT sent and the chat goes to a human"),
38
+ examples: z
39
+ .array(z.string())
40
+ .optional()
41
+ .describe("Real customer messages that land here. Optional, but the single best way to sharpen the choice — paste them from actual chats"),
42
+ actions: z
43
+ .array(z.record(z.any()))
44
+ .optional()
45
+ .describe("Flow actions to fire on this branch: tag, move funnel stage, create order, notify an advisor, run another flow. Same catalog as flows (see flows_get_catalog)"),
46
+ next_node_id: z.string().optional().describe("Node to continue at. Omit (or set `end`) to finish here"),
47
+ end: z.boolean().optional().describe("True = the conversation ends on this branch"),
48
+ end_message: z.string().optional().describe("Extra closing line when the branch ends"),
49
+ });
50
+ const NodeSchema = z.object({
51
+ id: z.string().describe("Node id, e.g. 'calificar'"),
52
+ ask: z.string().optional().describe("Sent on ARRIVING at this node. Leave empty for a node that only classifies"),
53
+ intent: z.string().optional().describe("What is being decided here, in Spanish. Helps the model not confuse similar nodes"),
54
+ slots: z.array(SlotSchema).optional().describe("Data to collect before any branch can advance"),
55
+ options: z.array(OptionSchema).describe("The branches. Keep it under 8 per node: past that the model starts confusing the similar ones — split the node instead"),
56
+ on_no_match: z
57
+ .enum(["retry", "escalate", "free_ai", "end"])
58
+ .optional()
59
+ .describe("Overrides the tree's fallback just for this node"),
60
+ max_retries: z.number().int().optional(),
61
+ invalid_message: z.string().optional().describe("What it says when re-asking (only with 'retry')"),
62
+ min_confidence: z.number().optional().describe("Overrides the tree's threshold just for this node"),
63
+ });
64
+ export const AiTreeSchema = z.object({
65
+ root_node_id: z.string().describe("Node the conversation starts at"),
66
+ nodes: z.array(NodeSchema),
67
+ on_no_match: z
68
+ .enum(["retry", "escalate", "free_ai", "end"])
69
+ .optional()
70
+ .describe("What happens when no branch applies. 'free_ai' hands the turn to the normal AI with its prompt and tools — START HERE, it is the hybrid mode that lets the bot ship without leaving customers unanswered, and ai_tree_gaps then tells you exactly which replies are missing. 'escalate' pauses the AI and calls a human. 'retry' re-asks. 'end' says goodbye"),
71
+ min_confidence: z.number().optional().describe("Below this the branch is not applied and the fallback runs (default 0.6)"),
72
+ history_turns: z.number().int().optional().describe("How many past turns the classifier sees (default 6)"),
73
+ ttl_seconds: z.number().int().optional().describe("How long the conversation stays inside the tree (default 900)"),
74
+ farewell_message: z.string().optional(),
75
+ escalate_message: z.string().optional().describe("What the customer is told when handed to a person"),
76
+ });
77
+ export function registerAiTreeTools(server, client) {
78
+ server.tool("ai_tree_validate", "Check a rails tree before saving it, and get the problems back in Spanish. Catches what silently breaks a bot in production: a branch pointing at a node that does not exist, a node nobody can reach, a branch with no `when` (unreachable — the model has nothing to choose it by), a branch that answers nothing, and a node with too many branches. Empty `problemas` means it will work. The POST that saves the agent runs this same check, so this is for iterating before you commit.", {
79
+ tree: AiTreeSchema.describe("The tree to check"),
80
+ }, async (params) => text(await client.post("/ai-tree/validate", params)));
81
+ server.tool("ai_tree_dry_run", "Run one customer message against one node of the tree WITHOUT sending anything. Returns the branch the model would pick, its confidence against the threshold, the data it extracted, and the exact text the customer would receive. Nothing is sent, no CRM is touched and no state is kept, so run it as many times as you want — this is how you check a tree with the weird messages before turning it on, and how you re-measure after changing a `when`.", {
82
+ message: z.string().describe("What the customer would write, in their own words and typos included"),
83
+ tree: AiTreeSchema.optional().describe("Tree to test. Omit it and pass flow_id to test one already saved"),
84
+ flow_id: z.number().optional().describe("Test the tree of this saved ai_tree flow instead"),
85
+ agent_id: z.number().optional().describe("Test the tree of this saved 'faq' agent instead (see agents_list) — use this to check a bot that is already answering a channel"),
86
+ node_id: z.string().optional().describe("Node to test against (default: the root)"),
87
+ slots: z.record(z.any()).optional().describe("Data already collected earlier in the conversation"),
88
+ history: z
89
+ .array(z.object({ role: z.string(), content: z.string() }))
90
+ .optional()
91
+ .describe("Previous turns, oldest first, as {role: 'user'|'assistant', content}"),
92
+ }, async (params) => text(await client.post("/ai-tree/dry-run", params)));
93
+ server.tool("ai_tree_gaps", "The real customer messages no branch could handle, grouped by node. This is half the point of a rails bot: start hybrid ('free_ai'), let it run, and in two weeks this list IS the repertoire that is missing — no guessing. Each row is someone who wrote something the business had not foreseen. Read this before writing new branches.", {
94
+ flow_id: z.number().optional().describe("Only the gaps of this ai_tree flow"),
95
+ limit: z.number().int().optional().describe("Max rows (default 200)"),
96
+ }, async (params) => text(await client.get("/ai-tree/gaps", query(params))));
97
+ server.tool("ai_tree_stats", "Per node: how many decisions, how many had no branch, and the average confidence — worst node first. Tells you which node to fix before any other. A node over ~25% with no branch is either missing branches or its `when` descriptions overlap.", {
98
+ flow_id: z.number().optional().describe("Only this ai_tree flow"),
99
+ }, async (params) => text(await client.get("/ai-tree/stats", query(params))));
100
+ server.tool("ai_tree_decisions", "Which branch the model picked on each message, newest first, with the confidence and what it extracted. This is what makes a rails bot fixable at all: 'the AI answered wrong' becomes 'on node calificar it picked precio when the customer was complaining', which you can correct and then measure.", {
101
+ only_unmatched: z.boolean().optional().describe("Only the messages nobody could classify"),
102
+ flow_id: z.number().optional(),
103
+ node_id: z.string().optional().describe("Only this node"),
104
+ session_id: z.string().optional().describe("Only this conversation"),
105
+ limit: z.number().int().optional().describe("Max rows (default 100)"),
106
+ }, async (params) => text(await client.get("/ai-tree/decisions", query(params))));
107
+ server.tool("ai_tree_correct", "Mark which branch a message SHOULD have landed on. Turns the log into a case bank: after changing the tree, re-run ai_tree_dry_run over the corrected messages to check the fix works without breaking what already worked. Correcting without re-running proves nothing.", {
108
+ decision_id: z.number().describe("Decision id (see ai_tree_decisions or ai_tree_gaps)"),
109
+ option_id: z.string().describe("The branch id it should have picked"),
110
+ }, async ({ decision_id, option_id }) => text(await client.post(`/ai-tree/decisions/${decision_id}/correct`, { option_id })));
111
+ }
112
+ //# sourceMappingURL=ai-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-tree.js","sourceRoot":"","sources":["../../src/tools/ai-tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,SAAS,IAAI,CAAC,IAAS;IACrB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACvF,CAAC;AAED,sFAAsF;AACtF,SAAS,KAAK,CAAC,MAA+B;IAC5C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACpD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,MAAM,C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A2Q,EAC3Q;QACE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;QACvF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;KACtE,EACD,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,EAAE,CACnC,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,sBAAsB,WAAW,UAAU,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CACtF,CAAC;AACJ,CAAC"}
@@ -6,7 +6,8 @@ const ENTIDADES = "cita | pedido | contacto | producto | flujo | plantilla | nur
6
6
  "ciclo-del-pedido | conversacion | campana | agente | prompt | contexto-del-negocio | " +
7
7
  "herramienta | experimento | equipo | configuracion | negocio | integracion | credenciales | " +
8
8
  "llave-api | webhook | suscripcion | plan | formulario | codigo-de-formulario | medio | " +
9
- "agenda-publica | linea | zona | mesa | insumo | reserva | resena | asignacion-de-agente";
9
+ "agenda-publica | linea | zona | mesa | insumo | reserva | resena | asignacion-de-agente | " +
10
+ "asesoria";
10
11
  export function registerAuditTools(server, client) {
11
12
  server.tool("audit_log_list", "Who changed what in this business, and when. Reads the activity log that Postgres triggers write on every write — from the dashboard, this MCP, the public API, the crons, the AI or raw SQL — so it answers questions no other tool can: who deleted that appointment, who changed the price, who moved the order, who turned the AI off, who changed a tab's permissions. " +
12
13
  "Each row says the entity, the action, the author (worker name when it was a person, or 'ia'/'cron'/'publico'/'mcp'/'sql' when it wasn't), the timestamp, and a field-by-field diff of what changed (before → after). " +
@@ -1 +1 @@
1
- {"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/tools/audit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,SAAS,IAAI,CAAC,IAAS;IACrB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE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MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;QAC1B,MAAM,EAAE,GAA2B,EAAE,CAAC;QACtC,IAAI,MAAM;YAAE,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/B,IAAI,KAAK,KAAK,SAAS;YAAE,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -737,8 +737,16 @@ export function registerEcommerceTools(server, client) {
737
737
  .optional()
738
738
  .describe("Services this space supports. Empty = mixed use, fits any service."),
739
739
  is_active: z.boolean().optional().default(true).describe("false = the space is never offered nor booked."),
740
+ // Sin este campo el MCP lo descartaba: como la lista se REEMPLAZA
741
+ // entera, cualquier llamada borraba los colores que el negocio ya
742
+ // había elegido en el dashboard, y por MCP no había cómo ponerlos.
743
+ color: z
744
+ .string()
745
+ .nullable()
746
+ .optional()
747
+ .describe("Color of this space/advisor in the calendar, by name: azul, verde, rosa, naranja, morado, turquesa, amarillo, gris, lima, celeste, marron or fucsia. Null/omitted = an automatic color by position. ALWAYS send back the color each space already has (read it first): omitting it here erases it, because the list is replaced whole."),
740
748
  }))
741
- .describe("Full list of bookable spaces. Replaces the existing one."),
749
+ .describe("Full list of bookable spaces. Replaces the existing one — read the current list first and keep every field (including color) you are not changing."),
742
750
  }, async ({ ecommerce_id, resources }) => {
743
751
  const id = ecommerce_id || client.getResolvedEcommerceId();
744
752
  // `resources` es clave de primer nivel de extra_config y el config mergea