@velaro/mcp-server 2.0.21 → 2.0.23

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.21",
3
+ "version": "2.0.23",
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,135 @@
1
+ // velaro part-finder: the per-site Part Finder (one ordered lookup). Site scope comes from the credential only, never from arguments.
2
+ // Parity module (CLI group `part-finder` -> MCP tools). Needs the Part Finder package (EnablePartFinder).
3
+
4
+ const need = (a, ...ks) => { for (const k of ks) if (a[k] === undefined || a[k] === null || a[k] === '') throw new Error(k + ' is required'); };
5
+ /** Body for POST /PartFinder/Sources. Pure so it is unit tested: shareUrl required and https, upload refused, no fileName sent. */
6
+ function buildSourceBody(a) {
7
+ need(a, 'shareUrl');
8
+ const shareUrl = String(a.shareUrl).trim();
9
+ if (!/^https:\/\//i.test(shareUrl)) throw new Error('shareUrl must be an https link to the file in SharePoint or OneDrive');
10
+ const type = a.type === undefined || a.type === '' ? 'sharepoint' : String(a.type).toLowerCase();
11
+ if (type !== 'sharepoint' && type !== 'onedrive') throw new Error('type must be sharepoint or onedrive');
12
+ const body = { type, shareUrl, loadMode: a.loadMode ? String(a.loadMode) : 'preload', enabled: a.enabled !== false };
13
+ if (a.syncIntervalHours !== undefined) {
14
+ const h = Number(a.syncIntervalHours);
15
+ if (!Number.isFinite(h) || h <= 0) throw new Error('syncIntervalHours must be a positive number');
16
+ body.syncIntervalHours = h;
17
+ }
18
+ if (typeof a.autoApproveRows === 'boolean') body.autoApproveRows = a.autoApproveRows;
19
+ return body;
20
+ }
21
+ const pid = (v, n = 'id') => { const x = Number(v); if (!Number.isInteger(x) || x <= 0) throw new Error(n + ' must be a positive integer'); return x; };
22
+
23
+ export const tools = [
24
+ {
25
+ name: 'part_finder_find',
26
+ description: 'Run the Part Finder lookup the bot uses for a part number, competitor model or description: approved matrix, connected business system, own catalog, then labelled possible matches. Returns status (confirmed, candidates, no_result), source, recommendations, candidates, handoff and the per-step trace. Calls POST /PartFinder/Find.',
27
+ inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The part number, model or description as the customer wrote it' } }, required: ['query'] },
28
+ },
29
+ {
30
+ name: 'part_finder_config',
31
+ description: 'Read the Part Finder settings, or change them when any field is given: enabled, steps (ordered list of {id: matrix|erp|catalog_exact|spec_search, enabled, timeoutMs}), minConfidence (0 to 1), noResultAction (handoff|categories|handoff_and_categories|capture_lead). Matrix and catalog_exact cannot both be off. Calls GET or PUT /PartFinder/Config.',
32
+ inputSchema: {
33
+ type: 'object',
34
+ properties: {
35
+ enabled: { type: 'boolean' },
36
+ steps: { type: 'array', items: { type: 'object', properties: { id: { type: 'string' }, enabled: { type: 'boolean' }, timeoutMs: { type: 'number' } }, required: ['id'] } },
37
+ minConfidence: { type: 'number' },
38
+ noResultAction: { type: 'string' },
39
+ },
40
+ },
41
+ },
42
+ {
43
+ name: 'part_finder_sources',
44
+ description: 'List the matrix sources (SharePoint, OneDrive) with load mode and last sync status. Calls GET /PartFinder/Sources.',
45
+ inputSchema: { type: 'object', properties: {} },
46
+ },
47
+ {
48
+ name: 'part_finder_source_add',
49
+ description: 'Add a matrix source from a share link. shareUrl is the Share link of an Excel (.xlsx) or CSV file in SharePoint or OneDrive (not a folder); the server resolves it to the file. type is sharepoint (default) or onedrive, loadMode is preload (default) or live, syncIntervalHours and autoApproveRows are optional. New rows are not approved unless autoApproveRows is true or the file says so. Calls POST /PartFinder/Sources.',
50
+ inputSchema: {
51
+ type: 'object',
52
+ properties: {
53
+ shareUrl: { type: 'string', description: 'The Share link (https) to the .xlsx or .csv file in SharePoint or OneDrive' },
54
+ type: { type: 'string', enum: ['sharepoint', 'onedrive'] },
55
+ loadMode: { type: 'string', enum: ['preload', 'live'] },
56
+ syncIntervalHours: { type: 'number' },
57
+ autoApproveRows: { type: 'boolean' },
58
+ enabled: { type: 'boolean' },
59
+ },
60
+ required: ['shareUrl'],
61
+ },
62
+ },
63
+ {
64
+ name: 'part_finder_source_preview',
65
+ description: 'Preview what a sync would change (added, changed, removed rows) without applying anything. Calls GET /PartFinder/Sources/{id}/Preview.',
66
+ inputSchema: { type: 'object', properties: { id: { type: 'number' } }, required: ['id'] },
67
+ },
68
+ {
69
+ name: 'part_finder_source_sync',
70
+ description: 'Sync one matrix source now. Unchanged files are not downloaded. Removed rows are switched to not approved, never deleted. Calls POST /PartFinder/Sources/{id}/SyncNow.',
71
+ inputSchema: { type: 'object', properties: { id: { type: 'number' } }, required: ['id'] },
72
+ },
73
+ {
74
+ name: 'part_finder_source_remove',
75
+ description: 'Remove one matrix source. Rows it already loaded stay in the matrix until removed there. Calls DELETE /PartFinder/Sources/{id}.',
76
+ inputSchema: { type: 'object', properties: { id: { type: 'number' } }, required: ['id'] },
77
+ },
78
+ {
79
+ name: 'part_finder_misses',
80
+ description: 'List what customers asked that found nothing (normalized text, count, last time), or dismiss one when dismissId is given. Calls GET /PartFinder/Misses or POST /PartFinder/Misses/{id}/Dismiss.',
81
+ inputSchema: { type: 'object', properties: { dismissId: { type: 'number' } } },
82
+ },
83
+ {
84
+ name: 'part_finder_suggestions',
85
+ description: 'List the AI-suggested matrix rows waiting for a person (never recommended until approved). Calls GET /PartFinder/Suggestions.',
86
+ inputSchema: { type: 'object', properties: {} },
87
+ },
88
+ {
89
+ name: 'part_finder_suggestions_generate',
90
+ description: 'Create suggestions for the top missed questions from catalog text. Suggestions start not approved. Capped per month by plan. Calls POST /PartFinder/Suggestions/Generate.',
91
+ inputSchema: { type: 'object', properties: {} },
92
+ },
93
+ {
94
+ name: 'part_finder_suggestion_decide',
95
+ description: 'Approve or reject one suggestion (approved defaults to true). Only approved rows are ever recommended. Calls POST /PartFinder/Suggestions/{id}/Approve or /Reject.',
96
+ inputSchema: { type: 'object', properties: { id: { type: 'number' }, approved: { type: 'boolean' } }, required: ['id'] },
97
+ },
98
+ ];
99
+
100
+ export const handlers = {
101
+ part_finder_find: async (a, ctx) => {
102
+ need(a, 'query');
103
+ return ctx.messagingPost('/PartFinder/Find', { query: String(a.query) });
104
+ },
105
+ part_finder_config: async (a, ctx) => {
106
+ const patch = {};
107
+ if (typeof a.enabled === 'boolean') patch.enabled = a.enabled;
108
+ if (Array.isArray(a.steps)) patch.steps = a.steps.map((s) => ({ id: String(s.id), enabled: s.enabled !== false, timeoutMs: Number(s.timeoutMs ?? 1000) }));
109
+ if (a.minConfidence !== undefined) {
110
+ const v = Number(a.minConfidence);
111
+ if (!Number.isFinite(v) || v < 0 || v > 1) throw new Error('minConfidence must be between 0 and 1');
112
+ patch.minConfidence = v;
113
+ }
114
+ if (a.noResultAction !== undefined) patch.noResultAction = String(a.noResultAction);
115
+ if (Object.keys(patch).length === 0) return ctx.messagingGet('/PartFinder/Config');
116
+ return ctx.messagingPut('/PartFinder/Config', patch);
117
+ },
118
+ part_finder_sources: async (_a, ctx) => ctx.messagingGet('/PartFinder/Sources'),
119
+ part_finder_source_add: async (a, ctx) => {
120
+ return ctx.messagingPost('/PartFinder/Sources', buildSourceBody(a));
121
+ },
122
+ part_finder_source_preview: async (a, ctx) => ctx.messagingGet('/PartFinder/Sources/' + pid(a.id) + '/Preview'),
123
+ part_finder_source_sync: async (a, ctx) => ctx.messagingPost('/PartFinder/Sources/' + pid(a.id) + '/SyncNow', {}),
124
+ part_finder_source_remove: async (a, ctx) => ctx.messagingDel('/PartFinder/Sources/' + pid(a.id)),
125
+ part_finder_misses: async (a, ctx) => {
126
+ if (a.dismissId !== undefined) return ctx.messagingPost('/PartFinder/Misses/' + pid(a.dismissId, 'dismissId') + '/Dismiss', {});
127
+ return ctx.messagingGet('/PartFinder/Misses');
128
+ },
129
+ part_finder_suggestions: async (_a, ctx) => ctx.messagingGet('/PartFinder/Suggestions'),
130
+ part_finder_suggestions_generate: async (_a, ctx) => ctx.messagingPost('/PartFinder/Suggestions/Generate', {}),
131
+ part_finder_suggestion_decide: async (a, ctx) => {
132
+ const verb = a.approved === false ? 'Reject' : 'Approve';
133
+ return ctx.messagingPost('/PartFinder/Suggestions/' + pid(a.id) + '/' + verb, {});
134
+ },
135
+ };