@velaro/mcp-server 2.0.98 → 2.0.99

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velaro/mcp-server",
3
- "version": "2.0.98",
3
+ "version": "2.0.99",
4
4
  "description": "Velaro MCP server — connect Claude and other AI agents directly to your Velaro account: KB, workflows, bots, conversations, contacts, routing, and more.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,79 @@
1
+ // MCP parity for `velaro crm-approval` and `velaro crm-score` (cli/lib/commands/crm-approvals-scoring.js).
2
+ // Backend: velaro-messaging CrmApprovalsController and CrmLeadScoringController
3
+ // (docs/architecture/crm-studio-program.md, features 15 and 16). Site from the credential, never an argument.
4
+
5
+ const data = (r) => (r && typeof r === 'object' && 'data' in r ? r.data : r);
6
+ const q = (o) => {
7
+ const p = Object.entries(o).filter(([, v]) => v !== undefined && v !== null && v !== '').map(([k, v]) => `${k}=${encodeURIComponent(v)}`);
8
+ return p.length ? `?${p.join('&')}` : '';
9
+ };
10
+ const id = (v) => encodeURIComponent(v);
11
+ const num = { type: 'number' };
12
+
13
+ export const tools = [
14
+ { name: 'crm_approval_rule_list', description: 'List the CRM approval rules: which deal stage moves, amount edits over a threshold and line item discounts over a percent are held for a Manager or Administrator. Manager or Administrator only. Part of the CRM Studio package (see your plan).', inputSchema: { type: 'object', properties: {} } },
15
+ {
16
+ name: 'crm_approval_rule_save',
17
+ description: 'Create an approval rule, or update one with id. kind is stage (needs stageId), amount (needs threshold) or discount (needs a percent threshold). includeManagers also holds changes made by Managers and Administrators. Manager or Administrator only.',
18
+ inputSchema: {
19
+ type: 'object',
20
+ properties: { id: num, kind: { type: 'string', enum: ['stage', 'amount', 'discount'] }, name: { type: 'string' }, stageId: { type: 'string' }, pipelineId: num, threshold: num, isActive: { type: 'boolean' }, includeManagers: { type: 'boolean' } },
21
+ required: ['kind', 'name'],
22
+ },
23
+ },
24
+ { name: 'crm_approval_rule_delete', description: 'Delete an approval rule. Requests already waiting stay in the queue.', inputSchema: { type: 'object', properties: { id: num }, required: ['id'] } },
25
+ {
26
+ name: 'crm_approval_list',
27
+ description: 'List CRM approval requests (held deal changes), pending by default, a page at a time. Each shows the deal, what is waiting, who asked and who decided.',
28
+ inputSchema: { type: 'object', properties: { status: { type: 'string', enum: ['pending', 'approved', 'rejected', 'all'] }, page: num, pageSize: num } },
29
+ },
30
+ { name: 'crm_approval_approve', description: 'Approve a held deal change. It is applied and attributed to the approver in the field history. Manager or Administrator only; confirm with the user first.', inputSchema: { type: 'object', properties: { id: num, comment: { type: 'string' } }, required: ['id'] } },
31
+ { name: 'crm_approval_reject', description: 'Reject a held deal change; the deal is not changed. A comment is required. Manager or Administrator only.', inputSchema: { type: 'object', properties: { id: num, comment: { type: 'string' } }, required: ['id', 'comment'] } },
32
+ { name: 'crm_score_rule_list', description: 'List the lead scoring rules (field conditions, recent activity, idle decay) and their points. Part of the CRM Studio package (see your plan).', inputSchema: { type: 'object', properties: {} } },
33
+ {
34
+ name: 'crm_score_rule_save',
35
+ description: 'Create a lead scoring rule, or update one with id. kind is field (field, operator, value), activity (activityType, windowDays) or decay (decayDays). The score is clamped between 0 and 100. Manager or Administrator only.',
36
+ inputSchema: {
37
+ type: 'object',
38
+ properties: {
39
+ id: num, kind: { type: 'string', enum: ['field', 'activity', 'decay'] }, name: { type: 'string' }, field: { type: 'string' },
40
+ operator: { type: 'string', enum: ['equals', 'notEquals', 'contains', 'startsWith', 'isSet', 'isEmpty', 'greaterThan', 'lessThan'] },
41
+ value: { type: 'string' }, activityType: { type: 'string' }, windowDays: num, decayDays: num, points: num, maxPoints: num, isActive: { type: 'boolean' },
42
+ },
43
+ required: ['kind'],
44
+ },
45
+ },
46
+ { name: 'crm_score_rule_delete', description: 'Delete a lead scoring rule. Scores change the next time they are recomputed.', inputSchema: { type: 'object', properties: { id: num }, required: ['id'] } },
47
+ { name: 'crm_score_preview', description: 'Show a contact\'s lead score and which rules earned each point, without saving anything.', inputSchema: { type: 'object', properties: { contactId: num }, required: ['contactId'] } },
48
+ {
49
+ name: 'crm_score_recompute',
50
+ description: 'Recompute and store lead scores: pass contactId for one contact, or walk all contacts in batches with afterId and batchSize (the reply gives the next cursor). Manager or Administrator only.',
51
+ inputSchema: { type: 'object', properties: { contactId: num, afterId: num, batchSize: num } },
52
+ },
53
+ ];
54
+
55
+ const ruleBody = (a, keys) => {
56
+ const b = {};
57
+ for (const k of keys) if (a[k] !== undefined) b[k] = a[k];
58
+ return b;
59
+ };
60
+
61
+ export const handlers = {
62
+ crm_approval_rule_list: async (_a, ctx) => data(await ctx.messagingGet('/CrmApprovals/rules')),
63
+ crm_approval_rule_save: async (a, ctx) => {
64
+ const body = ruleBody(a, ['kind', 'name', 'stageId', 'pipelineId', 'threshold', 'isActive', 'includeManagers']);
65
+ return data(a.id ? await ctx.messagingPut(`/CrmApprovals/rules/${id(a.id)}`, body) : await ctx.messagingPost('/CrmApprovals/rules', body));
66
+ },
67
+ crm_approval_rule_delete: async (a, ctx) => data(await ctx.messagingDel(`/CrmApprovals/rules/${id(a.id)}`)),
68
+ crm_approval_list: async (a, ctx) => data(await ctx.messagingGet(`/CrmApprovals${q({ status: a.status, page: a.page, pageSize: a.pageSize })}`)),
69
+ crm_approval_approve: async (a, ctx) => data(await ctx.messagingPost(`/CrmApprovals/${id(a.id)}/approve`, { comment: a.comment })),
70
+ crm_approval_reject: async (a, ctx) => data(await ctx.messagingPost(`/CrmApprovals/${id(a.id)}/reject`, { comment: a.comment })),
71
+ crm_score_rule_list: async (_a, ctx) => data(await ctx.messagingGet('/CrmLeadScoring/rules')),
72
+ crm_score_rule_save: async (a, ctx) => {
73
+ const body = ruleBody(a, ['kind', 'name', 'field', 'operator', 'value', 'activityType', 'windowDays', 'decayDays', 'points', 'maxPoints', 'isActive']);
74
+ return data(a.id ? await ctx.messagingPut(`/CrmLeadScoring/rules/${id(a.id)}`, body) : await ctx.messagingPost('/CrmLeadScoring/rules', body));
75
+ },
76
+ crm_score_rule_delete: async (a, ctx) => data(await ctx.messagingDel(`/CrmLeadScoring/rules/${id(a.id)}`)),
77
+ crm_score_preview: async (a, ctx) => data(await ctx.messagingGet(`/CrmLeadScoring/preview${q({ contactId: a.contactId })}`)),
78
+ crm_score_recompute: async (a, ctx) => data(await ctx.messagingPost('/CrmLeadScoring/recompute', ruleBody(a, ['contactId', 'afterId', 'batchSize']))),
79
+ };