@velaro/mcp-server 2.0.97 → 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.97",
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
+ };
@@ -0,0 +1,110 @@
1
+ // MCP parity for `velaro crm-object` and `velaro crm-rel` (cli/lib/commands/crm-objects-relationships.js).
2
+ // Backend: velaro-messaging CrmObjectsController and CrmRelationshipsController
3
+ // (docs/architecture/crm-studio-program.md, features 18 and 19). Site from the credential, never an argument.
4
+
5
+ const REL_ENTITIES = ['contact', 'company', 'deal', 'object'];
6
+
7
+ const data = (r) => (r && typeof r === 'object' && 'data' in r ? r.data : r);
8
+ const q = (o) => {
9
+ const p = Object.entries(o).filter(([, v]) => v !== undefined && v !== null && v !== '').map(([k, v]) => `${k}=${encodeURIComponent(v)}`);
10
+ return p.length ? `?${p.join('&')}` : '';
11
+ };
12
+ const id = (v) => encodeURIComponent(v);
13
+ const num = { type: 'number' };
14
+
15
+ export const tools = [
16
+ { name: 'crm_object_type_list', description: 'List the custom CRM object types of this account (your own record types such as Projects or Assets).', inputSchema: { type: 'object', properties: {} } },
17
+ {
18
+ name: 'crm_object_type_save',
19
+ description: 'Create a custom CRM object type, or update one with id. Administrator only. Part of the CRM Studio package (see your plan). Types are archived, never hard-deleted.',
20
+ inputSchema: { type: 'object', properties: { id: num, name: { type: 'string' }, pluralName: { type: 'string' }, description: { type: 'string' } }, required: ['name'] },
21
+ },
22
+ { name: 'crm_object_type_archive', description: 'Archive a custom object type; its records are kept. Administrator only.', inputSchema: { type: 'object', properties: { id: num }, required: ['id'] } },
23
+ { name: 'crm_object_type_restore', description: 'Restore an archived custom object type. Administrator only.', inputSchema: { type: 'object', properties: { id: num }, required: ['id'] } },
24
+ { name: 'crm_object_field_list', description: 'List the fields of a custom object type, with their types and role security.', inputSchema: { type: 'object', properties: { typeId: num }, required: ['typeId'] } },
25
+ {
26
+ name: 'crm_object_field_save',
27
+ description: 'Add a field to a custom object type, or update one with fieldId. Administrator only. The definition has label, fieldType, optionsJson, isRequired, helpText, defaultValue and optional read and write roles. Calculated fields are not offered on custom objects.',
28
+ inputSchema: { type: 'object', properties: { typeId: num, fieldId: num, definition: { type: 'object', description: 'Field definition: label, fieldType, optionsJson, isRequired, helpText, defaultValue, readRolesJson, writeRolesJson.' } }, required: ['typeId', 'definition'] },
29
+ },
30
+ { name: 'crm_object_field_archive', description: 'Archive a custom object field. Administrator only.', inputSchema: { type: 'object', properties: { typeId: num, fieldId: num }, required: ['typeId', 'fieldId'] } },
31
+ {
32
+ name: 'crm_object_record_list',
33
+ description: 'List the records of a custom object type, a page at a time. Search matches the record name only.',
34
+ inputSchema: { type: 'object', properties: { typeId: num, search: { type: 'string' }, includeArchived: { type: 'boolean' }, page: num, pageSize: num }, required: ['typeId'] },
35
+ },
36
+ { name: 'crm_object_record_get', description: 'Get one custom object record with its field values (fields the caller cannot read are left out).', inputSchema: { type: 'object', properties: { typeId: num, id: num }, required: ['typeId', 'id'] } },
37
+ {
38
+ name: 'crm_object_record_save',
39
+ description: 'Create a custom object record, or update one with id. Values go through the same format rules and field security as other CRM custom fields.',
40
+ inputSchema: {
41
+ type: 'object',
42
+ properties: {
43
+ typeId: num, id: num, name: { type: 'string' },
44
+ values: { type: 'array', items: { type: 'object', properties: { customFieldId: num, value: {} }, required: ['customFieldId'] } },
45
+ },
46
+ required: ['typeId', 'name'],
47
+ },
48
+ },
49
+ { name: 'crm_object_record_archive', description: 'Archive a custom object record (restorable).', inputSchema: { type: 'object', properties: { typeId: num, id: num }, required: ['typeId', 'id'] } },
50
+ { name: 'crm_object_record_restore', description: 'Restore an archived custom object record.', inputSchema: { type: 'object', properties: { typeId: num, id: num }, required: ['typeId', 'id'] } },
51
+ { name: 'crm_rel_type_list', description: 'List the relationship types of this account, such as "reports to" and "manages". Part of the CRM Studio package (see your plan).', inputSchema: { type: 'object', properties: {} } },
52
+ {
53
+ name: 'crm_rel_type_save',
54
+ description: 'Create a relationship type, or update one with id. A blank inverseName makes the type symmetric (for example "partner of"). Administrator only.',
55
+ inputSchema: { type: 'object', properties: { id: num, name: { type: 'string' }, inverseName: { type: 'string' } }, required: ['name'] },
56
+ },
57
+ { name: 'crm_rel_type_archive', description: 'Archive a relationship type. Administrator only.', inputSchema: { type: 'object', properties: { id: num }, required: ['id'] } },
58
+ { name: 'crm_rel_type_restore', description: 'Restore an archived relationship type. Administrator only.', inputSchema: { type: 'object', properties: { id: num }, required: ['id'] } },
59
+ {
60
+ name: 'crm_rel_link',
61
+ description: 'Link two CRM records (contact, company, deal or custom object record) with a relationship type. Linking the same pair twice keeps one link.',
62
+ inputSchema: {
63
+ type: 'object',
64
+ properties: { typeId: num, fromEntity: { type: 'string', enum: REL_ENTITIES }, fromId: num, toEntity: { type: 'string', enum: REL_ENTITIES }, toId: num },
65
+ required: ['typeId', 'fromEntity', 'fromId', 'toEntity', 'toId'],
66
+ },
67
+ },
68
+ { name: 'crm_rel_unlink', description: 'Remove a relationship link by its id.', inputSchema: { type: 'object', properties: { id: num }, required: ['id'] } },
69
+ {
70
+ name: 'crm_rel_list',
71
+ description: 'List every relationship of one CRM record in both directions, each side with its own label.',
72
+ inputSchema: { type: 'object', properties: { entity: { type: 'string', enum: REL_ENTITIES }, id: num }, required: ['entity', 'id'] },
73
+ },
74
+ ];
75
+
76
+ export const handlers = {
77
+ crm_object_type_list: async (_a, ctx) => data(await ctx.messagingGet('/CrmObjects')),
78
+ crm_object_type_save: async (a, ctx) => {
79
+ const body = { name: a.name, pluralName: a.pluralName, description: a.description };
80
+ return data(a.id ? await ctx.messagingPut(`/CrmObjects/${id(a.id)}`, body) : await ctx.messagingPost('/CrmObjects', body));
81
+ },
82
+ crm_object_type_archive: async (a, ctx) => data(await ctx.messagingDel(`/CrmObjects/${id(a.id)}`)),
83
+ crm_object_type_restore: async (a, ctx) => data(await ctx.messagingPost(`/CrmObjects/${id(a.id)}/restore`, {})),
84
+ crm_object_field_list: async (a, ctx) => data(await ctx.messagingGet(`/CrmObjects/${id(a.typeId)}/fields`)),
85
+ crm_object_field_save: async (a, ctx) => data(a.fieldId
86
+ ? await ctx.messagingPut(`/CrmObjects/${id(a.typeId)}/fields/${id(a.fieldId)}`, a.definition)
87
+ : await ctx.messagingPost(`/CrmObjects/${id(a.typeId)}/fields`, a.definition)),
88
+ crm_object_field_archive: async (a, ctx) => data(await ctx.messagingDel(`/CrmObjects/${id(a.typeId)}/fields/${id(a.fieldId)}`)),
89
+ crm_object_record_list: async (a, ctx) => data(await ctx.messagingGet(`/CrmObjects/${id(a.typeId)}/records${q({ search: a.search, includeArchived: a.includeArchived ? 'true' : undefined, page: a.page, pageSize: a.pageSize })}`)),
90
+ crm_object_record_get: async (a, ctx) => data(await ctx.messagingGet(`/CrmObjects/${id(a.typeId)}/records/${id(a.id)}`)),
91
+ crm_object_record_save: async (a, ctx) => {
92
+ const body = { name: a.name };
93
+ if (a.values !== undefined) body.values = a.values;
94
+ return data(a.id
95
+ ? await ctx.messagingPut(`/CrmObjects/${id(a.typeId)}/records/${id(a.id)}`, body)
96
+ : await ctx.messagingPost(`/CrmObjects/${id(a.typeId)}/records`, body));
97
+ },
98
+ crm_object_record_archive: async (a, ctx) => data(await ctx.messagingDel(`/CrmObjects/${id(a.typeId)}/records/${id(a.id)}`)),
99
+ crm_object_record_restore: async (a, ctx) => data(await ctx.messagingPost(`/CrmObjects/${id(a.typeId)}/records/${id(a.id)}/restore`, {})),
100
+ crm_rel_type_list: async (_a, ctx) => data(await ctx.messagingGet('/CrmRelationships/types')),
101
+ crm_rel_type_save: async (a, ctx) => {
102
+ const body = { name: a.name, inverseName: a.inverseName };
103
+ return data(a.id ? await ctx.messagingPut(`/CrmRelationships/types/${id(a.id)}`, body) : await ctx.messagingPost('/CrmRelationships/types', body));
104
+ },
105
+ crm_rel_type_archive: async (a, ctx) => data(await ctx.messagingDel(`/CrmRelationships/types/${id(a.id)}`)),
106
+ crm_rel_type_restore: async (a, ctx) => data(await ctx.messagingPost(`/CrmRelationships/types/${id(a.id)}/restore`, {})),
107
+ crm_rel_link: async (a, ctx) => data(await ctx.messagingPost('/CrmRelationships', { typeId: a.typeId, fromEntity: a.fromEntity, fromId: a.fromId, toEntity: a.toEntity, toId: a.toId })),
108
+ crm_rel_unlink: async (a, ctx) => data(await ctx.messagingDel(`/CrmRelationships/${id(a.id)}`)),
109
+ crm_rel_list: async (a, ctx) => data(await ctx.messagingGet(`/CrmRelationships/record/${id(a.entity)}/${id(a.id)}`)),
110
+ };