@velaro/mcp-server 2.0.51 → 2.0.53
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/email-route.customer.js +61 -0
- package/server.js +31 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velaro/mcp-server",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.53",
|
|
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,61 @@
|
|
|
1
|
+
// MCP parity for `velaro email-route` (cli/lib/commands/email-route.js). Backend: velaro-messaging TicketController
|
|
2
|
+
// Ticket/email-routes (GET list, POST create, PUT /{id} update, DELETE /{id}). Site from the credential, never an argument.
|
|
3
|
+
// Rules are evaluated in sortOrder; first match wins. Update is a full replace of the route fields (the server copies every field).
|
|
4
|
+
|
|
5
|
+
const MODES = ['ticket', 'conversation', 'ignore'];
|
|
6
|
+
|
|
7
|
+
const fields = {
|
|
8
|
+
name: { type: 'string', description: 'Route name (200 characters max).' },
|
|
9
|
+
recipientPattern: { type: 'string', description: 'Case-insensitive substring of the recipient address, e.g. "billing@support.acme.com" or "@acme.com". Blank matches any recipient.' },
|
|
10
|
+
senderDomainPattern: { type: 'string', description: 'Optional sender domain filter, e.g. "enterprise-client.com".' },
|
|
11
|
+
subjectKeywords: { type: 'string', description: 'Optional comma-separated subject keywords (any match), e.g. "invoice,billing,payment".' },
|
|
12
|
+
teamId: { type: 'number', description: 'Target team id (see team_list). Omit to use the site default team.' },
|
|
13
|
+
priority: { type: 'string', description: 'Priority for tickets created from this route (16 characters max).' },
|
|
14
|
+
category: { type: 'string', description: 'Category for tickets created from this route (64 characters max).' },
|
|
15
|
+
sortOrder: { type: 'number', description: 'Lower number is evaluated first. Default 0.' },
|
|
16
|
+
isActive: { type: 'boolean', description: 'Default true.' },
|
|
17
|
+
mode: { type: 'string', enum: MODES, description: 'ticket = always create a ticket, conversation = always a live conversation, ignore = discard silently. Omit to inherit the site-wide ticketing setting.' },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const body = (a) => ({
|
|
21
|
+
name: a.name,
|
|
22
|
+
recipientPattern: a.recipientPattern ?? null,
|
|
23
|
+
senderDomainPattern: a.senderDomainPattern ?? null,
|
|
24
|
+
subjectKeywords: a.subjectKeywords ?? null,
|
|
25
|
+
teamId: a.teamId ?? null,
|
|
26
|
+
priority: a.priority ?? null,
|
|
27
|
+
category: a.category ?? null,
|
|
28
|
+
sortOrder: a.sortOrder ?? 0,
|
|
29
|
+
isActive: a.isActive ?? true,
|
|
30
|
+
mode: a.mode ?? null,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const tools = [
|
|
34
|
+
{
|
|
35
|
+
name: 'email_route_list',
|
|
36
|
+
description: 'List ticket email routes: rules that send inbound email to a team, priority, category and mode (ticket, conversation, ignore) by recipient address, sender domain and subject keywords. Evaluated in sortOrder, first match wins.',
|
|
37
|
+
inputSchema: { type: 'object', properties: {} },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'email_route_create',
|
|
41
|
+
description: 'Create a ticket email route. The site plan may cap the number of routes. Returns the created route.',
|
|
42
|
+
inputSchema: { type: 'object', properties: fields, required: ['name'] },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'email_route_update',
|
|
46
|
+
description: 'Update a ticket email route by id. This replaces every route field, so pass the full route (read it with email_route_list first); omitted optional fields are cleared.',
|
|
47
|
+
inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Route id (see email_route_list).' }, ...fields }, required: ['id', 'name'] },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'email_route_delete',
|
|
51
|
+
description: 'Delete a ticket email route by id. Emails that matched it fall through to the next route or the site default.',
|
|
52
|
+
inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Route id (see email_route_list).' } }, required: ['id'] },
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
export const handlers = {
|
|
57
|
+
email_route_list: async (_a, ctx) => ({ routes: await ctx.messagingGet('/Ticket/email-routes') }),
|
|
58
|
+
email_route_create: async (a, ctx) => await ctx.messagingPost('/Ticket/email-routes', body(a)),
|
|
59
|
+
email_route_update: async (a, ctx) => await ctx.messagingPut(`/Ticket/email-routes/${encodeURIComponent(a.id)}`, body(a)),
|
|
60
|
+
email_route_delete: async (a, ctx) => await ctx.messagingDel(`/Ticket/email-routes/${encodeURIComponent(a.id)}`),
|
|
61
|
+
};
|
package/server.js
CHANGED
|
@@ -245,6 +245,24 @@ async function skillRoutingCrud(resource, args, fields) {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
// Magento search routes need ?configId= (the connected store) and ?query=; the old ?q= form always
|
|
249
|
+
// answered 404 "Config not found". Same rule as cli/lib/commands/magento-search.js.
|
|
250
|
+
async function magentoSearchPath(kind, query, configId) {
|
|
251
|
+
const configs = await api('GET', '/Magento/Configs');
|
|
252
|
+
const list = Array.isArray(configs) ? configs : [];
|
|
253
|
+
let id = configId === undefined || configId === null || configId === '' ? configId : Number(configId);
|
|
254
|
+
if (id === undefined || id === null) {
|
|
255
|
+
const active = list.filter(c => c.enabled !== false && c.isActive !== false);
|
|
256
|
+
if (active.length === 0) throw new Error('No active Magento store connected.');
|
|
257
|
+
if (active.length > 1) throw new Error('More than one Magento store is connected. Pass configId. Stores: ' + active.map(c => `${c.id} (${c.displayName ?? c.storeUrl})`).join(', '));
|
|
258
|
+
id = active[0].id;
|
|
259
|
+
} else if (!list.some(c => c.id === id)) {
|
|
260
|
+
throw new Error(`No connected Magento store has id ${id}.`);
|
|
261
|
+
}
|
|
262
|
+
const route = { customers: 'Customers', orders: 'Orders', products: 'Products' }[kind];
|
|
263
|
+
return `/Magento/${route}/Search?configId=${encodeURIComponent(id)}&query=${encodeURIComponent(query)}`;
|
|
264
|
+
}
|
|
265
|
+
|
|
248
266
|
async function api(method, path, body, base = API_BASE) {
|
|
249
267
|
// Normalize: a path without a leading slash would glue onto the host ("...comScraperJobs/...") and fail as "fetch failed".
|
|
250
268
|
if (!path.startsWith('/')) path = '/' + path;
|
|
@@ -3297,6 +3315,7 @@ For multiSelect dynamic options: the variable named in dynamicOptionsVariable mu
|
|
|
3297
3315
|
type: 'object',
|
|
3298
3316
|
properties: {
|
|
3299
3317
|
email: { type: 'string', description: 'Customer email to look up' },
|
|
3318
|
+
configId: { type: 'number', description: 'Connected store id (magento_list_stores). Optional when only one store is connected.' },
|
|
3300
3319
|
},
|
|
3301
3320
|
required: ['email'],
|
|
3302
3321
|
},
|
|
@@ -3308,6 +3327,7 @@ For multiSelect dynamic options: the variable named in dynamicOptionsVariable mu
|
|
|
3308
3327
|
type: 'object',
|
|
3309
3328
|
properties: {
|
|
3310
3329
|
orderId: { type: 'string', description: 'Magento order increment ID, e.g. "000001234"' },
|
|
3330
|
+
configId: { type: 'number', description: 'Connected store id (magento_list_stores). Optional when only one store is connected.' },
|
|
3311
3331
|
},
|
|
3312
3332
|
required: ['orderId'],
|
|
3313
3333
|
},
|
|
@@ -3320,6 +3340,7 @@ For multiSelect dynamic options: the variable named in dynamicOptionsVariable mu
|
|
|
3320
3340
|
properties: {
|
|
3321
3341
|
email: { type: 'string', description: 'Customer email address' },
|
|
3322
3342
|
limit: { type: 'number', description: 'Max results (default: 10, max: 50)' },
|
|
3343
|
+
configId: { type: 'number', description: 'Connected store id (magento_list_stores). Optional when only one store is connected.' },
|
|
3323
3344
|
},
|
|
3324
3345
|
required: ['email'],
|
|
3325
3346
|
},
|
|
@@ -3330,6 +3351,7 @@ For multiSelect dynamic options: the variable named in dynamicOptionsVariable mu
|
|
|
3330
3351
|
inputSchema: {
|
|
3331
3352
|
type: 'object',
|
|
3332
3353
|
properties: {
|
|
3354
|
+
configId: { type: 'number', description: 'Connected store id (magento_list_stores). Optional when only one store is connected.' },
|
|
3333
3355
|
query: { type: 'string', description: 'Product name search query' },
|
|
3334
3356
|
limit: { type: 'number', description: 'Max results (default: 10, max: 50)' },
|
|
3335
3357
|
},
|
|
@@ -7795,13 +7817,14 @@ reply: ${r?.reply}`;
|
|
|
7795
7817
|
}
|
|
7796
7818
|
|
|
7797
7819
|
case 'magento_search_customers': {
|
|
7798
|
-
const
|
|
7799
|
-
|
|
7800
|
-
|
|
7820
|
+
const found = await api('GET', await magentoSearchPath('customers', args.email, args.configId));
|
|
7821
|
+
const customers = Array.isArray(found) ? found : (found && found.id ? [found] : []);
|
|
7822
|
+
if (!customers.length) return `No Magento customer found for ${args.email}.`;
|
|
7823
|
+
return customers.map(r => `Customer: ${r.name ?? ([r.firstName, r.lastName].filter(Boolean).join(' ') || '(no name)')} | ${r.email} | Group: ${r.group ?? r.groupId ?? 'General'} | ID: ${r.id}`).join('\n');
|
|
7801
7824
|
}
|
|
7802
7825
|
|
|
7803
7826
|
case 'magento_get_order': {
|
|
7804
|
-
const r = await api('GET',
|
|
7827
|
+
const r = await api('GET', await magentoSearchPath('orders', args.orderId, args.configId));
|
|
7805
7828
|
if (!Array.isArray(r) || !r.length) return `Order ${args.orderId} not found.`;
|
|
7806
7829
|
const o = r[0];
|
|
7807
7830
|
const lines = [
|
|
@@ -7816,7 +7839,8 @@ reply: ${r?.reply}`;
|
|
|
7816
7839
|
|
|
7817
7840
|
case 'magento_search_orders': {
|
|
7818
7841
|
const limit = Math.min(50, args.limit ?? 10);
|
|
7819
|
-
const
|
|
7842
|
+
const found = await api('GET', await magentoSearchPath('orders', args.email, args.configId));
|
|
7843
|
+
const r = Array.isArray(found) ? found.slice(0, limit) : found;
|
|
7820
7844
|
if (!Array.isArray(r) || !r.length) return `No orders found for ${args.email}.`;
|
|
7821
7845
|
return r.map(o =>
|
|
7822
7846
|
`[${o.incrementId ?? o.id}] ${o.status} — $${o.grandTotal} — ${o.createdAt?.slice(0, 10)}`
|
|
@@ -7825,7 +7849,8 @@ reply: ${r?.reply}`;
|
|
|
7825
7849
|
|
|
7826
7850
|
case 'magento_search_products': {
|
|
7827
7851
|
const limit = Math.min(50, args.limit ?? 10);
|
|
7828
|
-
const
|
|
7852
|
+
const found = await api('GET', await magentoSearchPath('products', args.query, args.configId));
|
|
7853
|
+
const r = Array.isArray(found) ? found.slice(0, limit) : found;
|
|
7829
7854
|
if (!Array.isArray(r) || !r.length) return `No products found for "${args.query}".`;
|
|
7830
7855
|
return r.map(p =>
|
|
7831
7856
|
`[${p.sku}] ${p.name} — $${p.price} — ${p.status}`
|