@velaro/mcp-server 2.0.92 → 2.0.93
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 +1 -1
- package/parity/crm-import-dedupe-audit.customer.js +113 -0
- package/server.js +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velaro/mcp-server",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.93",
|
|
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,113 @@
|
|
|
1
|
+
// MCP parity for `velaro crm-import`, `crm-tag`, `crm-dedupe` and `crm-audit` (cli/lib/commands/crm-import-dedupe-audit.js).
|
|
2
|
+
// Backend: velaro-messaging CrmImportController, CrmTagsController, CrmDealDuplicatesController and CrmAuditController
|
|
3
|
+
// (docs/architecture/crm-studio-program.md, features 11 to 14). Site from the credential, never an argument.
|
|
4
|
+
|
|
5
|
+
const ENTITIES = ['contact', 'company', 'deal'];
|
|
6
|
+
const TAG_ENTITIES = ['company', 'deal'];
|
|
7
|
+
|
|
8
|
+
const data = (r) => (r && typeof r === 'object' && 'data' in r ? r.data : r);
|
|
9
|
+
const q = (o) => {
|
|
10
|
+
const p = Object.entries(o).filter(([, v]) => v !== undefined && v !== null && v !== '').map(([k, v]) => `${k}=${encodeURIComponent(v)}`);
|
|
11
|
+
return p.length ? `?${p.join('&')}` : '';
|
|
12
|
+
};
|
|
13
|
+
const id = (v) => encodeURIComponent(v);
|
|
14
|
+
|
|
15
|
+
const importProps = {
|
|
16
|
+
entity: { type: 'string', enum: ENTITIES },
|
|
17
|
+
csv: { type: 'string', description: 'The CSV text; the first line is the header. Comma, semicolon or tab separated.' },
|
|
18
|
+
mapping: { type: 'object', description: 'Column header to field (built-in name or cf:<customFieldId>). Unlisted columns are matched by name, so an exported file needs no mapping.' },
|
|
19
|
+
duplicates: { type: 'string', enum: ['skip', 'update'], description: 'Existing contact (same email) or company (same name): skip it (default) or update only the filled-in cells.' },
|
|
20
|
+
pipelineId: { type: 'number', description: 'Deals: the pipeline for rows without a pipeline column.' },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const tools = [
|
|
24
|
+
{
|
|
25
|
+
name: 'crm_import_meta',
|
|
26
|
+
description: 'List what a CRM CSV import supports: the record types, the built-in fields and custom fields a column can map to, and the file limits.',
|
|
27
|
+
inputSchema: { type: 'object', properties: {} },
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'crm_import_preview',
|
|
31
|
+
description: 'Dry run of a CRM CSV import for contacts, companies or deals. Nothing is written. Returns the mapped and ignored columns and, for every row, whether it would create, update, skip or fail and why. Always preview before committing. Part of the CRM Studio package (see your plan).',
|
|
32
|
+
inputSchema: { type: 'object', properties: importProps, required: ['entity', 'csv'] },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'crm_import_commit',
|
|
36
|
+
description: 'Import a CSV of contacts, companies or deals into the CRM. Manager or Administrator only. Rows go through the same checks as a single create (field rules, field security, plan limits, stage rules). A tags column adds tags by name. Run crm_import_preview first. Part of the CRM Studio package (see your plan).',
|
|
37
|
+
inputSchema: { type: 'object', properties: importProps, required: ['entity', 'csv'] },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'crm_import_export',
|
|
41
|
+
description: 'Export contacts, companies or deals as CSV text. The file imports back with no mapping. Custom fields the caller cannot read are left out. Manager or Administrator only. Part of the CRM Studio package (see your plan).',
|
|
42
|
+
inputSchema: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: { entity: { type: 'string', enum: ENTITIES }, skip: { type: 'number' }, take: { type: 'number' } },
|
|
45
|
+
required: ['entity'],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'crm_tag_list',
|
|
50
|
+
description: 'List the tags on one CRM company or deal. Tags come from the same site tag list contacts use.',
|
|
51
|
+
inputSchema: { type: 'object', properties: { entity: { type: 'string', enum: TAG_ENTITIES }, id: { type: 'number' } }, required: ['entity', 'id'] },
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'crm_tag_add',
|
|
55
|
+
description: 'Tag a CRM company or deal. Adding the same tag twice keeps one tag.',
|
|
56
|
+
inputSchema: { type: 'object', properties: { entity: { type: 'string', enum: TAG_ENTITIES }, id: { type: 'number' }, tagId: { type: 'number' } }, required: ['entity', 'id', 'tagId'] },
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'crm_tag_remove',
|
|
60
|
+
description: 'Remove a tag from a CRM company or deal.',
|
|
61
|
+
inputSchema: { type: 'object', properties: { entity: { type: 'string', enum: TAG_ENTITIES }, id: { type: 'number' }, tagId: { type: 'number' } }, required: ['entity', 'id', 'tagId'] },
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'crm_dedupe_find',
|
|
65
|
+
description: 'Find groups of open CRM deals that look like duplicates: same title (case and punctuation ignored), same company, a shared contact, and amounts within a window. Part of the CRM Studio package (see your plan).',
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
pipelineId: { type: 'number' },
|
|
70
|
+
amountWindowPercent: { type: 'number', description: 'How close the amounts must be, in percent.' },
|
|
71
|
+
maxGroups: { type: 'number' },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'crm_dedupe_merge',
|
|
77
|
+
description: 'Merge duplicate CRM deals into a survivor. Notes, activities, contacts, conversations, tickets, attachments and custom field values move to the survivor, blank survivor fields are filled, and each duplicate is archived (restorable with crm_bulk_run action restore). Manager or Administrator only. Use dryRun first. Part of the CRM Studio package (see your plan).',
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: { survivorId: { type: 'number' }, duplicateIds: { type: 'array', items: { type: 'number' } }, dryRun: { type: 'boolean' } },
|
|
81
|
+
required: ['survivorId', 'duplicateIds'],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'crm_audit_list',
|
|
86
|
+
description: 'Show the field-change history of one CRM contact, company or deal, newest first: which field, the before and after value, who changed it and from where. Custom fields the caller cannot read are left out. Part of the CRM Studio package (see your plan).',
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: { entity: { type: 'string', enum: ENTITIES }, id: { type: 'number' }, page: { type: 'number' }, pageSize: { type: 'number' } },
|
|
90
|
+
required: ['entity', 'id'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const importBody = (a) => {
|
|
96
|
+
const body = { entity: a.entity, csv: a.csv, duplicates: a.duplicates ?? 'skip' };
|
|
97
|
+
if (a.mapping !== undefined) body.mapping = a.mapping;
|
|
98
|
+
if (a.pipelineId !== undefined) body.pipelineId = a.pipelineId;
|
|
99
|
+
return body;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const handlers = {
|
|
103
|
+
crm_import_meta: async (_a, ctx) => data(await ctx.messagingGet('/CrmImport/meta')),
|
|
104
|
+
crm_import_preview: async (a, ctx) => data(await ctx.messagingPost('/CrmImport/preview', importBody(a))),
|
|
105
|
+
crm_import_commit: async (a, ctx) => data(await ctx.messagingPost('/CrmImport/commit', importBody(a))),
|
|
106
|
+
crm_import_export: async (a, ctx) => ctx.messagingText(`/CrmImport/export${q({ entity: a.entity, skip: a.skip, take: a.take })}`),
|
|
107
|
+
crm_tag_list: async (a, ctx) => data(await ctx.messagingGet(`/CrmTags/${id(a.entity)}/${id(a.id)}`)),
|
|
108
|
+
crm_tag_add: async (a, ctx) => data(await ctx.messagingPost(`/CrmTags/${id(a.entity)}/${id(a.id)}/${id(a.tagId)}`, {})),
|
|
109
|
+
crm_tag_remove: async (a, ctx) => data(await ctx.messagingDel(`/CrmTags/${id(a.entity)}/${id(a.id)}/${id(a.tagId)}`)),
|
|
110
|
+
crm_dedupe_find: async (a, ctx) => data(await ctx.messagingGet(`/CrmDealDuplicates${q({ pipelineId: a.pipelineId, amountWindowPercent: a.amountWindowPercent, maxGroups: a.maxGroups })}`)),
|
|
111
|
+
crm_dedupe_merge: async (a, ctx) => data(await ctx.messagingPost('/CrmDealDuplicates/merge', { survivorId: a.survivorId, duplicateIds: a.duplicateIds, dryRun: !!a.dryRun })),
|
|
112
|
+
crm_audit_list: async (a, ctx) => data(await ctx.messagingGet(`/CrmAudit${q({ entity: a.entity, id: a.id, page: a.page, pageSize: a.pageSize })}`)),
|
|
113
|
+
};
|
package/server.js
CHANGED
|
@@ -160,6 +160,13 @@ async function messagingRequest(method, path, body) {
|
|
|
160
160
|
}
|
|
161
161
|
const MCP_SUBMISSION_LIMIT = 50;
|
|
162
162
|
const messagingGet = (path) => messagingRequest('GET', path);
|
|
163
|
+
// Raw text reply (CSV export); the JSON helpers above would fail to parse it.
|
|
164
|
+
async function messagingText(path) {
|
|
165
|
+
if (!MESSAGING_API) throw new Error('VELARO_MESSAGING_API is not configured.');
|
|
166
|
+
const res = await fetch(`${MESSAGING_API}${path}`, { headers: { Authorization: authHeader() }, signal: AbortSignal.timeout(30000) });
|
|
167
|
+
if (!res.ok) throw new Error(`${path} -> ${res.status}: ${(await res.text().catch(() => '')).slice(0, 300)}`);
|
|
168
|
+
return await res.text();
|
|
169
|
+
}
|
|
163
170
|
const messagingPost = (path, body) => messagingRequest('POST', path, body);
|
|
164
171
|
const messagingPut = (path, body) => messagingRequest('PUT', path, body);
|
|
165
172
|
function teamRoutingConfigPath(teamId) {
|
|
@@ -9871,7 +9878,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
9871
9878
|
return { content: [{ type: 'text', text: `Error: ${toolsetBlockedMessage(name, TOOLSETS)}` }], isError: true };
|
|
9872
9879
|
}
|
|
9873
9880
|
try {
|
|
9874
|
-
const parityResult = await runParity(PARITY, name, args ?? {}, { api, messagingGet, messagingPost, messagingPut, messagingDel, messagingPatch });
|
|
9881
|
+
const parityResult = await runParity(PARITY, name, args ?? {}, { api, messagingGet, messagingText, messagingPost, messagingPut, messagingDel, messagingPatch });
|
|
9875
9882
|
const result = parityResult !== undefined ? parityResult : await handleTool(name, args ?? {});
|
|
9876
9883
|
return { content: [{ type: 'text', text: String(result) }] };
|
|
9877
9884
|
} catch (err) {
|