@l4yercak3/cli 1.2.16 → 1.2.18
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/docs/INTEGRATION_PATHS_ARCHITECTURE.md +1543 -0
- package/package.json +1 -1
- package/src/commands/spread.js +101 -6
- package/src/detectors/database-detector.js +245 -0
- package/src/detectors/index.js +17 -4
- package/src/generators/api-only/client.js +683 -0
- package/src/generators/api-only/index.js +96 -0
- package/src/generators/api-only/types.js +618 -0
- package/src/generators/api-only/webhooks.js +377 -0
- package/src/generators/index.js +88 -2
- package/src/generators/mcp-guide-generator.js +256 -0
- package/src/generators/quickstart/components/index.js +1699 -0
- package/src/generators/quickstart/database/convex.js +1257 -0
- package/src/generators/quickstart/database/index.js +34 -0
- package/src/generators/quickstart/database/supabase.js +1132 -0
- package/src/generators/quickstart/hooks/index.js +1047 -0
- package/src/generators/quickstart/index.js +151 -0
- package/src/generators/quickstart/pages/index.js +1466 -0
- package/src/mcp/registry/domains/benefits.js +798 -0
- package/src/mcp/registry/index.js +2 -0
- package/tests/database-detector.test.js +221 -0
- package/tests/generators-index.test.js +215 -3
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Benefits Domain Tools
|
|
3
|
+
*
|
|
4
|
+
* Tools for managing benefits, commission payouts, member wallets,
|
|
5
|
+
* and platform fees tracking.
|
|
6
|
+
*
|
|
7
|
+
* @module mcp/registry/domains/benefits
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const backendClient = require('../../../api/backend-client');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Benefits domain definition
|
|
14
|
+
*/
|
|
15
|
+
module.exports = {
|
|
16
|
+
name: 'benefits',
|
|
17
|
+
description: 'Benefits Platform - claims, commissions, wallets, and fees',
|
|
18
|
+
tools: [
|
|
19
|
+
// ========================================
|
|
20
|
+
// Benefit Claims Tools
|
|
21
|
+
// ========================================
|
|
22
|
+
{
|
|
23
|
+
name: 'l4yercak3_benefits_list_claims',
|
|
24
|
+
description: `List benefit claims for the organization.
|
|
25
|
+
Use this to retrieve pending, approved, or rejected benefit claims.
|
|
26
|
+
|
|
27
|
+
Returns claims with their status, amount, and member information.`,
|
|
28
|
+
inputSchema: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
status: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
enum: ['pending', 'approved', 'rejected', 'paid', 'cancelled'],
|
|
34
|
+
description: 'Filter by claim status',
|
|
35
|
+
},
|
|
36
|
+
memberId: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'Filter by member ID',
|
|
39
|
+
},
|
|
40
|
+
benefitType: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'Filter by benefit type',
|
|
43
|
+
},
|
|
44
|
+
limit: {
|
|
45
|
+
type: 'number',
|
|
46
|
+
description: 'Max claims to return (default 50, max 100)',
|
|
47
|
+
},
|
|
48
|
+
offset: {
|
|
49
|
+
type: 'number',
|
|
50
|
+
description: 'Offset for pagination',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
requiresAuth: true,
|
|
55
|
+
requiredPermissions: ['benefits:read'],
|
|
56
|
+
handler: async (params, authContext) => {
|
|
57
|
+
const queryParams = new URLSearchParams();
|
|
58
|
+
queryParams.set('organizationId', authContext.organizationId);
|
|
59
|
+
if (params.status) queryParams.set('status', params.status);
|
|
60
|
+
if (params.memberId) queryParams.set('memberId', params.memberId);
|
|
61
|
+
if (params.benefitType) queryParams.set('benefitType', params.benefitType);
|
|
62
|
+
if (params.limit) queryParams.set('limit', Math.min(params.limit, 100));
|
|
63
|
+
if (params.offset) queryParams.set('offset', params.offset);
|
|
64
|
+
|
|
65
|
+
const response = await backendClient.request(
|
|
66
|
+
'GET',
|
|
67
|
+
`/api/v1/benefits/claims?${queryParams.toString()}`
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
claims: (response.claims || []).map(claim => ({
|
|
72
|
+
id: claim._id,
|
|
73
|
+
memberId: claim.memberId,
|
|
74
|
+
memberName: claim.memberName,
|
|
75
|
+
benefitType: claim.benefitType,
|
|
76
|
+
amount: claim.amount,
|
|
77
|
+
currency: claim.currency || 'EUR',
|
|
78
|
+
status: claim.status,
|
|
79
|
+
description: claim.description,
|
|
80
|
+
submittedAt: claim.submittedAt,
|
|
81
|
+
processedAt: claim.processedAt,
|
|
82
|
+
notes: claim.notes,
|
|
83
|
+
})),
|
|
84
|
+
total: response.total || (response.claims || []).length,
|
|
85
|
+
hasMore: response.hasMore || false,
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
{
|
|
91
|
+
name: 'l4yercak3_benefits_create_claim',
|
|
92
|
+
description: `Create a new benefit claim.
|
|
93
|
+
Use this to submit a benefit claim on behalf of a member.`,
|
|
94
|
+
inputSchema: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
memberId: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
description: 'Member ID submitting the claim',
|
|
100
|
+
},
|
|
101
|
+
benefitType: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
description: 'Type of benefit being claimed',
|
|
104
|
+
},
|
|
105
|
+
amount: {
|
|
106
|
+
type: 'number',
|
|
107
|
+
description: 'Claim amount',
|
|
108
|
+
},
|
|
109
|
+
currency: {
|
|
110
|
+
type: 'string',
|
|
111
|
+
description: 'Currency code (default: EUR)',
|
|
112
|
+
},
|
|
113
|
+
description: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'Description of the claim',
|
|
116
|
+
},
|
|
117
|
+
supportingDocuments: {
|
|
118
|
+
type: 'array',
|
|
119
|
+
items: { type: 'string' },
|
|
120
|
+
description: 'URLs to supporting documents',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
required: ['memberId', 'benefitType', 'amount'],
|
|
124
|
+
},
|
|
125
|
+
requiresAuth: true,
|
|
126
|
+
requiredPermissions: ['benefits:write'],
|
|
127
|
+
handler: async (params, authContext) => {
|
|
128
|
+
const response = await backendClient.request('POST', '/api/v1/benefits/claims', {
|
|
129
|
+
organizationId: authContext.organizationId,
|
|
130
|
+
memberId: params.memberId,
|
|
131
|
+
benefitType: params.benefitType,
|
|
132
|
+
amount: params.amount,
|
|
133
|
+
currency: params.currency || 'EUR',
|
|
134
|
+
description: params.description,
|
|
135
|
+
supportingDocuments: params.supportingDocuments || [],
|
|
136
|
+
source: 'mcp',
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
success: true,
|
|
141
|
+
claimId: response.claimId || response._id,
|
|
142
|
+
status: 'pending',
|
|
143
|
+
message: 'Benefit claim submitted successfully',
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
{
|
|
149
|
+
name: 'l4yercak3_benefits_get_claim',
|
|
150
|
+
description: `Get details of a specific benefit claim.`,
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: 'object',
|
|
153
|
+
properties: {
|
|
154
|
+
claimId: {
|
|
155
|
+
type: 'string',
|
|
156
|
+
description: 'The claim ID',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
required: ['claimId'],
|
|
160
|
+
},
|
|
161
|
+
requiresAuth: true,
|
|
162
|
+
requiredPermissions: ['benefits:read'],
|
|
163
|
+
handler: async (params, _authContext) => {
|
|
164
|
+
const response = await backendClient.request(
|
|
165
|
+
'GET',
|
|
166
|
+
`/api/v1/benefits/claims/${params.claimId}`
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const claim = response.claim || response;
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
id: claim._id,
|
|
173
|
+
memberId: claim.memberId,
|
|
174
|
+
memberName: claim.memberName,
|
|
175
|
+
memberEmail: claim.memberEmail,
|
|
176
|
+
benefitType: claim.benefitType,
|
|
177
|
+
amount: claim.amount,
|
|
178
|
+
currency: claim.currency || 'EUR',
|
|
179
|
+
status: claim.status,
|
|
180
|
+
description: claim.description,
|
|
181
|
+
supportingDocuments: claim.supportingDocuments || [],
|
|
182
|
+
submittedAt: claim.submittedAt,
|
|
183
|
+
processedAt: claim.processedAt,
|
|
184
|
+
processedBy: claim.processedBy,
|
|
185
|
+
notes: claim.notes,
|
|
186
|
+
history: claim.history || [],
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
{
|
|
192
|
+
name: 'l4yercak3_benefits_update_claim_status',
|
|
193
|
+
description: `Update the status of a benefit claim (approve, reject, etc.).`,
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {
|
|
197
|
+
claimId: {
|
|
198
|
+
type: 'string',
|
|
199
|
+
description: 'The claim ID to update',
|
|
200
|
+
},
|
|
201
|
+
status: {
|
|
202
|
+
type: 'string',
|
|
203
|
+
enum: ['approved', 'rejected', 'paid', 'cancelled'],
|
|
204
|
+
description: 'New status for the claim',
|
|
205
|
+
},
|
|
206
|
+
notes: {
|
|
207
|
+
type: 'string',
|
|
208
|
+
description: 'Notes about the status change',
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
required: ['claimId', 'status'],
|
|
212
|
+
},
|
|
213
|
+
requiresAuth: true,
|
|
214
|
+
requiredPermissions: ['benefits:write'],
|
|
215
|
+
handler: async (params, _authContext) => {
|
|
216
|
+
await backendClient.request(
|
|
217
|
+
'PATCH',
|
|
218
|
+
`/api/v1/benefits/claims/${params.claimId}/status`,
|
|
219
|
+
{
|
|
220
|
+
status: params.status,
|
|
221
|
+
notes: params.notes,
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
success: true,
|
|
227
|
+
claimId: params.claimId,
|
|
228
|
+
status: params.status,
|
|
229
|
+
message: `Claim ${params.status} successfully`,
|
|
230
|
+
};
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
// ========================================
|
|
235
|
+
// Commission Payout Tools
|
|
236
|
+
// ========================================
|
|
237
|
+
{
|
|
238
|
+
name: 'l4yercak3_benefits_list_commissions',
|
|
239
|
+
description: `List commission payouts for the organization.
|
|
240
|
+
Use this to view pending, processing, or completed commission payouts.`,
|
|
241
|
+
inputSchema: {
|
|
242
|
+
type: 'object',
|
|
243
|
+
properties: {
|
|
244
|
+
status: {
|
|
245
|
+
type: 'string',
|
|
246
|
+
enum: ['pending', 'processing', 'completed', 'failed', 'cancelled'],
|
|
247
|
+
description: 'Filter by payout status',
|
|
248
|
+
},
|
|
249
|
+
memberId: {
|
|
250
|
+
type: 'string',
|
|
251
|
+
description: 'Filter by member ID',
|
|
252
|
+
},
|
|
253
|
+
commissionType: {
|
|
254
|
+
type: 'string',
|
|
255
|
+
description: 'Filter by commission type',
|
|
256
|
+
},
|
|
257
|
+
limit: {
|
|
258
|
+
type: 'number',
|
|
259
|
+
description: 'Max payouts to return (default 50)',
|
|
260
|
+
},
|
|
261
|
+
offset: {
|
|
262
|
+
type: 'number',
|
|
263
|
+
description: 'Offset for pagination',
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
requiresAuth: true,
|
|
268
|
+
requiredPermissions: ['benefits:read'],
|
|
269
|
+
handler: async (params, authContext) => {
|
|
270
|
+
const queryParams = new URLSearchParams();
|
|
271
|
+
queryParams.set('organizationId', authContext.organizationId);
|
|
272
|
+
if (params.status) queryParams.set('status', params.status);
|
|
273
|
+
if (params.memberId) queryParams.set('memberId', params.memberId);
|
|
274
|
+
if (params.commissionType) queryParams.set('commissionType', params.commissionType);
|
|
275
|
+
if (params.limit) queryParams.set('limit', Math.min(params.limit, 100));
|
|
276
|
+
if (params.offset) queryParams.set('offset', params.offset);
|
|
277
|
+
|
|
278
|
+
const response = await backendClient.request(
|
|
279
|
+
'GET',
|
|
280
|
+
`/api/v1/benefits/commissions?${queryParams.toString()}`
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
commissions: (response.commissions || []).map(payout => ({
|
|
285
|
+
id: payout._id,
|
|
286
|
+
memberId: payout.memberId,
|
|
287
|
+
memberName: payout.memberName,
|
|
288
|
+
commissionType: payout.commissionType,
|
|
289
|
+
amount: payout.amount,
|
|
290
|
+
currency: payout.currency || 'EUR',
|
|
291
|
+
status: payout.status,
|
|
292
|
+
sourceTransaction: payout.sourceTransaction,
|
|
293
|
+
calculatedAt: payout.calculatedAt,
|
|
294
|
+
paidAt: payout.paidAt,
|
|
295
|
+
paymentMethod: payout.paymentMethod,
|
|
296
|
+
})),
|
|
297
|
+
total: response.total || (response.commissions || []).length,
|
|
298
|
+
hasMore: response.hasMore || false,
|
|
299
|
+
};
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
{
|
|
304
|
+
name: 'l4yercak3_benefits_create_commission',
|
|
305
|
+
description: `Create a new commission payout record.
|
|
306
|
+
Use this to record a commission earned by a member.`,
|
|
307
|
+
inputSchema: {
|
|
308
|
+
type: 'object',
|
|
309
|
+
properties: {
|
|
310
|
+
memberId: {
|
|
311
|
+
type: 'string',
|
|
312
|
+
description: 'Member ID earning the commission',
|
|
313
|
+
},
|
|
314
|
+
commissionType: {
|
|
315
|
+
type: 'string',
|
|
316
|
+
description: 'Type of commission (e.g., referral, sales, affiliate)',
|
|
317
|
+
},
|
|
318
|
+
amount: {
|
|
319
|
+
type: 'number',
|
|
320
|
+
description: 'Commission amount',
|
|
321
|
+
},
|
|
322
|
+
currency: {
|
|
323
|
+
type: 'string',
|
|
324
|
+
description: 'Currency code (default: EUR)',
|
|
325
|
+
},
|
|
326
|
+
sourceTransaction: {
|
|
327
|
+
type: 'string',
|
|
328
|
+
description: 'ID of the transaction that generated this commission',
|
|
329
|
+
},
|
|
330
|
+
description: {
|
|
331
|
+
type: 'string',
|
|
332
|
+
description: 'Description of the commission',
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
required: ['memberId', 'commissionType', 'amount'],
|
|
336
|
+
},
|
|
337
|
+
requiresAuth: true,
|
|
338
|
+
requiredPermissions: ['benefits:write'],
|
|
339
|
+
handler: async (params, authContext) => {
|
|
340
|
+
const response = await backendClient.request('POST', '/api/v1/benefits/commissions', {
|
|
341
|
+
organizationId: authContext.organizationId,
|
|
342
|
+
memberId: params.memberId,
|
|
343
|
+
commissionType: params.commissionType,
|
|
344
|
+
amount: params.amount,
|
|
345
|
+
currency: params.currency || 'EUR',
|
|
346
|
+
sourceTransaction: params.sourceTransaction,
|
|
347
|
+
description: params.description,
|
|
348
|
+
source: 'mcp',
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
return {
|
|
352
|
+
success: true,
|
|
353
|
+
commissionId: response.commissionId || response._id,
|
|
354
|
+
status: 'pending',
|
|
355
|
+
message: 'Commission payout created successfully',
|
|
356
|
+
};
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
{
|
|
361
|
+
name: 'l4yercak3_benefits_get_commission',
|
|
362
|
+
description: `Get details of a specific commission payout.`,
|
|
363
|
+
inputSchema: {
|
|
364
|
+
type: 'object',
|
|
365
|
+
properties: {
|
|
366
|
+
commissionId: {
|
|
367
|
+
type: 'string',
|
|
368
|
+
description: 'The commission payout ID',
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
required: ['commissionId'],
|
|
372
|
+
},
|
|
373
|
+
requiresAuth: true,
|
|
374
|
+
requiredPermissions: ['benefits:read'],
|
|
375
|
+
handler: async (params, _authContext) => {
|
|
376
|
+
const response = await backendClient.request(
|
|
377
|
+
'GET',
|
|
378
|
+
`/api/v1/benefits/commissions/${params.commissionId}`
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
const commission = response.commission || response;
|
|
382
|
+
|
|
383
|
+
return {
|
|
384
|
+
id: commission._id,
|
|
385
|
+
memberId: commission.memberId,
|
|
386
|
+
memberName: commission.memberName,
|
|
387
|
+
commissionType: commission.commissionType,
|
|
388
|
+
amount: commission.amount,
|
|
389
|
+
currency: commission.currency || 'EUR',
|
|
390
|
+
status: commission.status,
|
|
391
|
+
sourceTransaction: commission.sourceTransaction,
|
|
392
|
+
description: commission.description,
|
|
393
|
+
calculatedAt: commission.calculatedAt,
|
|
394
|
+
paidAt: commission.paidAt,
|
|
395
|
+
paymentMethod: commission.paymentMethod,
|
|
396
|
+
paymentReference: commission.paymentReference,
|
|
397
|
+
history: commission.history || [],
|
|
398
|
+
};
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
{
|
|
403
|
+
name: 'l4yercak3_benefits_process_commission',
|
|
404
|
+
description: `Process a pending commission payout (mark as processing, completed, or failed).`,
|
|
405
|
+
inputSchema: {
|
|
406
|
+
type: 'object',
|
|
407
|
+
properties: {
|
|
408
|
+
commissionId: {
|
|
409
|
+
type: 'string',
|
|
410
|
+
description: 'The commission ID to process',
|
|
411
|
+
},
|
|
412
|
+
status: {
|
|
413
|
+
type: 'string',
|
|
414
|
+
enum: ['processing', 'completed', 'failed', 'cancelled'],
|
|
415
|
+
description: 'New status for the payout',
|
|
416
|
+
},
|
|
417
|
+
paymentMethod: {
|
|
418
|
+
type: 'string',
|
|
419
|
+
description: 'Payment method used (e.g., bank_transfer, crypto, paypal)',
|
|
420
|
+
},
|
|
421
|
+
paymentReference: {
|
|
422
|
+
type: 'string',
|
|
423
|
+
description: 'Payment reference/transaction ID',
|
|
424
|
+
},
|
|
425
|
+
notes: {
|
|
426
|
+
type: 'string',
|
|
427
|
+
description: 'Notes about the processing',
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
required: ['commissionId', 'status'],
|
|
431
|
+
},
|
|
432
|
+
requiresAuth: true,
|
|
433
|
+
requiredPermissions: ['benefits:write'],
|
|
434
|
+
handler: async (params, _authContext) => {
|
|
435
|
+
await backendClient.request(
|
|
436
|
+
'PATCH',
|
|
437
|
+
`/api/v1/benefits/commissions/${params.commissionId}/process`,
|
|
438
|
+
{
|
|
439
|
+
status: params.status,
|
|
440
|
+
paymentMethod: params.paymentMethod,
|
|
441
|
+
paymentReference: params.paymentReference,
|
|
442
|
+
notes: params.notes,
|
|
443
|
+
}
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
return {
|
|
447
|
+
success: true,
|
|
448
|
+
commissionId: params.commissionId,
|
|
449
|
+
status: params.status,
|
|
450
|
+
message: `Commission payout ${params.status} successfully`,
|
|
451
|
+
};
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
// ========================================
|
|
456
|
+
// Member Wallet Tools
|
|
457
|
+
// ========================================
|
|
458
|
+
{
|
|
459
|
+
name: 'l4yercak3_benefits_list_wallets',
|
|
460
|
+
description: `List member wallets for the organization.
|
|
461
|
+
Use this to view linked crypto wallets for members.`,
|
|
462
|
+
inputSchema: {
|
|
463
|
+
type: 'object',
|
|
464
|
+
properties: {
|
|
465
|
+
memberId: {
|
|
466
|
+
type: 'string',
|
|
467
|
+
description: 'Filter by member ID',
|
|
468
|
+
},
|
|
469
|
+
walletType: {
|
|
470
|
+
type: 'string',
|
|
471
|
+
enum: ['ethereum', 'bitcoin', 'solana', 'polygon', 'other'],
|
|
472
|
+
description: 'Filter by wallet type/network',
|
|
473
|
+
},
|
|
474
|
+
verified: {
|
|
475
|
+
type: 'boolean',
|
|
476
|
+
description: 'Filter by verification status',
|
|
477
|
+
},
|
|
478
|
+
limit: {
|
|
479
|
+
type: 'number',
|
|
480
|
+
description: 'Max wallets to return (default 50)',
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
requiresAuth: true,
|
|
485
|
+
requiredPermissions: ['benefits:read'],
|
|
486
|
+
handler: async (params, authContext) => {
|
|
487
|
+
const queryParams = new URLSearchParams();
|
|
488
|
+
queryParams.set('organizationId', authContext.organizationId);
|
|
489
|
+
if (params.memberId) queryParams.set('memberId', params.memberId);
|
|
490
|
+
if (params.walletType) queryParams.set('walletType', params.walletType);
|
|
491
|
+
if (params.verified !== undefined) queryParams.set('verified', params.verified);
|
|
492
|
+
if (params.limit) queryParams.set('limit', Math.min(params.limit, 100));
|
|
493
|
+
|
|
494
|
+
const response = await backendClient.request(
|
|
495
|
+
'GET',
|
|
496
|
+
`/api/v1/benefits/wallets?${queryParams.toString()}`
|
|
497
|
+
);
|
|
498
|
+
|
|
499
|
+
return {
|
|
500
|
+
wallets: (response.wallets || []).map(wallet => ({
|
|
501
|
+
id: wallet._id,
|
|
502
|
+
memberId: wallet.memberId,
|
|
503
|
+
memberName: wallet.memberName,
|
|
504
|
+
walletType: wallet.walletType,
|
|
505
|
+
walletAddress: wallet.walletAddress,
|
|
506
|
+
label: wallet.label,
|
|
507
|
+
verified: wallet.verified || false,
|
|
508
|
+
verifiedAt: wallet.verifiedAt,
|
|
509
|
+
createdAt: wallet.createdAt,
|
|
510
|
+
})),
|
|
511
|
+
total: response.total || (response.wallets || []).length,
|
|
512
|
+
};
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
|
|
516
|
+
{
|
|
517
|
+
name: 'l4yercak3_benefits_link_wallet',
|
|
518
|
+
description: `Link a crypto wallet to a member for receiving commission payouts.`,
|
|
519
|
+
inputSchema: {
|
|
520
|
+
type: 'object',
|
|
521
|
+
properties: {
|
|
522
|
+
memberId: {
|
|
523
|
+
type: 'string',
|
|
524
|
+
description: 'Member ID to link wallet to',
|
|
525
|
+
},
|
|
526
|
+
walletType: {
|
|
527
|
+
type: 'string',
|
|
528
|
+
enum: ['ethereum', 'bitcoin', 'solana', 'polygon', 'other'],
|
|
529
|
+
description: 'Wallet network type',
|
|
530
|
+
},
|
|
531
|
+
walletAddress: {
|
|
532
|
+
type: 'string',
|
|
533
|
+
description: 'Wallet address',
|
|
534
|
+
},
|
|
535
|
+
label: {
|
|
536
|
+
type: 'string',
|
|
537
|
+
description: 'Optional label for the wallet (e.g., "Primary ETH Wallet")',
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
required: ['memberId', 'walletType', 'walletAddress'],
|
|
541
|
+
},
|
|
542
|
+
requiresAuth: true,
|
|
543
|
+
requiredPermissions: ['benefits:write'],
|
|
544
|
+
handler: async (params, authContext) => {
|
|
545
|
+
const response = await backendClient.request('POST', '/api/v1/benefits/wallets', {
|
|
546
|
+
organizationId: authContext.organizationId,
|
|
547
|
+
memberId: params.memberId,
|
|
548
|
+
walletType: params.walletType,
|
|
549
|
+
walletAddress: params.walletAddress,
|
|
550
|
+
label: params.label,
|
|
551
|
+
source: 'mcp',
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
return {
|
|
555
|
+
success: true,
|
|
556
|
+
walletId: response.walletId || response._id,
|
|
557
|
+
verified: false,
|
|
558
|
+
message: 'Wallet linked successfully. Verification may be required.',
|
|
559
|
+
};
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
|
|
563
|
+
{
|
|
564
|
+
name: 'l4yercak3_benefits_verify_wallet',
|
|
565
|
+
description: `Verify a member's linked wallet.`,
|
|
566
|
+
inputSchema: {
|
|
567
|
+
type: 'object',
|
|
568
|
+
properties: {
|
|
569
|
+
walletId: {
|
|
570
|
+
type: 'string',
|
|
571
|
+
description: 'Wallet ID to verify',
|
|
572
|
+
},
|
|
573
|
+
verificationSignature: {
|
|
574
|
+
type: 'string',
|
|
575
|
+
description: 'Signature proving wallet ownership (if required)',
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
required: ['walletId'],
|
|
579
|
+
},
|
|
580
|
+
requiresAuth: true,
|
|
581
|
+
requiredPermissions: ['benefits:write'],
|
|
582
|
+
handler: async (params, _authContext) => {
|
|
583
|
+
await backendClient.request(
|
|
584
|
+
'POST',
|
|
585
|
+
`/api/v1/benefits/wallets/${params.walletId}/verify`,
|
|
586
|
+
{
|
|
587
|
+
verificationSignature: params.verificationSignature,
|
|
588
|
+
}
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
return {
|
|
592
|
+
success: true,
|
|
593
|
+
walletId: params.walletId,
|
|
594
|
+
verified: true,
|
|
595
|
+
message: 'Wallet verified successfully',
|
|
596
|
+
};
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
|
|
600
|
+
{
|
|
601
|
+
name: 'l4yercak3_benefits_remove_wallet',
|
|
602
|
+
description: `Remove a linked wallet from a member.`,
|
|
603
|
+
inputSchema: {
|
|
604
|
+
type: 'object',
|
|
605
|
+
properties: {
|
|
606
|
+
walletId: {
|
|
607
|
+
type: 'string',
|
|
608
|
+
description: 'Wallet ID to remove',
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
required: ['walletId'],
|
|
612
|
+
},
|
|
613
|
+
requiresAuth: true,
|
|
614
|
+
requiredPermissions: ['benefits:write'],
|
|
615
|
+
handler: async (params, _authContext) => {
|
|
616
|
+
await backendClient.request('DELETE', `/api/v1/benefits/wallets/${params.walletId}`);
|
|
617
|
+
|
|
618
|
+
return {
|
|
619
|
+
success: true,
|
|
620
|
+
message: 'Wallet removed successfully',
|
|
621
|
+
};
|
|
622
|
+
},
|
|
623
|
+
},
|
|
624
|
+
|
|
625
|
+
// ========================================
|
|
626
|
+
// Platform Fee Tools
|
|
627
|
+
// ========================================
|
|
628
|
+
{
|
|
629
|
+
name: 'l4yercak3_benefits_list_fees',
|
|
630
|
+
description: `List platform fees for the organization.
|
|
631
|
+
Use this to view fee transactions for billing purposes.`,
|
|
632
|
+
inputSchema: {
|
|
633
|
+
type: 'object',
|
|
634
|
+
properties: {
|
|
635
|
+
feeType: {
|
|
636
|
+
type: 'string',
|
|
637
|
+
description: 'Filter by fee type (e.g., transaction, subscription, processing)',
|
|
638
|
+
},
|
|
639
|
+
status: {
|
|
640
|
+
type: 'string',
|
|
641
|
+
enum: ['pending', 'collected', 'waived', 'refunded'],
|
|
642
|
+
description: 'Filter by fee status',
|
|
643
|
+
},
|
|
644
|
+
startDate: {
|
|
645
|
+
type: 'string',
|
|
646
|
+
description: 'Start date for date range filter (ISO format)',
|
|
647
|
+
},
|
|
648
|
+
endDate: {
|
|
649
|
+
type: 'string',
|
|
650
|
+
description: 'End date for date range filter (ISO format)',
|
|
651
|
+
},
|
|
652
|
+
limit: {
|
|
653
|
+
type: 'number',
|
|
654
|
+
description: 'Max fees to return (default 50)',
|
|
655
|
+
},
|
|
656
|
+
offset: {
|
|
657
|
+
type: 'number',
|
|
658
|
+
description: 'Offset for pagination',
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
requiresAuth: true,
|
|
663
|
+
requiredPermissions: ['benefits:read'],
|
|
664
|
+
handler: async (params, authContext) => {
|
|
665
|
+
const queryParams = new URLSearchParams();
|
|
666
|
+
queryParams.set('organizationId', authContext.organizationId);
|
|
667
|
+
if (params.feeType) queryParams.set('feeType', params.feeType);
|
|
668
|
+
if (params.status) queryParams.set('status', params.status);
|
|
669
|
+
if (params.startDate) queryParams.set('startDate', params.startDate);
|
|
670
|
+
if (params.endDate) queryParams.set('endDate', params.endDate);
|
|
671
|
+
if (params.limit) queryParams.set('limit', Math.min(params.limit, 100));
|
|
672
|
+
if (params.offset) queryParams.set('offset', params.offset);
|
|
673
|
+
|
|
674
|
+
const response = await backendClient.request(
|
|
675
|
+
'GET',
|
|
676
|
+
`/api/v1/benefits/fees?${queryParams.toString()}`
|
|
677
|
+
);
|
|
678
|
+
|
|
679
|
+
return {
|
|
680
|
+
fees: (response.fees || []).map(fee => ({
|
|
681
|
+
id: fee._id,
|
|
682
|
+
feeType: fee.feeType,
|
|
683
|
+
amount: fee.amount,
|
|
684
|
+
currency: fee.currency || 'EUR',
|
|
685
|
+
status: fee.status,
|
|
686
|
+
sourceTransaction: fee.sourceTransaction,
|
|
687
|
+
description: fee.description,
|
|
688
|
+
createdAt: fee.createdAt,
|
|
689
|
+
collectedAt: fee.collectedAt,
|
|
690
|
+
})),
|
|
691
|
+
total: response.total || (response.fees || []).length,
|
|
692
|
+
summary: response.summary || {
|
|
693
|
+
totalPending: 0,
|
|
694
|
+
totalCollected: 0,
|
|
695
|
+
},
|
|
696
|
+
hasMore: response.hasMore || false,
|
|
697
|
+
};
|
|
698
|
+
},
|
|
699
|
+
},
|
|
700
|
+
|
|
701
|
+
{
|
|
702
|
+
name: 'l4yercak3_benefits_get_fee_summary',
|
|
703
|
+
description: `Get a summary of platform fees for a period.`,
|
|
704
|
+
inputSchema: {
|
|
705
|
+
type: 'object',
|
|
706
|
+
properties: {
|
|
707
|
+
period: {
|
|
708
|
+
type: 'string',
|
|
709
|
+
enum: ['day', 'week', 'month', 'quarter', 'year'],
|
|
710
|
+
description: 'Period for the summary (default: month)',
|
|
711
|
+
},
|
|
712
|
+
startDate: {
|
|
713
|
+
type: 'string',
|
|
714
|
+
description: 'Custom start date (ISO format)',
|
|
715
|
+
},
|
|
716
|
+
endDate: {
|
|
717
|
+
type: 'string',
|
|
718
|
+
description: 'Custom end date (ISO format)',
|
|
719
|
+
},
|
|
720
|
+
},
|
|
721
|
+
},
|
|
722
|
+
requiresAuth: true,
|
|
723
|
+
requiredPermissions: ['benefits:read'],
|
|
724
|
+
handler: async (params, authContext) => {
|
|
725
|
+
const queryParams = new URLSearchParams();
|
|
726
|
+
queryParams.set('organizationId', authContext.organizationId);
|
|
727
|
+
if (params.period) queryParams.set('period', params.period);
|
|
728
|
+
if (params.startDate) queryParams.set('startDate', params.startDate);
|
|
729
|
+
if (params.endDate) queryParams.set('endDate', params.endDate);
|
|
730
|
+
|
|
731
|
+
const response = await backendClient.request(
|
|
732
|
+
'GET',
|
|
733
|
+
`/api/v1/benefits/fees/summary?${queryParams.toString()}`
|
|
734
|
+
);
|
|
735
|
+
|
|
736
|
+
return {
|
|
737
|
+
period: params.period || 'month',
|
|
738
|
+
startDate: response.startDate,
|
|
739
|
+
endDate: response.endDate,
|
|
740
|
+
totalFees: response.totalFees || 0,
|
|
741
|
+
feesByType: response.feesByType || {},
|
|
742
|
+
feesByStatus: response.feesByStatus || {},
|
|
743
|
+
currency: response.currency || 'EUR',
|
|
744
|
+
transactionCount: response.transactionCount || 0,
|
|
745
|
+
};
|
|
746
|
+
},
|
|
747
|
+
},
|
|
748
|
+
|
|
749
|
+
// ========================================
|
|
750
|
+
// Member Benefits Summary
|
|
751
|
+
// ========================================
|
|
752
|
+
{
|
|
753
|
+
name: 'l4yercak3_benefits_get_member_summary',
|
|
754
|
+
description: `Get a summary of benefits for a specific member.
|
|
755
|
+
Shows claims, commissions, and wallet information.`,
|
|
756
|
+
inputSchema: {
|
|
757
|
+
type: 'object',
|
|
758
|
+
properties: {
|
|
759
|
+
memberId: {
|
|
760
|
+
type: 'string',
|
|
761
|
+
description: 'Member ID to get summary for',
|
|
762
|
+
},
|
|
763
|
+
},
|
|
764
|
+
required: ['memberId'],
|
|
765
|
+
},
|
|
766
|
+
requiresAuth: true,
|
|
767
|
+
requiredPermissions: ['benefits:read'],
|
|
768
|
+
handler: async (params, authContext) => {
|
|
769
|
+
const response = await backendClient.request(
|
|
770
|
+
'GET',
|
|
771
|
+
`/api/v1/benefits/members/${params.memberId}/summary?organizationId=${authContext.organizationId}`
|
|
772
|
+
);
|
|
773
|
+
|
|
774
|
+
return {
|
|
775
|
+
memberId: params.memberId,
|
|
776
|
+
memberName: response.memberName,
|
|
777
|
+
claims: {
|
|
778
|
+
total: response.claims?.total || 0,
|
|
779
|
+
pending: response.claims?.pending || 0,
|
|
780
|
+
approved: response.claims?.approved || 0,
|
|
781
|
+
totalAmount: response.claims?.totalAmount || 0,
|
|
782
|
+
},
|
|
783
|
+
commissions: {
|
|
784
|
+
total: response.commissions?.total || 0,
|
|
785
|
+
pending: response.commissions?.pending || 0,
|
|
786
|
+
paid: response.commissions?.paid || 0,
|
|
787
|
+
totalAmount: response.commissions?.totalAmount || 0,
|
|
788
|
+
},
|
|
789
|
+
wallets: {
|
|
790
|
+
linked: response.wallets?.linked || 0,
|
|
791
|
+
verified: response.wallets?.verified || 0,
|
|
792
|
+
},
|
|
793
|
+
currency: response.currency || 'EUR',
|
|
794
|
+
};
|
|
795
|
+
},
|
|
796
|
+
},
|
|
797
|
+
],
|
|
798
|
+
};
|