refacil-pay-mcp 1.0.0

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.
@@ -0,0 +1,1721 @@
1
+ // Tipos para herramientas MCP
2
+ import { z } from 'zod';
3
+ import axios from 'axios';
4
+ import { getAuthHeaders } from './auth.js';
5
+ import { appConfig } from '../config.js';
6
+ // Configuración de la API
7
+ const API_CONFIG = {
8
+ get baseUrl() {
9
+ return appConfig.baseUrl;
10
+ },
11
+ timeout: 30000
12
+ };
13
+ // Helper para asignar valores definidos (incluye null) sin mutar argumentos originales
14
+ function assignIfDefined(target, source, key) {
15
+ if (Object.prototype.hasOwnProperty.call(source, key) && source[key] !== undefined) {
16
+ target[key] = source[key];
17
+ }
18
+ }
19
+ // Función helper para hacer requests HTTP
20
+ // secretId puede venir del contexto de la request (HTTP mode) o undefined (STDIO mode)
21
+ async function makeApiRequest(method, endpoint, data, params, secretId) {
22
+ try {
23
+ // Obtener headers de autenticación según el tipo
24
+ const headers = await getAuthHeaders();
25
+ const url = `${API_CONFIG.baseUrl}${endpoint}`;
26
+ const config = {
27
+ method: method.toLowerCase(),
28
+ url,
29
+ headers,
30
+ timeout: API_CONFIG.timeout
31
+ };
32
+ if (params && Object.keys(params).length > 0) {
33
+ config.params = params;
34
+ }
35
+ if (data && method !== 'GET') {
36
+ config.data = data;
37
+ }
38
+ const response = await axios(config);
39
+ // Formato estándar del protocolo MCP
40
+ return {
41
+ content: [
42
+ {
43
+ type: 'text',
44
+ text: JSON.stringify({
45
+ success: true,
46
+ statusCode: response.status,
47
+ data: response.data,
48
+ message: 'Operación exitosa'
49
+ }, null, 2)
50
+ }
51
+ ]
52
+ };
53
+ }
54
+ catch (error) {
55
+ const errorData = {
56
+ success: false,
57
+ statusCode: error.response?.status || 500,
58
+ data: error.response?.data || null,
59
+ message: error.response?.data?.message || error.message || 'Error en la operación',
60
+ error: error.code || 'UNKNOWN_ERROR'
61
+ };
62
+ // Formato estándar del protocolo MCP para errores
63
+ return {
64
+ content: [
65
+ {
66
+ type: 'text',
67
+ text: JSON.stringify(errorData, null, 2)
68
+ }
69
+ ],
70
+ isError: true
71
+ };
72
+ }
73
+ }
74
+ const auth_loginInputJsonSchema = {
75
+ "type": "object",
76
+ "properties": {
77
+ "username": {
78
+ "type": "string",
79
+ "description": "Campo del body: username",
80
+ "default": "{{username}}"
81
+ },
82
+ "password": {
83
+ "type": "string",
84
+ "description": "Campo del body: password",
85
+ "default": "{{secretKey}}"
86
+ }
87
+ },
88
+ "required": []
89
+ };
90
+ const auth_loginInputShape = {
91
+ username: z.string().optional().describe("Campo del body: username"),
92
+ password: z.string().optional().describe("Campo del body: password")
93
+ };
94
+ const auth_loginInputValidator = z.object(auth_loginInputShape);
95
+ // Herramienta: auth_login
96
+ export const auth_loginTool = {
97
+ name: 'auth_login',
98
+ description: "| **Name** | **Type** | **Description** |\\n| --- | --- | --- |\\n| **username** \\\\* | string | User |\\n| **password** \\\\* | string | Password |\n\nContexto: Endpoint: POST /auth/login | Autenticación > Auth > Login | Uso: Genera un token JWT usando las credenciales configuradas en el MCP",
99
+ inputSchema: auth_loginInputShape,
100
+ jsonSchema: auth_loginInputJsonSchema,
101
+ endpoint: '/auth/login',
102
+ method: 'POST',
103
+ parameters: [],
104
+ headers: [{ "key": "Content-Type", "value": "application/json" }],
105
+ handler: async (rawArgs) => {
106
+ try {
107
+ const normalizedArgs = rawArgs ?? {};
108
+ // Extraer secretId del contexto (si viene del HTTP mode)
109
+ const secretId = normalizedArgs._secretId;
110
+ // Remover _secretId de los args antes de validar
111
+ const { _secretId, ...argsToValidate } = normalizedArgs;
112
+ const validatedInput = validateToolInput(auth_loginInputValidator, argsToValidate);
113
+ const args = validatedInput;
114
+ const bodyData = {};
115
+ const usernameValue = args.username !== undefined ? args.username : "{{username}}";
116
+ if (usernameValue !== undefined)
117
+ bodyData.username = usernameValue;
118
+ const passwordValue = args.password !== undefined ? args.password : "{{secretKey}}";
119
+ if (passwordValue !== undefined)
120
+ bodyData.password = passwordValue;
121
+ return await makeApiRequest('POST', '/auth/login', bodyData, undefined, secretId);
122
+ }
123
+ catch (error) {
124
+ // Formato estándar del protocolo MCP para errores
125
+ return {
126
+ content: [
127
+ {
128
+ type: 'text',
129
+ text: JSON.stringify({
130
+ success: false,
131
+ statusCode: 500,
132
+ data: null,
133
+ message: error instanceof Error ? error.message : 'Error desconocido',
134
+ error: 'HANDLER_ERROR'
135
+ }, null, 2)
136
+ }
137
+ ],
138
+ isError: true
139
+ };
140
+ }
141
+ }
142
+ };
143
+ const trx_token_generateInputJsonSchema = {
144
+ "type": "object",
145
+ "properties": {
146
+ "service": {
147
+ "type": "string",
148
+ "description": "Campo del body: service",
149
+ "default": "/cash-in/generate/payment-link/token"
150
+ }
151
+ },
152
+ "required": []
153
+ };
154
+ const trx_token_generateInputShape = {
155
+ service: z.string().optional().describe("Campo del body: service")
156
+ };
157
+ const trx_token_generateInputValidator = z.object(trx_token_generateInputShape);
158
+ // Herramienta: trx_token_generate
159
+ export const trx_token_generateTool = {
160
+ name: 'trx_token_generate',
161
+ description: "| **Name** | **Type** | **Description** |\\n| --- | --- | --- |\\n| **service** \\\\* | string | Value of the service to be consumed |\n\nContexto: Endpoint: POST /trx-token/generate | Trx token > Generate",
162
+ inputSchema: trx_token_generateInputShape,
163
+ jsonSchema: trx_token_generateInputJsonSchema,
164
+ endpoint: '/trx-token/generate',
165
+ method: 'POST',
166
+ parameters: [],
167
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }],
168
+ handler: async (rawArgs) => {
169
+ try {
170
+ const normalizedArgs = rawArgs ?? {};
171
+ // Extraer secretId del contexto (si viene del HTTP mode)
172
+ const secretId = normalizedArgs._secretId;
173
+ // Remover _secretId de los args antes de validar
174
+ const { _secretId, ...argsToValidate } = normalizedArgs;
175
+ const validatedInput = validateToolInput(trx_token_generateInputValidator, argsToValidate);
176
+ const args = validatedInput;
177
+ const bodyData = {};
178
+ const serviceValue = args.service !== undefined ? args.service : "/cash-in/generate/payment-link/token";
179
+ if (serviceValue !== undefined)
180
+ bodyData.service = serviceValue;
181
+ return await makeApiRequest('POST', '/trx-token/generate', bodyData, undefined, secretId);
182
+ }
183
+ catch (error) {
184
+ // Formato estándar del protocolo MCP para errores
185
+ return {
186
+ content: [
187
+ {
188
+ type: 'text',
189
+ text: JSON.stringify({
190
+ success: false,
191
+ statusCode: 500,
192
+ data: null,
193
+ message: error instanceof Error ? error.message : 'Error desconocido',
194
+ error: 'HANDLER_ERROR'
195
+ }, null, 2)
196
+ }
197
+ ],
198
+ isError: true
199
+ };
200
+ }
201
+ }
202
+ };
203
+ const trx_token_generate_3InputJsonSchema = {
204
+ "type": "object",
205
+ "properties": {
206
+ "service": {
207
+ "type": "string",
208
+ "description": "Campo del body: service",
209
+ "default": "/cash-in/payment-method/token"
210
+ }
211
+ },
212
+ "required": []
213
+ };
214
+ const trx_token_generate_3InputShape = {
215
+ service: z.string().optional().describe("Campo del body: service")
216
+ };
217
+ const trx_token_generate_3InputValidator = z.object(trx_token_generate_3InputShape);
218
+ // Herramienta: trx_token_generate_3
219
+ export const trx_token_generate_3Tool = {
220
+ name: 'trx_token_generate_3',
221
+ description: "| **Name** | **Type** | **Description** |\\n| --- | --- | --- |\\n| **service** \\\\* | string | Value of the service to be consumed |\n\nContexto: Endpoint: POST /trx-token/generate | Trx token > Generate",
222
+ inputSchema: trx_token_generate_3InputShape,
223
+ jsonSchema: trx_token_generate_3InputJsonSchema,
224
+ endpoint: '/trx-token/generate',
225
+ method: 'POST',
226
+ parameters: [],
227
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }],
228
+ handler: async (rawArgs) => {
229
+ try {
230
+ const normalizedArgs = rawArgs ?? {};
231
+ // Extraer secretId del contexto (si viene del HTTP mode)
232
+ const secretId = normalizedArgs._secretId;
233
+ // Remover _secretId de los args antes de validar
234
+ const { _secretId, ...argsToValidate } = normalizedArgs;
235
+ const validatedInput = validateToolInput(trx_token_generate_3InputValidator, argsToValidate);
236
+ const args = validatedInput;
237
+ const bodyData = {};
238
+ const serviceValue = args.service !== undefined ? args.service : "/cash-in/payment-method/token";
239
+ if (serviceValue !== undefined)
240
+ bodyData.service = serviceValue;
241
+ return await makeApiRequest('POST', '/trx-token/generate', bodyData, undefined, secretId);
242
+ }
243
+ catch (error) {
244
+ // Formato estándar del protocolo MCP para errores
245
+ return {
246
+ content: [
247
+ {
248
+ type: 'text',
249
+ text: JSON.stringify({
250
+ success: false,
251
+ statusCode: 500,
252
+ data: null,
253
+ message: error instanceof Error ? error.message : 'Error desconocido',
254
+ error: 'HANDLER_ERROR'
255
+ }, null, 2)
256
+ }
257
+ ],
258
+ isError: true
259
+ };
260
+ }
261
+ }
262
+ };
263
+ const trx_token_generate_4InputJsonSchema = {
264
+ "type": "object",
265
+ "properties": {
266
+ "service": {
267
+ "type": "string",
268
+ "description": "Campo del body: service",
269
+ "default": "/cash-out/generate/withdraw-method/token"
270
+ }
271
+ },
272
+ "required": []
273
+ };
274
+ const trx_token_generate_4InputShape = {
275
+ service: z.string().optional().describe("Campo del body: service")
276
+ };
277
+ const trx_token_generate_4InputValidator = z.object(trx_token_generate_4InputShape);
278
+ // Herramienta: trx_token_generate_4
279
+ export const trx_token_generate_4Tool = {
280
+ name: 'trx_token_generate_4',
281
+ description: "| **Name** | **Type** | **Description** |\\n| --- | --- | --- |\\n| **service** \\\\* | string | Value of the service to be consumed |\n\nContexto: Endpoint: POST /trx-token/generate | Trx token > Generate",
282
+ inputSchema: trx_token_generate_4InputShape,
283
+ jsonSchema: trx_token_generate_4InputJsonSchema,
284
+ endpoint: '/trx-token/generate',
285
+ method: 'POST',
286
+ parameters: [],
287
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }],
288
+ handler: async (rawArgs) => {
289
+ try {
290
+ const normalizedArgs = rawArgs ?? {};
291
+ // Extraer secretId del contexto (si viene del HTTP mode)
292
+ const secretId = normalizedArgs._secretId;
293
+ // Remover _secretId de los args antes de validar
294
+ const { _secretId, ...argsToValidate } = normalizedArgs;
295
+ const validatedInput = validateToolInput(trx_token_generate_4InputValidator, argsToValidate);
296
+ const args = validatedInput;
297
+ const bodyData = {};
298
+ const serviceValue = args.service !== undefined ? args.service : "/cash-out/generate/withdraw-method/token";
299
+ if (serviceValue !== undefined)
300
+ bodyData.service = serviceValue;
301
+ return await makeApiRequest('POST', '/trx-token/generate', bodyData, undefined, secretId);
302
+ }
303
+ catch (error) {
304
+ // Formato estándar del protocolo MCP para errores
305
+ return {
306
+ content: [
307
+ {
308
+ type: 'text',
309
+ text: JSON.stringify({
310
+ success: false,
311
+ statusCode: 500,
312
+ data: null,
313
+ message: error instanceof Error ? error.message : 'Error desconocido',
314
+ error: 'HANDLER_ERROR'
315
+ }, null, 2)
316
+ }
317
+ ],
318
+ isError: true
319
+ };
320
+ }
321
+ }
322
+ };
323
+ const trx_token_generate_5InputJsonSchema = {
324
+ "type": "object",
325
+ "properties": {
326
+ "service": {
327
+ "type": "string",
328
+ "description": "Campo del body: service",
329
+ "default": "/merchant-key/create"
330
+ }
331
+ },
332
+ "required": []
333
+ };
334
+ const trx_token_generate_5InputShape = {
335
+ service: z.string().optional().describe("Campo del body: service")
336
+ };
337
+ const trx_token_generate_5InputValidator = z.object(trx_token_generate_5InputShape);
338
+ // Herramienta: trx_token_generate_5
339
+ export const trx_token_generate_5Tool = {
340
+ name: 'trx_token_generate_5',
341
+ description: "| **Name** | **Type** | **Description** |\\n| --- | --- | --- |\\n| **service** \\\\* | string | Value of the service to be consumed |\n\nContexto: Endpoint: POST /trx-token/generate | Trx token > Generate",
342
+ inputSchema: trx_token_generate_5InputShape,
343
+ jsonSchema: trx_token_generate_5InputJsonSchema,
344
+ endpoint: '/trx-token/generate',
345
+ method: 'POST',
346
+ parameters: [],
347
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }],
348
+ handler: async (rawArgs) => {
349
+ try {
350
+ const normalizedArgs = rawArgs ?? {};
351
+ // Extraer secretId del contexto (si viene del HTTP mode)
352
+ const secretId = normalizedArgs._secretId;
353
+ // Remover _secretId de los args antes de validar
354
+ const { _secretId, ...argsToValidate } = normalizedArgs;
355
+ const validatedInput = validateToolInput(trx_token_generate_5InputValidator, argsToValidate);
356
+ const args = validatedInput;
357
+ const bodyData = {};
358
+ const serviceValue = args.service !== undefined ? args.service : "/merchant-key/create";
359
+ if (serviceValue !== undefined)
360
+ bodyData.service = serviceValue;
361
+ return await makeApiRequest('POST', '/trx-token/generate', bodyData, undefined, secretId);
362
+ }
363
+ catch (error) {
364
+ // Formato estándar del protocolo MCP para errores
365
+ return {
366
+ content: [
367
+ {
368
+ type: 'text',
369
+ text: JSON.stringify({
370
+ success: false,
371
+ statusCode: 500,
372
+ data: null,
373
+ message: error instanceof Error ? error.message : 'Error desconocido',
374
+ error: 'HANDLER_ERROR'
375
+ }, null, 2)
376
+ }
377
+ ],
378
+ isError: true
379
+ };
380
+ }
381
+ }
382
+ };
383
+ const trx_token_generate_6InputJsonSchema = {
384
+ "type": "object",
385
+ "properties": {
386
+ "service": {
387
+ "type": "string",
388
+ "description": "Campo del body: service",
389
+ "default": "/merchant-key/cancel"
390
+ }
391
+ },
392
+ "required": []
393
+ };
394
+ const trx_token_generate_6InputShape = {
395
+ service: z.string().optional().describe("Campo del body: service")
396
+ };
397
+ const trx_token_generate_6InputValidator = z.object(trx_token_generate_6InputShape);
398
+ // Herramienta: trx_token_generate_6
399
+ export const trx_token_generate_6Tool = {
400
+ name: 'trx_token_generate_6',
401
+ description: "| **Name** | **Type** | **Description** |\\n| --- | --- | --- |\\n| **service** \\\\* | string | Value of the service to be consumed |\n\nContexto: Endpoint: POST /trx-token/generate | Trx token > Generate",
402
+ inputSchema: trx_token_generate_6InputShape,
403
+ jsonSchema: trx_token_generate_6InputJsonSchema,
404
+ endpoint: '/trx-token/generate',
405
+ method: 'POST',
406
+ parameters: [],
407
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }],
408
+ handler: async (rawArgs) => {
409
+ try {
410
+ const normalizedArgs = rawArgs ?? {};
411
+ // Extraer secretId del contexto (si viene del HTTP mode)
412
+ const secretId = normalizedArgs._secretId;
413
+ // Remover _secretId de los args antes de validar
414
+ const { _secretId, ...argsToValidate } = normalizedArgs;
415
+ const validatedInput = validateToolInput(trx_token_generate_6InputValidator, argsToValidate);
416
+ const args = validatedInput;
417
+ const bodyData = {};
418
+ const serviceValue = args.service !== undefined ? args.service : "/merchant-key/cancel";
419
+ if (serviceValue !== undefined)
420
+ bodyData.service = serviceValue;
421
+ return await makeApiRequest('POST', '/trx-token/generate', bodyData, undefined, secretId);
422
+ }
423
+ catch (error) {
424
+ // Formato estándar del protocolo MCP para errores
425
+ return {
426
+ content: [
427
+ {
428
+ type: 'text',
429
+ text: JSON.stringify({
430
+ success: false,
431
+ statusCode: 500,
432
+ data: null,
433
+ message: error instanceof Error ? error.message : 'Error desconocido',
434
+ error: 'HANDLER_ERROR'
435
+ }, null, 2)
436
+ }
437
+ ],
438
+ isError: true
439
+ };
440
+ }
441
+ }
442
+ };
443
+ const cash_in_generate_payment_link_tokenInputJsonSchema = {
444
+ "type": "object",
445
+ "properties": {
446
+ "expiresIn": {
447
+ "type": "number",
448
+ "description": "Campo del body: expiresIn",
449
+ "default": 12360
450
+ },
451
+ "amount": {
452
+ "type": "number",
453
+ "description": "Campo del body: amount",
454
+ "default": 2000
455
+ },
456
+ "brandId": {
457
+ "type": "number",
458
+ "description": "Campo del body: brandId",
459
+ "default": 117
460
+ },
461
+ "webhookUrl": {
462
+ "type": "string",
463
+ "description": "Campo del body: webhookUrl",
464
+ "default": "https://webhook.site/8965aa0a-e3e7-4092-aa7d-6c44bf63f7a8"
465
+ },
466
+ "userMetadata": {
467
+ "type": "object",
468
+ "description": "Campo del body: userMetadata",
469
+ "default": {
470
+ "ip": "1.2.3.2",
471
+ "identifier": "123467hyujikolpñmnaafsddssd",
472
+ "urlCommerce": "https://url-tucomercio.com"
473
+ }
474
+ },
475
+ "returnUrl": {
476
+ "type": "string",
477
+ "description": "Campo del body: returnUrl",
478
+ "default": "https://www.google.com"
479
+ },
480
+ "reference1": {
481
+ "type": "string",
482
+ "description": "Campo del body: reference1",
483
+ "default": "Ref01350"
484
+ },
485
+ "reference2": {
486
+ "type": "object",
487
+ "description": "Campo del body: reference2",
488
+ "default": {
489
+ "Label": {
490
+ "Name": "Juanita Perez",
491
+ "Email": "pqacLO87V77DgF62P8PXENA==do",
492
+ "CellPhone": "1VM6daPPJcXCD4Cw93272oQ==8",
493
+ "Type Person": "NATURAL",
494
+ "Type Document": "CEDULA",
495
+ "DocumentNumber": 79706920,
496
+ "Nodo": 47474
497
+ },
498
+ "Data": {
499
+ "Typedoc": "cedula",
500
+ "docnum": "1088307172"
501
+ }
502
+ }
503
+ }
504
+ },
505
+ "required": []
506
+ };
507
+ const cash_in_generate_payment_link_tokenInputShape = {
508
+ expiresIn: z.number().optional().describe("Campo del body: expiresIn"),
509
+ amount: z.number().optional().describe("Campo del body: amount"),
510
+ brandId: z.number().optional().describe("Campo del body: brandId"),
511
+ webhookUrl: z.string().optional().describe("Campo del body: webhookUrl"),
512
+ userMetadata: z.record(z.any()).optional().describe("Campo del body: userMetadata"),
513
+ returnUrl: z.string().optional().describe("Campo del body: returnUrl"),
514
+ reference1: z.string().optional().describe("Campo del body: reference1"),
515
+ reference2: z.record(z.any()).optional().describe("Campo del body: reference2")
516
+ };
517
+ const cash_in_generate_payment_link_tokenInputValidator = z.object(cash_in_generate_payment_link_tokenInputShape);
518
+ // Herramienta: cash_in_generate_payment_link_token
519
+ export const cash_in_generate_payment_link_tokenTool = {
520
+ name: 'cash_in_generate_payment_link_token',
521
+ description: "## 📥 Request Body Parameters\\n\\n| **Field** | **Type** | **Required** | **Description** |\\n| --- | --- | --- | --- |\\n| \\`amount\\` | number | ✅ | Value of the payment. |\\n| \\`brandId\\` | number | ❌ | ID of the customer\\'s white label; if one is not available, the default ID 79 is sent. |\\n| \\`expiresIn\\` | number | ❌ | Time in minutes for the expiration of the resource or payment link. |\\n| \\`reference1\\` | string | ✅ | Customer identifier, must be between 1 and 30 characters. |\\n| \\`reference2\\` | object | ❌ | Object for additional information. |\\n| \\`reference2.Commerce\\` | object | ❌ | Object for information related to the store or commerce. |\\n| \\`reference2.Data\\` | object | ❌ | Object for information related to the conciliation of the transaction. |\\n| \\`reference2.Label\\` | object | ❌ | Object to send information to be displayed in the payment summary. |\\n| \\`returnUrl\\` | string | ❌ | Link that the customer will see when clicking on the back to commerce button. |\\n| \\`showSummary\\` | boolean | ❌ | Indicates whether the RefácilPay payment summary will be shown or not (false: do not show, true: show). Default: true. |\\n| \\`userMetadata\\` | object | ✅ | Object containing key details about the user or merchant generating the payment resource. |\\n| \\`userMetadata.identifier\\` | string | ✅ | Unique identifier of the user or merchant generating the payment resource (max 36 characters). |\\n| \\`userMetadata.ip\\` | string | ✅ | IP address associated with the user\\'s identifier. Must be a valid IP address. |\\n| \\`userMetadata.urlCommerce\\` | string | ✅ | URL that identifies the commerce. Must follow valid URL structure with http:// or https:// protocol. Maximum length: 500 characters. |\\n| \\`webhookUrl\\` | string | ✅ | URL of the client\\'s webhook to receive real-time payment status updates. |\\n\n\nContexto: Endpoint: POST /cash-in/generate/payment-link/token | Cash in > Generate > Payment link > Token",
522
+ inputSchema: cash_in_generate_payment_link_tokenInputShape,
523
+ jsonSchema: cash_in_generate_payment_link_tokenInputJsonSchema,
524
+ endpoint: '/cash-in/generate/payment-link/token',
525
+ method: 'POST',
526
+ parameters: [],
527
+ headers: [{ "key": "Content-Type", "value": "application/json" }, { "key": "x-transaction-token", "value": "{{transactionalToken}}" }, { "key": "Authorization", "value": "Bearer {{tokenLogin}}" }],
528
+ handler: async (rawArgs) => {
529
+ try {
530
+ const normalizedArgs = rawArgs ?? {};
531
+ // Extraer secretId del contexto (si viene del HTTP mode)
532
+ const secretId = normalizedArgs._secretId;
533
+ // Remover _secretId de los args antes de validar
534
+ const { _secretId, ...argsToValidate } = normalizedArgs;
535
+ const validatedInput = validateToolInput(cash_in_generate_payment_link_tokenInputValidator, argsToValidate);
536
+ const args = validatedInput;
537
+ const bodyData = {};
538
+ const expiresInValue = args.expiresIn !== undefined ? args.expiresIn : 12360;
539
+ if (expiresInValue !== undefined)
540
+ bodyData.expiresIn = expiresInValue;
541
+ const amountValue = args.amount !== undefined ? args.amount : 2000;
542
+ if (amountValue !== undefined)
543
+ bodyData.amount = amountValue;
544
+ const brandIdValue = args.brandId !== undefined ? args.brandId : 117;
545
+ if (brandIdValue !== undefined)
546
+ bodyData.brandId = brandIdValue;
547
+ const webhookUrlValue = args.webhookUrl !== undefined ? args.webhookUrl : "https://webhook.site/8965aa0a-e3e7-4092-aa7d-6c44bf63f7a8";
548
+ if (webhookUrlValue !== undefined)
549
+ bodyData.webhookUrl = webhookUrlValue;
550
+ const userMetadataValue = args.userMetadata !== undefined ? args.userMetadata : { "ip": "1.2.3.2", "identifier": "123467hyujikolpñmnaafsddssd", "urlCommerce": "https://url-tucomercio.com" };
551
+ if (userMetadataValue !== undefined)
552
+ bodyData.userMetadata = userMetadataValue;
553
+ const returnUrlValue = args.returnUrl !== undefined ? args.returnUrl : "https://www.google.com";
554
+ if (returnUrlValue !== undefined)
555
+ bodyData.returnUrl = returnUrlValue;
556
+ const reference1Value = args.reference1 !== undefined ? args.reference1 : "Ref01350";
557
+ if (reference1Value !== undefined)
558
+ bodyData.reference1 = reference1Value;
559
+ const reference2Value = args.reference2 !== undefined ? args.reference2 : { "Label": { "Name": "Juanita Perez", "Email": "pqacLO87V77DgF62P8PXENA==do", "CellPhone": "1VM6daPPJcXCD4Cw93272oQ==8", "Type Person": "NATURAL", "Type Document": "CEDULA", "DocumentNumber": 79706920, "Nodo": 47474 }, "Data": { "Typedoc": "cedula", "docnum": "1088307172" } };
560
+ if (reference2Value !== undefined)
561
+ bodyData.reference2 = reference2Value;
562
+ return await makeApiRequest('POST', '/cash-in/generate/payment-link/token', bodyData, undefined, secretId);
563
+ }
564
+ catch (error) {
565
+ // Formato estándar del protocolo MCP para errores
566
+ return {
567
+ content: [
568
+ {
569
+ type: 'text',
570
+ text: JSON.stringify({
571
+ success: false,
572
+ statusCode: 500,
573
+ data: null,
574
+ message: error instanceof Error ? error.message : 'Error desconocido',
575
+ error: 'HANDLER_ERROR'
576
+ }, null, 2)
577
+ }
578
+ ],
579
+ isError: true
580
+ };
581
+ }
582
+ }
583
+ };
584
+ const cash_in_generate_payment_method_tokenInputJsonSchema = {
585
+ "type": "object",
586
+ "properties": {
587
+ "expiresIn": {
588
+ "type": "number",
589
+ "description": "Campo del body: expiresIn",
590
+ "default": 0
591
+ },
592
+ "paymentMethod": {
593
+ "type": "object",
594
+ "description": "Campo del body: paymentMethod",
595
+ "default": {
596
+ "id": 155,
597
+ "cellphone": "3051000002"
598
+ }
599
+ },
600
+ "userMetadata": {
601
+ "type": "object",
602
+ "description": "Campo del body: userMetadata",
603
+ "default": {
604
+ "ip": "1.2.3.2",
605
+ "identifier": "123467hyujikolpñmnaafsddssd",
606
+ "urlCommerce": "https://url-tucomercio.com"
607
+ }
608
+ },
609
+ "amount": {
610
+ "type": "number",
611
+ "description": "Campo del body: amount",
612
+ "default": 10000
613
+ },
614
+ "brandId": {
615
+ "type": "number",
616
+ "description": "Campo del body: brandId",
617
+ "default": 1
618
+ },
619
+ "webhookUrl": {
620
+ "type": "string",
621
+ "description": "Campo del body: webhookUrl",
622
+ "default": "https://webhook.site/271888cd-bd07-469a-88a8-e0ed7e93c368"
623
+ },
624
+ "returnUrl": {
625
+ "type": "string",
626
+ "description": "Campo del body: returnUrl",
627
+ "default": "https://www.google.com/?hl=es"
628
+ },
629
+ "showSummary": {
630
+ "type": "boolean",
631
+ "description": "Campo del body: showSummary",
632
+ "default": true
633
+ },
634
+ "reference1": {
635
+ "type": "string",
636
+ "description": "Campo del body: reference1",
637
+ "default": "EGfbOsiYQspMpgDD"
638
+ },
639
+ "reference2": {
640
+ "type": "object",
641
+ "description": "Campo del body: reference2",
642
+ "default": {
643
+ "Label": {
644
+ "Campos": "string"
645
+ }
646
+ }
647
+ }
648
+ },
649
+ "required": []
650
+ };
651
+ const cash_in_generate_payment_method_tokenInputShape = {
652
+ expiresIn: z.number().optional().describe("Campo del body: expiresIn"),
653
+ paymentMethod: z.record(z.any()).optional().describe("Campo del body: paymentMethod"),
654
+ userMetadata: z.record(z.any()).optional().describe("Campo del body: userMetadata"),
655
+ amount: z.number().optional().describe("Campo del body: amount"),
656
+ brandId: z.number().optional().describe("Campo del body: brandId"),
657
+ webhookUrl: z.string().optional().describe("Campo del body: webhookUrl"),
658
+ returnUrl: z.string().optional().describe("Campo del body: returnUrl"),
659
+ showSummary: z.boolean().optional().describe("Campo del body: showSummary"),
660
+ reference1: z.string().optional().describe("Campo del body: reference1"),
661
+ reference2: z.record(z.any()).optional().describe("Campo del body: reference2")
662
+ };
663
+ const cash_in_generate_payment_method_tokenInputValidator = z.object(cash_in_generate_payment_method_tokenInputShape);
664
+ // Herramienta: cash_in_generate_payment_method_token
665
+ export const cash_in_generate_payment_method_tokenTool = {
666
+ name: 'cash_in_generate_payment_method_token',
667
+ description: "This endpoint allows you to **generate payment requests** through the available _cash-in_ methods.\\n\\n---\\n\\n### 💡 Overview\\n\\nThe table below lists the available payment methods along with their corresponding IDs and **minimum expiration times** (\\`expiresIn\\`) required when creating a payment request.\\n\\n| **Method ID** | **Description** | **Minimum Expiration (seconds)** |\\n| --- | --- | --- |\\n| \\`130\\` | Cash-in via **Nequi** | 43,200 |\\n| \\`131\\` | Cash-in via **Daviplata** | 43,200 |\\n| \\`133\\` | Cash-in via **PSE** | 1,800 |\\n| \\`262\\` | Cash-in via **PSE Gateway** | 1,800 |\\n| \\`134\\` | Cash-in via **IPay** | 43,200 |\\n| \\`153\\` | Cash-in via **Recaudo Efectivo** | 86,400 |\\n| \\`155\\` | Cash-in via **Transfiya Recaudo** | 43,200 |\\n| \\`163\\` | Cash-in via **TPaga** | 43,200 |\\n| \\`248\\` | Cash-in via **QR Interoperable** | N/A |\\n\\n> ⚠ **Important:** \\nThe value provided in the \\`expiresIn\\` field **must be greater than or equal** to the minimum expiration defined for the selected payment method. \\n \\n\\n---\\n\\n## 🧩 Payment Method Details\\n\\nEach payment method requires a specific object structure within the \\`\\\"paymentMethod\\\"\\` field.\\n\\n---\\n\\n### **Nequi**\\n\\n\\`\\`\\` json\\n\\\"paymentMethod\\\": {\\n \\\"id\\\": 130,\\n \\\"cellphone\\\": \\\"3105293225\\\"\\n}\\n\\n \\`\\`\\`\\n\\n---\\n\\n### **Daviplata**\\n\\n\\`\\`\\` json\\n\\\"paymentMethod\\\": {\\n \\\"id\\\": 131,\\n \\\"cellphone\\\": \\\"3208385715\\\"\\n}\\n\\n \\`\\`\\`\\n\\n---\\n\\n### **PSE**\\n\\nFor this payment method, depending on the \\`typePerson\\` selected, only specific document types are accepted:\\n\\n- **\\`typePerson\\`****:** **\\`\\\"0\\\"\\`** → corresponds to a **Natural Person** and only accepts the following values for \\`documentType\\`:\\n \\n - \\`RCN\\`\\n \\n - \\`TI\\`\\n \\n - \\`CC\\`\\n \\n - \\`TE\\`\\n \\n - \\`CE\\`\\n \\n - \\`PA\\`\\n \\n - \\`DIE\\`\\n \\n- **\\`typePerson\\`****:** **\\`\\\"1\\\"\\`** → corresponds to a **Legal Person** and only accepts the following value for \\`documentType\\`:\\n \\n - \\`NIT\\`\\n \\n\\n\\`\\`\\` json\\n\\\"paymentMethod\\\": {\\n \\\"id\\\": 133,\\n \\\"documentType\\\": \\\"CC\\\",\\n \\\"typePerson\\\": \\\"0\\\",\\n \\\"bankId\\\": \\\"string\\\",\\n \\\"documentNumber\\\": \\\"string\\\",\\n \\\"name\\\": \\\"string\\\",\\n \\\"cellphone\\\": \\\"string\\\",\\n \\\"address\\\": \\\"string\\\",\\n \\\"email\\\": \\\"string\\\"\\n}\\n\\n \\`\\`\\`\\n\\n---\\n\\n### **PSE Gateway**\\n\\nThis payment method enables direct integration with the PSE network for processing online bank payments. \\nTo consume this product, it is required to have the following parameters previously configured and associated with your product:\\n\\n- \\`entity_code\\`\\n \\n- \\`service_code\\`\\n \\n- \\`company_ciiu\\`\\n \\n- \\`company_name\\`\\n \\n\\nThese parameters identify your company within the PSE network and are necessary for successful transaction routing and validation.\\n\\n> 💬 **For more information or to request these credentials, please contact the support team.** \\n \\n\\nThis method follows **the same structure and validation rules** as **PSE**, but must use the following identifier:\\n\\n\\`\\`\\` json\\n\\\"paymentMethod\\\": {\\n \\\"id\\\": 262,\\n \\\"documentType\\\": \\\"CC\\\",\\n \\\"typePerson\\\": \\\"0\\\",\\n \\\"bankId\\\": \\\"string\\\",\\n \\\"documentNumber\\\": \\\"string\\\",\\n \\\"name\\\": \\\"string\\\",\\n \\\"cellphone\\\": \\\"string\\\",\\n \\\"address\\\": \\\"string\\\",\\n \\\"email\\\": \\\"string\\\"\\n}\\n\\n \\`\\`\\`\\n\\nThe **PSE integration** relies heavily on the correct configuration of the \\`showSummary\\` and \\`returnUrl\\` parameters. \\nThese parameters control the **user experience** and the **finalization flow** of the payment process.\\n\\n| Scenario | \\`showSummary\\` | \\`returnUrl\\` | Flow Description |\\n| --- | --- | --- | --- |\\n| **1\\\\. Standard Redirect (Default)** | \\`true\\` or not sent | ✅ Present | Displays a transaction summary screen with key payment details and retrieves the final transaction status. After the payment is completed, the user is redirected to the specified \\`returnUrl\\`. |\\n| **2\\\\. Without Transaction Summary Screen** | \\`false\\` | ✅ Present | Skips the transaction summary screen and redirects the user directly to the \\`returnUrl\\`. In this case, the merchant’s system must display the transaction summary on the destination page. |\\n\\n> ⚠️ **Note:** \\nFor **PSE** and **PSE Gateway**, it is **strongly recommended** to use \\`showSummary: true\\` along with a valid \\`returnUrl\\` to ensure a seamless customer experience and accurate transaction tracking. \\n \\n> 🔗 **See also:** \\n \\n\\n- [Transaction Summary](https://documenter.getpostman.com/view/35146358/2sA3QpDEFA#45e0d76a-fabd-442e-9b17-e2f6b8354ec5)\\n \\n- [Transaction Status](https://documenter.getpostman.com/view/35146358/2sA3QpDEFA#dd3ba9f5-1f10-4109-b59d-6e5aad5e3799)\\n \\n\\n---\\n\\n### **IPay**\\n\\n\\`\\`\\` json\\n\\\"paymentMethod\\\": {\\n \\\"id\\\": 134\\n}\\n\\n \\`\\`\\`\\n\\n---\\n\\n### **Recaudo Efectivo**\\n\\n\\`\\`\\` json\\n\\\"paymentMethod\\\": {\\n \\\"id\\\": 153\\n}\\n\\n \\`\\`\\`\\n\\n---\\n\\n### **Transfiya Recaudo**\\n\\n\\`\\`\\` json\\n\\\"paymentMethod\\\": {\\n \\\"id\\\": 155,\\n \\\"cellphone\\\": \\\"3105293225\\\"\\n}\\n\\n \\`\\`\\`\\n\\n---\\n\\n### **TPaga**\\n\\nThis payment method supports an optional parameter called \\`isQr\\`, which determines the type of resource returned in the \\`url\\` field:\\n\\n| **Value** | **Description** |\\n| --- | --- |\\n| \\`true\\` | The \\`url\\` field returns a link to a **QR code** displaying transaction details. |\\n| \\`false\\` | The \\`url\\` field returns a **deeplink** to open directly in the TPAGA wallet app. |\\n\\n> 🧠 **Behavior:** \\nIf \\`isQr\\` is not provided, the default behavior is equivalent to \\`isQr: false\\`. \\nTransactions can only be completed **from a mobile device**. \\nIf the request is made from a desktop or tablet, it is recommended to send \\`isQr: true\\` so the user can scan the QR from a mobile device. \\n \\n\\n\\`\\`\\` json\\n\\\"paymentMethod\\\": {\\n \\\"id\\\": 163,\\n \\\"isQr\\\": false\\n}\\n\\n \\`\\`\\`\\n\\n---\\n\\n### **QR Interoperable**\\n\\nFor this method, the following fields are **optional**:\\n\\n- \\`cellphone\\`\\n \\n- \\`documentNumber\\`\\n \\n- \\`documentType\\`\\n \\n- \\`merchantId\\`\\n \\n\\nThe service can function using only the payment method ID; however, providing these optional fields can **improve response time**. \\nYou may retrieve this data through the \\`enrollment-data\\` service in the [Merchant Enrollment](https://documenter.getpostman.com/view/35146358/2sA3QpDEFA#8c9f5a18-a19a-4b8f-baba-cd7501aa29a0) section.\\n\\n> ⚠ **Prerequisite:** \\nThe merchant must complete the **Merchant Enrollment** process before using this method. \\nSee the _Merchant Enrollment_ section for setup details. \\n \\n> 🔁 **Open Resource:** \\nThe **QR Interoperable** operates as an _open resource_, meaning the generated QR can be used multiple times by the same user. \\n \\n> ⚙️ **Technical Note — Dynamic QR Behavior:** \\nDynamic QR codes may be scanned multiple times due to current limitations in the Redeban system. \\nThis is **not** an error in our platform. \\n \\n\\n#### Behavior Details\\n\\n- Redeban does not automatically invalidate a dynamic QR after its first scan.\\n \\n- As a result, the same QR may generate multiple transaction records.\\n \\n\\n#### Recommendations\\n\\n- Implement **application-level validation** to detect multiple payments from the same QR code.\\n \\n- Monitor dynamic QR transactions and confirm status before marking payments as completed.\\n \\n- Inform end-users to verify the success of a transaction before rescanning.\\n \\n\\n#### Future Considerations\\n\\n- Redeban is evaluating support for **single-use dynamic QR control**.\\n \\n- Stay updated with interoperability provider announcements to adjust integrations accordingly.\\n \\n\\n\\`\\`\\` json\\n\\\"paymentMethod\\\": {\\n \\\"id\\\": 248,\\n \\\"cellphone\\\": \\\"string\\\",\\n \\\"documentType\\\": \\\"string\\\",\\n \\\"documentNumber\\\": \\\"string\\\",\\n \\\"merchantId\\\": \\\"string\\\"\\n}\\n\\n \\`\\`\\`\\n\\n---\\n\\n## 📥 Request Body Parameters\\n\\n| **Field** | **Type** | **Required** | **Description** |\\n| --- | --- | --- | --- |\\n| \\`amount\\` | number | ✅ | Value of the payment. |\\n| \\`brandId\\` | number | ❌ | ID of the customer\\'s white label; if one is not available, the default ID 79 is sent. |\\n| \\`expiresIn\\` | number | ❌ | Time in seconds for the expiration of the resource or payment link. |\\n| \\`paymentMethod\\` | object | ✅ | Object specifying the payment method and its details. |\\n| \\`paymentMethod.id\\` | number | ✅ | ID of the selected payment method (see available payment methods). |\\n| \\`reference1\\` | string | ✅ | Customer identifier, must be between 1 and 30 characters. |\\n| \\`reference2\\` | object | ❌ | Object for additional information. |\\n| \\`reference2.Commerce\\` | object | ❌ | Object for information related to the store or commerce. |\\n| \\`reference2.Data\\` | object | ❌ | Object for information related to the conciliation of the transaction. |\\n| \\`reference2.Label\\` | object | ❌ | Object to send information to be displayed in the payment summary. |\\n| \\`returnUrl\\` | string | ❌ | Link that the customer will see when clicking on the back to commerce button. |\\n| \\`showSummary\\` | boolean | ❌ | Indicates whether the RefácilPay payment summary will be shown or not (false: do not show, true: show). Default: true. |\\n| \\`userMetadata\\` | object | ✅ | Object containing key details about the user or merchant generating the payment resource. |\\n| \\`userMetadata.identifier\\` | string | ✅ | Unique identifier of the user or merchant generating the payment resource (max 36 characters). |\\n| \\`userMetadata.ip\\` | string | ✅ | IP address associated with the user\\'s identifier. Must be a valid IP address. |\\n| \\`userMetadata.urlCommerce\\` | string | ✅ | URL that identifies the commerce. Must follow valid URL structure with http:// or https:// protocol. Maximum length: 500 characters. |\\n| \\`webhookUrl\\` | string | ✅ | URL of the client\\'s webhook to receive real-time payment status updates. |\n\nContexto: Endpoint: POST /cash-in/generate/payment-method/token | Cash in > Generate > Payment method > Token",
668
+ inputSchema: cash_in_generate_payment_method_tokenInputShape,
669
+ jsonSchema: cash_in_generate_payment_method_tokenInputJsonSchema,
670
+ endpoint: '/cash-in/generate/payment-method/token',
671
+ method: 'POST',
672
+ parameters: [],
673
+ headers: [{ "key": "Content-Type", "value": "application/json" }, { "key": "x-transaction-token", "value": "{{transactionalToken}}" }, { "key": "Authorization", "value": "Bearer {{tokenLogin}}" }],
674
+ handler: async (rawArgs) => {
675
+ try {
676
+ const normalizedArgs = rawArgs ?? {};
677
+ // Extraer secretId del contexto (si viene del HTTP mode)
678
+ const secretId = normalizedArgs._secretId;
679
+ // Remover _secretId de los args antes de validar
680
+ const { _secretId, ...argsToValidate } = normalizedArgs;
681
+ const validatedInput = validateToolInput(cash_in_generate_payment_method_tokenInputValidator, argsToValidate);
682
+ const args = validatedInput;
683
+ const bodyData = {};
684
+ const expiresInValue = args.expiresIn !== undefined ? args.expiresIn : 0;
685
+ if (expiresInValue !== undefined)
686
+ bodyData.expiresIn = expiresInValue;
687
+ const paymentMethodValue = args.paymentMethod !== undefined ? args.paymentMethod : { "id": 155, "cellphone": "3051000002" };
688
+ if (paymentMethodValue !== undefined)
689
+ bodyData.paymentMethod = paymentMethodValue;
690
+ const userMetadataValue = args.userMetadata !== undefined ? args.userMetadata : { "ip": "1.2.3.2", "identifier": "123467hyujikolpñmnaafsddssd", "urlCommerce": "https://url-tucomercio.com" };
691
+ if (userMetadataValue !== undefined)
692
+ bodyData.userMetadata = userMetadataValue;
693
+ const amountValue = args.amount !== undefined ? args.amount : 10000;
694
+ if (amountValue !== undefined)
695
+ bodyData.amount = amountValue;
696
+ const brandIdValue = args.brandId !== undefined ? args.brandId : 1;
697
+ if (brandIdValue !== undefined)
698
+ bodyData.brandId = brandIdValue;
699
+ const webhookUrlValue = args.webhookUrl !== undefined ? args.webhookUrl : "https://webhook.site/271888cd-bd07-469a-88a8-e0ed7e93c368";
700
+ if (webhookUrlValue !== undefined)
701
+ bodyData.webhookUrl = webhookUrlValue;
702
+ const returnUrlValue = args.returnUrl !== undefined ? args.returnUrl : "https://www.google.com/?hl=es";
703
+ if (returnUrlValue !== undefined)
704
+ bodyData.returnUrl = returnUrlValue;
705
+ const showSummaryValue = args.showSummary !== undefined ? args.showSummary : true;
706
+ if (showSummaryValue !== undefined)
707
+ bodyData.showSummary = showSummaryValue;
708
+ const reference1Value = args.reference1 !== undefined ? args.reference1 : "EGfbOsiYQspMpgDD";
709
+ if (reference1Value !== undefined)
710
+ bodyData.reference1 = reference1Value;
711
+ const reference2Value = args.reference2 !== undefined ? args.reference2 : { "Label": { "Campos": "string" } };
712
+ if (reference2Value !== undefined)
713
+ bodyData.reference2 = reference2Value;
714
+ return await makeApiRequest('POST', '/cash-in/generate/payment-method/token', bodyData, undefined, secretId);
715
+ }
716
+ catch (error) {
717
+ // Formato estándar del protocolo MCP para errores
718
+ return {
719
+ content: [
720
+ {
721
+ type: 'text',
722
+ text: JSON.stringify({
723
+ success: false,
724
+ statusCode: 500,
725
+ data: null,
726
+ message: error instanceof Error ? error.message : 'Error desconocido',
727
+ error: 'HANDLER_ERROR'
728
+ }, null, 2)
729
+ }
730
+ ],
731
+ isError: true
732
+ };
733
+ }
734
+ }
735
+ };
736
+ const cash_out_generate_withdraw_method_tokenInputJsonSchema = {
737
+ "type": "object",
738
+ "properties": {
739
+ "amount": {
740
+ "type": "number",
741
+ "description": "Campo del body: amount",
742
+ "default": 1000
743
+ },
744
+ "reference1": {
745
+ "type": "string",
746
+ "description": "Campo del body: reference1",
747
+ "default": "EGfbOsiYQspMpgBd"
748
+ },
749
+ "bankName": {
750
+ "type": "string",
751
+ "description": "Campo del body: bankName",
752
+ "default": "Banco Rojo"
753
+ },
754
+ "webhookRequest": {
755
+ "type": "string",
756
+ "description": "Campo del body: webhookRequest",
757
+ "default": "https://****gerstg.azure-api.net/SkCo.PagosEnLinea.API/payonline/PostStatus"
758
+ },
759
+ "withdrawMethod": {
760
+ "type": "object",
761
+ "description": "Campo del body: withdrawMethod",
762
+ "default": {
763
+ "id": 245,
764
+ "cellphone": "3125763074"
765
+ }
766
+ },
767
+ "userMetadata": {
768
+ "type": "object",
769
+ "description": "Campo del body: userMetadata",
770
+ "default": {
771
+ "identifier": "1234567890",
772
+ "ip": "127.0.0.1",
773
+ "urlCommerce": "https://url-tucomercio.com"
774
+ }
775
+ }
776
+ },
777
+ "required": []
778
+ };
779
+ const cash_out_generate_withdraw_method_tokenInputShape = {
780
+ amount: z.number().optional().describe("Campo del body: amount"),
781
+ reference1: z.string().optional().describe("Campo del body: reference1"),
782
+ bankName: z.string().optional().describe("Campo del body: bankName"),
783
+ webhookRequest: z.string().optional().describe("Campo del body: webhookRequest"),
784
+ withdrawMethod: z.record(z.any()).optional().describe("Campo del body: withdrawMethod"),
785
+ userMetadata: z.record(z.any()).optional().describe("Campo del body: userMetadata")
786
+ };
787
+ const cash_out_generate_withdraw_method_tokenInputValidator = z.object(cash_out_generate_withdraw_method_tokenInputShape);
788
+ // Herramienta: cash_out_generate_withdraw_method_token
789
+ export const cash_out_generate_withdraw_method_tokenTool = {
790
+ name: 'cash_out_generate_withdraw_method_token',
791
+ description: "This endpoint allows you to **generate withdrawal (cash-out) requests** through the available payout methods.\\n\\n---\\n\\n### 💡 Overview\\n\\nThe table below lists the available payout methods along with their corresponding IDs and brief descriptions.\\n\\n| **Method ID** | **Description** |\\n| --- | --- |\\n| \\`245\\` | Cash-out via **Transfiya** |\\n| \\`264\\` | Cash-out via **Bre-B** |\\n\\n> ⚠ **Note:** \\nEach withdrawal method requires a specific object structure within the \\`\\\"withdrawMethod\\\"\\` field, as shown below. \\n \\n\\n---\\n\\n## 🧩 Payout Method Details\\n\\n### **Transfiya**\\n\\n\\`\\`\\` json\\n\\\"withdrawMethod\\\": {\\n \\\"id\\\": 245,\\n \\\"cellphone\\\": \\\"3125763074\\\"\\n}\\n\\n \\`\\`\\`\\n\\n**Description:** \\nTransfers funds to a recipient using their registered Transfiya cellphone number.\\n\\n> ⚠ **Important:** \\nEnsure the cellphone number is registered with Transfiya and capable of receiving funds. \\n \\n\\n---\\n\\n### **Bre-B**\\n\\n\\`\\`\\` json\\n\\\"withdrawMethod\\\": {\\n \\\"id\\\": 264,\\n \\\"key\\\": \\\"@REPRUEBAL7717\\\"\\n}\\n\\n \\`\\`\\`\\n\\n**Description:** \\nTransfers funds directly to a Bre-B account using the beneficiary’s unique Bre-B key.\\n\\n> 💡 **Tip:** \\nThe \\`key\\` field must contain a valid Bre-B account alias in the format \\`@USERNAME\\`. \\n \\n\\n---\\n\\n## 📥 Request Body Parameters\\n\\n| **Field** | **Type** | **Required** | **Description** |\\n| --- | --- | --- | --- |\\n| \\`amount\\` | number | ✅ | Amount to be withdrawn. |\\n| \\`reference1\\` | string | ✅ | Unique transaction reference generated by the client (max 20 characters). |\\n| \\`webhookRequest\\` | string | ✅ | Customer’s webhook URL to receive real-time withdrawal status updates. |\\n| \\`userMetadata\\` | object | ✅ | Object containing metadata related to the origin of the transaction. |\\n| \\`userMetadata.identifier\\` | string | ✅ | Identifier for the user or merchant initiating the transaction. |\\n| \\`userMetadata.ip\\` | string | ✅ | IP address from which the transaction was initiated. |\\n| \\`userMetadata.urlCommerce\\` | string | ✅ | Commerce or customer’s URL associated with the transaction. |\\n| \\`withdrawMethod\\` | object | ✅ | Object specifying the withdrawal method and destination details. |\\n| \\`withdrawMethod.id\\` | number | ✅ | ID of the selected payout method (see table above). |\\n| \\`withdrawMethod.cellphone\\` | string | Conditional | Required for **Transfiya** withdrawals. |\\n| \\`withdrawMethod.key\\` | string | Conditional | Required for **Bre-B** withdrawals. |\\n| \\`withdrawMethod.bankName\\` | string | ❌ | Optional bank name, if applicable for future payout methods. |\\n\\n---\n\nContexto: Endpoint: POST /cash-out/generate/withdraw-method/token | Cash out > Generate > Withdraw method > Token",
792
+ inputSchema: cash_out_generate_withdraw_method_tokenInputShape,
793
+ jsonSchema: cash_out_generate_withdraw_method_tokenInputJsonSchema,
794
+ endpoint: '/cash-out/generate/withdraw-method/token',
795
+ method: 'POST',
796
+ parameters: [],
797
+ headers: [{ "key": "Content-Type", "value": "application/json" }, { "key": "x-transaction-token", "value": "{{transactionalToken}}" }, { "key": "Authorization", "value": "Bearer {{tokenLogin}}" }],
798
+ handler: async (rawArgs) => {
799
+ try {
800
+ const normalizedArgs = rawArgs ?? {};
801
+ // Extraer secretId del contexto (si viene del HTTP mode)
802
+ const secretId = normalizedArgs._secretId;
803
+ // Remover _secretId de los args antes de validar
804
+ const { _secretId, ...argsToValidate } = normalizedArgs;
805
+ const validatedInput = validateToolInput(cash_out_generate_withdraw_method_tokenInputValidator, argsToValidate);
806
+ const args = validatedInput;
807
+ const bodyData = {};
808
+ const amountValue = args.amount !== undefined ? args.amount : 1000;
809
+ if (amountValue !== undefined)
810
+ bodyData.amount = amountValue;
811
+ const reference1Value = args.reference1 !== undefined ? args.reference1 : "EGfbOsiYQspMpgBd";
812
+ if (reference1Value !== undefined)
813
+ bodyData.reference1 = reference1Value;
814
+ const bankNameValue = args.bankName !== undefined ? args.bankName : "Banco Rojo";
815
+ if (bankNameValue !== undefined)
816
+ bodyData.bankName = bankNameValue;
817
+ const webhookRequestValue = args.webhookRequest !== undefined ? args.webhookRequest : "https://****gerstg.azure-api.net/SkCo.PagosEnLinea.API/payonline/PostStatus";
818
+ if (webhookRequestValue !== undefined)
819
+ bodyData.webhookRequest = webhookRequestValue;
820
+ const withdrawMethodValue = args.withdrawMethod !== undefined ? args.withdrawMethod : { "id": 245, "cellphone": "3125763074" };
821
+ if (withdrawMethodValue !== undefined)
822
+ bodyData.withdrawMethod = withdrawMethodValue;
823
+ const userMetadataValue = args.userMetadata !== undefined ? args.userMetadata : { "identifier": "1234567890", "ip": "127.0.0.1", "urlCommerce": "https://url-tucomercio.com" };
824
+ if (userMetadataValue !== undefined)
825
+ bodyData.userMetadata = userMetadataValue;
826
+ return await makeApiRequest('POST', '/cash-out/generate/withdraw-method/token', bodyData, undefined, secretId);
827
+ }
828
+ catch (error) {
829
+ // Formato estándar del protocolo MCP para errores
830
+ return {
831
+ content: [
832
+ {
833
+ type: 'text',
834
+ text: JSON.stringify({
835
+ success: false,
836
+ statusCode: 500,
837
+ data: null,
838
+ message: error instanceof Error ? error.message : 'Error desconocido',
839
+ error: 'HANDLER_ERROR'
840
+ }, null, 2)
841
+ }
842
+ ],
843
+ isError: true
844
+ };
845
+ }
846
+ }
847
+ };
848
+ const customer_getbalanceInputJsonSchema = {
849
+ "type": "object",
850
+ "properties": {
851
+ "userId": {
852
+ "type": "number",
853
+ "description": "Campo del body: userId",
854
+ "default": 1085718
855
+ }
856
+ },
857
+ "required": []
858
+ };
859
+ const customer_getbalanceInputShape = {
860
+ userId: z.number().optional().describe("Campo del body: userId")
861
+ };
862
+ const customer_getbalanceInputValidator = z.object(customer_getbalanceInputShape);
863
+ // Herramienta: customer_getbalance
864
+ export const customer_getbalanceTool = {
865
+ name: 'customer_getbalance',
866
+ description: "This service allows you to consult the balance exchange and the dispersion exchange associated with the client\\'s identifier.\\n\\n> To use the service, an authentication token is required, which must be sent as an Authorization header. \\n \\n\\nHeaders\\n\\n| **Name** | **Value** |\\n| --- | --- |\\n| Content-Type | application/json |\\n| Authorization | Bearer |\\n\\nBody\\n\\n| Name | Type | Description |\\n| --- | --- | --- |\\n| \\`userId\\`\\\\* | number | Integrated unique user identifier |\n\nContexto: Endpoint: POST /customer/getBalance | Customer > GetBalance",
867
+ inputSchema: customer_getbalanceInputShape,
868
+ jsonSchema: customer_getbalanceInputJsonSchema,
869
+ endpoint: '/customer/getBalance',
870
+ method: 'POST',
871
+ parameters: [],
872
+ headers: [{ "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Bearer {{tokenLogin}}" }],
873
+ handler: async (rawArgs) => {
874
+ try {
875
+ const normalizedArgs = rawArgs ?? {};
876
+ // Extraer secretId del contexto (si viene del HTTP mode)
877
+ const secretId = normalizedArgs._secretId;
878
+ // Remover _secretId de los args antes de validar
879
+ const { _secretId, ...argsToValidate } = normalizedArgs;
880
+ const validatedInput = validateToolInput(customer_getbalanceInputValidator, argsToValidate);
881
+ const args = validatedInput;
882
+ const bodyData = {};
883
+ const userIdValue = args.userId !== undefined ? args.userId : 1085718;
884
+ if (userIdValue !== undefined)
885
+ bodyData.userId = userIdValue;
886
+ return await makeApiRequest('POST', '/customer/getBalance', bodyData, undefined, secretId);
887
+ }
888
+ catch (error) {
889
+ // Formato estándar del protocolo MCP para errores
890
+ return {
891
+ content: [
892
+ {
893
+ type: 'text',
894
+ text: JSON.stringify({
895
+ success: false,
896
+ statusCode: 500,
897
+ data: null,
898
+ message: error instanceof Error ? error.message : 'Error desconocido',
899
+ error: 'HANDLER_ERROR'
900
+ }, null, 2)
901
+ }
902
+ ],
903
+ isError: true
904
+ };
905
+ }
906
+ }
907
+ };
908
+ const payment_transfiya_banksInputJsonSchema = {
909
+ "type": "object",
910
+ "properties": {
911
+ "cellphone": {
912
+ "type": "string",
913
+ "description": "Campo del body: cellphone",
914
+ "default": "3051000002"
915
+ }
916
+ },
917
+ "required": []
918
+ };
919
+ const payment_transfiya_banksInputShape = {
920
+ cellphone: z.string().optional().describe("Campo del body: cellphone")
921
+ };
922
+ const payment_transfiya_banksInputValidator = z.object(payment_transfiya_banksInputShape);
923
+ // Herramienta: payment_transfiya_banks
924
+ export const payment_transfiya_banksTool = {
925
+ name: 'payment_transfiya_banks',
926
+ description: "This service allows you to consult the balance exchange and the dispersion exchange associated with the client\\'s identifier.\\n\\n> To use the service, an authentication token is required, which must be sent as an Authorization header. \\n \\n\\nHeaders\\n\\n| **Name** | **Value** |\\n| --- | --- |\\n| Content-Type | application/json |\\n| Authorization | Bearer |\\n\\nBody\\n\\n| Name | Type | Description |\\n| --- | --- | --- |\\n| \\`cellphone\\`\\\\* | number | The cell phone number to be used to consult the list of banks. |\n\nContexto: Endpoint: POST /payment/transfiya-banks | Payment > Transfiya banks",
927
+ inputSchema: payment_transfiya_banksInputShape,
928
+ jsonSchema: payment_transfiya_banksInputJsonSchema,
929
+ endpoint: '/payment/transfiya-banks',
930
+ method: 'POST',
931
+ parameters: [],
932
+ headers: [{ "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Bearer {{tokenLogin}}" }],
933
+ handler: async (rawArgs) => {
934
+ try {
935
+ const normalizedArgs = rawArgs ?? {};
936
+ // Extraer secretId del contexto (si viene del HTTP mode)
937
+ const secretId = normalizedArgs._secretId;
938
+ // Remover _secretId de los args antes de validar
939
+ const { _secretId, ...argsToValidate } = normalizedArgs;
940
+ const validatedInput = validateToolInput(payment_transfiya_banksInputValidator, argsToValidate);
941
+ const args = validatedInput;
942
+ const bodyData = {};
943
+ const cellphoneValue = args.cellphone !== undefined ? args.cellphone : "3051000002";
944
+ if (cellphoneValue !== undefined)
945
+ bodyData.cellphone = cellphoneValue;
946
+ return await makeApiRequest('POST', '/payment/transfiya-banks', bodyData, undefined, secretId);
947
+ }
948
+ catch (error) {
949
+ // Formato estándar del protocolo MCP para errores
950
+ return {
951
+ content: [
952
+ {
953
+ type: 'text',
954
+ text: JSON.stringify({
955
+ success: false,
956
+ statusCode: 500,
957
+ data: null,
958
+ message: error instanceof Error ? error.message : 'Error desconocido',
959
+ error: 'HANDLER_ERROR'
960
+ }, null, 2)
961
+ }
962
+ ],
963
+ isError: true
964
+ };
965
+ }
966
+ }
967
+ };
968
+ const payment_statusInputJsonSchema = {
969
+ "type": "object",
970
+ "properties": {
971
+ "reference": {
972
+ "type": "string",
973
+ "description": "Campo del body: reference",
974
+ "default": "12442830-7afb-11ed-b265-b9457b46***3"
975
+ }
976
+ },
977
+ "required": []
978
+ };
979
+ const payment_statusInputShape = {
980
+ reference: z.string().optional().describe("Campo del body: reference")
981
+ };
982
+ const payment_statusInputValidator = z.object(payment_statusInputShape);
983
+ // Herramienta: payment_status
984
+ export const payment_statusTool = {
985
+ name: 'payment_status',
986
+ description: "This service allows you to check the status of a transaction made, for this you must have the _reference_ data that returned the response when generating any payment resource.\\n\\nIn the response you will get the _status_ _id_ which will mean the following\\n\\n0 - Transaction Rejected\\n\\n1 - Pending Transaction\\n\\n2 - Transaction Approved\\n\\n3 - Failed Transaction\\n\\n5 - Transaction Cancelled\\n\\n9 - Processing Transaction\\n\\nHeaders\\n\\n| **Name** | **Value** |\\n| --- | --- |\\n| Content-Type | application/json |\\n| Authorization | Bearer |\\n\\nBody\\n\\n| Name | Type | Description |\\n| --- | --- | --- |\\n| \\`reference\\`\\\\* | string | Product reference |\n\nContexto: Endpoint: POST /payment/status | Payment > Status",
987
+ inputSchema: payment_statusInputShape,
988
+ jsonSchema: payment_statusInputJsonSchema,
989
+ endpoint: '/payment/status',
990
+ method: 'POST',
991
+ parameters: [],
992
+ headers: [{ "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Bearer {{tokenLogin}}" }],
993
+ handler: async (rawArgs) => {
994
+ try {
995
+ const normalizedArgs = rawArgs ?? {};
996
+ // Extraer secretId del contexto (si viene del HTTP mode)
997
+ const secretId = normalizedArgs._secretId;
998
+ // Remover _secretId de los args antes de validar
999
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1000
+ const validatedInput = validateToolInput(payment_statusInputValidator, argsToValidate);
1001
+ const args = validatedInput;
1002
+ const bodyData = {};
1003
+ const referenceValue = args.reference !== undefined ? args.reference : "12442830-7afb-11ed-b265-b9457b46***3";
1004
+ if (referenceValue !== undefined)
1005
+ bodyData.reference = referenceValue;
1006
+ return await makeApiRequest('POST', '/payment/status', bodyData, undefined, secretId);
1007
+ }
1008
+ catch (error) {
1009
+ // Formato estándar del protocolo MCP para errores
1010
+ return {
1011
+ content: [
1012
+ {
1013
+ type: 'text',
1014
+ text: JSON.stringify({
1015
+ success: false,
1016
+ statusCode: 500,
1017
+ data: null,
1018
+ message: error instanceof Error ? error.message : 'Error desconocido',
1019
+ error: 'HANDLER_ERROR'
1020
+ }, null, 2)
1021
+ }
1022
+ ],
1023
+ isError: true
1024
+ };
1025
+ }
1026
+ }
1027
+ };
1028
+ const payment_customer_reference_statusInputJsonSchema = {
1029
+ "type": "object",
1030
+ "properties": {
1031
+ "customerReference": {
1032
+ "type": "string",
1033
+ "description": "Campo del body: customerReference",
1034
+ "default": "12442830-7afb-11ed-b265-b9457b46***3"
1035
+ }
1036
+ },
1037
+ "required": []
1038
+ };
1039
+ const payment_customer_reference_statusInputShape = {
1040
+ customerReference: z.string().optional().describe("Campo del body: customerReference")
1041
+ };
1042
+ const payment_customer_reference_statusInputValidator = z.object(payment_customer_reference_statusInputShape);
1043
+ // Herramienta: payment_customer_reference_status
1044
+ export const payment_customer_reference_statusTool = {
1045
+ name: 'payment_customer_reference_status',
1046
+ description: "## 🔍 Check Transaction by Customer Reference\\n\\nThis endpoint allows **API Pay** users to query the status of a transaction using only the \\`customerReference\\` value originally provided when generating a resource as \\`reference1\\` through any of the following endpoints:\\n\\n- \\`/cash-in/generate/payment-link/token\\`\\n \\n- \\`/cash-in/generate/payment-method/token\\`\\n \\n- \\`/cash-out/generate/withdraw-method/token\\`\\n \\n\\nThis service is useful for retrieving the internal **Refacil** transaction information associated with a previously submitted customer reference.\\n\\n---\\n\\n## 🔐 Authentication\\n\\nThis endpoint **requires** a valid Bearer Token in the request headers. Requests without valid authentication will be rejected with an \\`Unauthorized\\` error.\\n\\n## 📤 Successful Response\\n\\n- \\`exists\\`: \\`true\\` indicates that the transaction associated with the provided \\`customerReference\\` was found.\\n \\n- \\`id\\`: Internal Refacil transaction ID.\\n \\n- \\`status\\`: Transaction status code (see table below).\\n \\n- \\`reference\\`: Full Refacil transaction reference, which can be used to query \\`/payment/status\\`.\\n \\n\\n### ℹ️ Status Code Reference\\n\\n| Status Code | Meaning |\\n| --- | --- |\\n| \\`0\\` | Transaction Rejected |\\n| \\`1\\` | Transaction Pending |\\n| \\`2\\` | Transaction Approved |\\n| \\`3\\` | Transaction Failed |\\n| \\`5\\` | Transaction Cancelled |\\n| \\`9\\` | Transaction Processing |\\n\\n---\n\nContexto: Endpoint: POST /payment/customer-reference/status | Payment > Customer reference > Status",
1047
+ inputSchema: payment_customer_reference_statusInputShape,
1048
+ jsonSchema: payment_customer_reference_statusInputJsonSchema,
1049
+ endpoint: '/payment/customer-reference/status',
1050
+ method: 'POST',
1051
+ parameters: [],
1052
+ headers: [{ "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Bearer {{tokenLogin}}" }],
1053
+ handler: async (rawArgs) => {
1054
+ try {
1055
+ const normalizedArgs = rawArgs ?? {};
1056
+ // Extraer secretId del contexto (si viene del HTTP mode)
1057
+ const secretId = normalizedArgs._secretId;
1058
+ // Remover _secretId de los args antes de validar
1059
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1060
+ const validatedInput = validateToolInput(payment_customer_reference_statusInputValidator, argsToValidate);
1061
+ const args = validatedInput;
1062
+ const bodyData = {};
1063
+ const customerReferenceValue = args.customerReference !== undefined ? args.customerReference : "12442830-7afb-11ed-b265-b9457b46***3";
1064
+ if (customerReferenceValue !== undefined)
1065
+ bodyData.customerReference = customerReferenceValue;
1066
+ return await makeApiRequest('POST', '/payment/customer-reference/status', bodyData, undefined, secretId);
1067
+ }
1068
+ catch (error) {
1069
+ // Formato estándar del protocolo MCP para errores
1070
+ return {
1071
+ content: [
1072
+ {
1073
+ type: 'text',
1074
+ text: JSON.stringify({
1075
+ success: false,
1076
+ statusCode: 500,
1077
+ data: null,
1078
+ message: error instanceof Error ? error.message : 'Error desconocido',
1079
+ error: 'HANDLER_ERROR'
1080
+ }, null, 2)
1081
+ }
1082
+ ],
1083
+ isError: true
1084
+ };
1085
+ }
1086
+ }
1087
+ };
1088
+ const payment_featuresInputJsonSchema = {
1089
+ "type": "object",
1090
+ "properties": {
1091
+ "id": {
1092
+ "type": "number",
1093
+ "description": "Campo del body: id",
1094
+ "default": 133
1095
+ }
1096
+ },
1097
+ "required": []
1098
+ };
1099
+ const payment_featuresInputShape = {
1100
+ id: z.number().optional().describe("Campo del body: id")
1101
+ };
1102
+ const payment_featuresInputValidator = z.object(payment_featuresInputShape);
1103
+ // Herramienta: payment_features
1104
+ export const payment_featuresTool = {
1105
+ name: 'payment_features',
1106
+ description: "This service allows you to consult the necessary characteristics of a payment method to successfully generate a resource. For example, obtain the PSE banks\\n\\nHeaders\\n\\n| **Name** | **Value** |\\n| --- | --- |\\n| Content-Type | application/json |\\n| Authorization | Bearer |\\n\\nBody\\n\\n| Name | Type | Description |\\n| --- | --- | --- |\\n| \\`id\\`\\\\* | integer | Product identification |\n\nContexto: Endpoint: POST /payment/features | Payment > Features",
1107
+ inputSchema: payment_featuresInputShape,
1108
+ jsonSchema: payment_featuresInputJsonSchema,
1109
+ endpoint: '/payment/features',
1110
+ method: 'POST',
1111
+ parameters: [],
1112
+ headers: [{ "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Bearer {{tokenLogin}}" }],
1113
+ handler: async (rawArgs) => {
1114
+ try {
1115
+ const normalizedArgs = rawArgs ?? {};
1116
+ // Extraer secretId del contexto (si viene del HTTP mode)
1117
+ const secretId = normalizedArgs._secretId;
1118
+ // Remover _secretId de los args antes de validar
1119
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1120
+ const validatedInput = validateToolInput(payment_featuresInputValidator, argsToValidate);
1121
+ const args = validatedInput;
1122
+ const bodyData = {};
1123
+ const idValue = args.id !== undefined ? args.id : 133;
1124
+ if (idValue !== undefined)
1125
+ bodyData.id = idValue;
1126
+ return await makeApiRequest('POST', '/payment/features', bodyData, undefined, secretId);
1127
+ }
1128
+ catch (error) {
1129
+ // Formato estándar del protocolo MCP para errores
1130
+ return {
1131
+ content: [
1132
+ {
1133
+ type: 'text',
1134
+ text: JSON.stringify({
1135
+ success: false,
1136
+ statusCode: 500,
1137
+ data: null,
1138
+ message: error instanceof Error ? error.message : 'Error desconocido',
1139
+ error: 'HANDLER_ERROR'
1140
+ }, null, 2)
1141
+ }
1142
+ ],
1143
+ isError: true
1144
+ };
1145
+ }
1146
+ }
1147
+ };
1148
+ const webhook_notifyInputJsonSchema = {
1149
+ "type": "object",
1150
+ "properties": {
1151
+ "reference": {
1152
+ "type": "string",
1153
+ "description": "Campo del body: reference",
1154
+ "default": "12442830-7afb-11ed-b265-b9457b46***3"
1155
+ }
1156
+ },
1157
+ "required": []
1158
+ };
1159
+ const webhook_notifyInputShape = {
1160
+ reference: z.string().optional().describe("Campo del body: reference")
1161
+ };
1162
+ const webhook_notifyInputValidator = z.object(webhook_notifyInputShape);
1163
+ // Herramienta: webhook_notify
1164
+ export const webhook_notifyTool = {
1165
+ name: 'webhook_notify',
1166
+ description: "Body\\n\\n| Name | Type | Description |\\n| --- | --- | --- |\\n| amount\\\\* | Integer | Total transaction value |\\n| cost\\\\* | Integer | Transaction cost |\\n| Resource | Object | Object |\\n| id | Integer | Identifier of the payment resource |\\n| updatedAt | String | Date and time at which the transaction was processed |\\n| status\\\\* | Object | Transaction status identifier |\\n| transfiyaStatus | String | The TransfiYa status, see the details below |\\n| id\\\\* | String | Transaction status ID : 1 Pending , 2 Approved ,3 Failed |\\n| id \\\\* | Integer | transaction identifier |\\n| description | String | Status detail |\\n| Key | interger | Key |\\n| PaymentMethod | Object | Payment method |\\n| id | String | Method identifier |\\n| name | String | payment method name |\\n| type | String | method |\\n| extra | Object | Object |\\n| reference1\\\\* | String | Unique reference to the transaction provided when sending the request to generate the resource |\\n| reference2 | String | Allows to append extra information provided by the client |\\n| reference3 | String | Allows to append extra information provided by the customer |\\n| commerceId | String | Commerce identifier |\\n| createdAt | String | Date and time the transaction was created |\\n| signature | String | Signature generated for webhook notification |\\n| data | Object | Object with all data |\\n| Transaction | String | |\\n\\n\\n## TransfiYa Status\\n\\n| **transfiyaStatus** | Description |\\n| --- | --- |\\n| \\`CREATED\\` | Transfer is received and queued for processing. |\\n| \\`PENDING\\` | Transfer is valid and is waiting for the target to accept it. |\\n| \\`ACCEPTED\\` | Transfer has been accepted by the target, and payment is pending in the target bank. |\\n| \\`COMPLETED\\` | The payment is valid and completely processed, visible in the receiving bank account. |\\n| \\`REJECTED\\` | Payment was rejected. |\\n| \\`ERROR\\` | An error occurred during payment. |\\n\\n### Transfer state machine\\n\\n<img src=\\\"https://content.pstmn.io/89f89557-2e1b-44c2-8dcb-d9e7d2f32c54/aW1hZ2UucG5n\\\" width=\\\"293\\\" height=\\\"380\\\">\n\nContexto: Endpoint: POST /webhook/notify | Webhook > Notify",
1167
+ inputSchema: webhook_notifyInputShape,
1168
+ jsonSchema: webhook_notifyInputJsonSchema,
1169
+ endpoint: '/webhook/notify',
1170
+ method: 'POST',
1171
+ parameters: [],
1172
+ headers: [{ "key": "Content-Type", "value": "application/json" }, { "key": "Authorization", "value": "Bearer {{tokenLogin}}" }],
1173
+ handler: async (rawArgs) => {
1174
+ try {
1175
+ const normalizedArgs = rawArgs ?? {};
1176
+ // Extraer secretId del contexto (si viene del HTTP mode)
1177
+ const secretId = normalizedArgs._secretId;
1178
+ // Remover _secretId de los args antes de validar
1179
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1180
+ const validatedInput = validateToolInput(webhook_notifyInputValidator, argsToValidate);
1181
+ const args = validatedInput;
1182
+ const bodyData = {};
1183
+ const referenceValue = args.reference !== undefined ? args.reference : "12442830-7afb-11ed-b265-b9457b46***3";
1184
+ if (referenceValue !== undefined)
1185
+ bodyData.reference = referenceValue;
1186
+ return await makeApiRequest('POST', '/webhook/notify', bodyData, undefined, secretId);
1187
+ }
1188
+ catch (error) {
1189
+ // Formato estándar del protocolo MCP para errores
1190
+ return {
1191
+ content: [
1192
+ {
1193
+ type: 'text',
1194
+ text: JSON.stringify({
1195
+ success: false,
1196
+ statusCode: 500,
1197
+ data: null,
1198
+ message: error instanceof Error ? error.message : 'Error desconocido',
1199
+ error: 'HANDLER_ERROR'
1200
+ }, null, 2)
1201
+ }
1202
+ ],
1203
+ isError: true
1204
+ };
1205
+ }
1206
+ }
1207
+ };
1208
+ const merchant_enrollmentInputJsonSchema = {
1209
+ "type": "object",
1210
+ "properties": {},
1211
+ "required": []
1212
+ };
1213
+ const merchant_enrollmentInputShape = {};
1214
+ const merchant_enrollmentInputValidator = z.object(merchant_enrollmentInputShape);
1215
+ // Herramienta: merchant_enrollment
1216
+ export const merchant_enrollmentTool = {
1217
+ name: 'merchant_enrollment',
1218
+ description: "This endpoint initiates the merchant enrollment process required to use the QR interoperable payment method. Once the request is made, the enrollment process may take up to **7 minutes** to complete.\n\nContexto: Endpoint: GET /merchant/enrollment | Merchant > Enrollment",
1219
+ inputSchema: merchant_enrollmentInputShape,
1220
+ jsonSchema: merchant_enrollmentInputJsonSchema,
1221
+ endpoint: '/merchant/enrollment',
1222
+ method: 'GET',
1223
+ parameters: [],
1224
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }],
1225
+ handler: async (rawArgs) => {
1226
+ try {
1227
+ const normalizedArgs = rawArgs ?? {};
1228
+ // Extraer secretId del contexto (si viene del HTTP mode)
1229
+ const secretId = normalizedArgs._secretId;
1230
+ // Remover _secretId de los args antes de validar
1231
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1232
+ const validatedInput = validateToolInput(merchant_enrollmentInputValidator, argsToValidate);
1233
+ const args = validatedInput;
1234
+ return await makeApiRequest('GET', '/merchant/enrollment', undefined, undefined, secretId);
1235
+ }
1236
+ catch (error) {
1237
+ // Formato estándar del protocolo MCP para errores
1238
+ return {
1239
+ content: [
1240
+ {
1241
+ type: 'text',
1242
+ text: JSON.stringify({
1243
+ success: false,
1244
+ statusCode: 500,
1245
+ data: null,
1246
+ message: error instanceof Error ? error.message : 'Error desconocido',
1247
+ error: 'HANDLER_ERROR'
1248
+ }, null, 2)
1249
+ }
1250
+ ],
1251
+ isError: true
1252
+ };
1253
+ }
1254
+ }
1255
+ };
1256
+ const merchant_enrollment_dataInputJsonSchema = {
1257
+ "type": "object",
1258
+ "properties": {},
1259
+ "required": []
1260
+ };
1261
+ const merchant_enrollment_dataInputShape = {};
1262
+ const merchant_enrollment_dataInputValidator = z.object(merchant_enrollment_dataInputShape);
1263
+ // Herramienta: merchant_enrollment_data
1264
+ export const merchant_enrollment_dataTool = {
1265
+ name: 'merchant_enrollment_data',
1266
+ description: "This endpoint retrieves the merchant\\'s enrollment details after the enrollment process has been completed. It provides necessary information to use the QR interoperable payment method.\n\nContexto: Endpoint: GET /merchant/enrollment-data | Merchant > Enrollment data",
1267
+ inputSchema: merchant_enrollment_dataInputShape,
1268
+ jsonSchema: merchant_enrollment_dataInputJsonSchema,
1269
+ endpoint: '/merchant/enrollment-data',
1270
+ method: 'GET',
1271
+ parameters: [],
1272
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }],
1273
+ handler: async (rawArgs) => {
1274
+ try {
1275
+ const normalizedArgs = rawArgs ?? {};
1276
+ // Extraer secretId del contexto (si viene del HTTP mode)
1277
+ const secretId = normalizedArgs._secretId;
1278
+ // Remover _secretId de los args antes de validar
1279
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1280
+ const validatedInput = validateToolInput(merchant_enrollment_dataInputValidator, argsToValidate);
1281
+ const args = validatedInput;
1282
+ return await makeApiRequest('GET', '/merchant/enrollment-data', undefined, undefined, secretId);
1283
+ }
1284
+ catch (error) {
1285
+ // Formato estándar del protocolo MCP para errores
1286
+ return {
1287
+ content: [
1288
+ {
1289
+ type: 'text',
1290
+ text: JSON.stringify({
1291
+ success: false,
1292
+ statusCode: 500,
1293
+ data: null,
1294
+ message: error instanceof Error ? error.message : 'Error desconocido',
1295
+ error: 'HANDLER_ERROR'
1296
+ }, null, 2)
1297
+ }
1298
+ ],
1299
+ isError: true
1300
+ };
1301
+ }
1302
+ }
1303
+ };
1304
+ const merchant_key_createInputJsonSchema = {
1305
+ "type": "object",
1306
+ "properties": {
1307
+ "webhookUrl": {
1308
+ "type": "string",
1309
+ "description": "Campo del body: webhookUrl",
1310
+ "default": "https://mi-comercio.com/webhook"
1311
+ },
1312
+ "reference1": {
1313
+ "type": "string",
1314
+ "description": "Campo del body: reference1",
1315
+ "default": "Ref1053"
1316
+ },
1317
+ "reference2": {
1318
+ "type": "object",
1319
+ "description": "Campo del body: reference2",
1320
+ "default": {
1321
+ "Label": {
1322
+ "title": "Pago de servicios",
1323
+ "description": "Pago mensual de servicios básicos"
1324
+ },
1325
+ "Data": {
1326
+ "invoiceId": "INV-001",
1327
+ "customerId": "CUST-123"
1328
+ },
1329
+ "Commerce": {
1330
+ "name": "Mi Comercio",
1331
+ "category": "Servicios"
1332
+ }
1333
+ }
1334
+ },
1335
+ "userMetadata": {
1336
+ "type": "object",
1337
+ "description": "Campo del body: userMetadata",
1338
+ "default": {
1339
+ "identifier": "user-12345",
1340
+ "ip": "192.168.1.100",
1341
+ "urlCommerce": "https://mi-comercio.com"
1342
+ }
1343
+ },
1344
+ "typeKey": {
1345
+ "type": "string",
1346
+ "description": "Campo del body: typeKey",
1347
+ "default": "document"
1348
+ },
1349
+ "key": {
1350
+ "type": "string",
1351
+ "description": "Campo del body: key",
1352
+ "default": "15545216"
1353
+ },
1354
+ "otp": {
1355
+ "type": "string",
1356
+ "description": "Campo del body: otp",
1357
+ "default": "123456"
1358
+ },
1359
+ "termsAndConditions": {
1360
+ "type": "boolean",
1361
+ "description": "Campo del body: termsAndConditions",
1362
+ "default": true
1363
+ }
1364
+ },
1365
+ "required": []
1366
+ };
1367
+ const merchant_key_createInputShape = {
1368
+ webhookUrl: z.string().optional().describe("Campo del body: webhookUrl"),
1369
+ reference1: z.string().optional().describe("Campo del body: reference1"),
1370
+ reference2: z.record(z.any()).optional().describe("Campo del body: reference2"),
1371
+ userMetadata: z.record(z.any()).optional().describe("Campo del body: userMetadata"),
1372
+ typeKey: z.string().optional().describe("Campo del body: typeKey"),
1373
+ key: z.string().optional().describe("Campo del body: key"),
1374
+ otp: z.string().optional().describe("Campo del body: otp"),
1375
+ termsAndConditions: z.boolean().optional().describe("Campo del body: termsAndConditions")
1376
+ };
1377
+ const merchant_key_createInputValidator = z.object(merchant_key_createInputShape);
1378
+ // Herramienta: merchant_key_create
1379
+ export const merchant_key_createTool = {
1380
+ name: 'merchant_key_create',
1381
+ description: "This endpoint will allow you to create 4 types of keys: \\`alias\\`, \\`email\\`, \\`cellphone\\`, and \\`document\\`.\\n\\n⚠ **Important**:\\n\\n- **Alias key:** To generate this key, it is not necessary to send the \\`key\\` field and the \\`otp\\` field. A random key is generated from various parameters of the merchant user, beginning with the character @.\\n \\n- **Document key:** To generate this key, it is not necessary to send the \\`otp\\` field, and the key field must contain the document provided in the technical data sheet shared with the merchant.\\n \\n- **Email key:** To generate this key, you must first use the service that generates and sends the OTP to the \\`email\\` address. The key field must contain the \\`email\\` address provided in the technical data sheet.\\n \\n- **Cellphone key:** To generate this key, you must first use the service that generates and sends the OTP to the \\`cellphone\\`. The key field must contain the \\`cellphone\\` number provided in the technical data sheet.\\n \\n\\nHeaders\\n\\n| **Name** | **Value** |\\n| --- | --- |\\n| Content-Type | application/json |\\n| Authorization | Bearer |\\n| x-transaction-token | 9b48edde-652d-11ed-984e-02c840fe**** |\\n\\nBody\\n\\n| Name | Type | Description |\\n| --- | --- | --- |\\n| \\`webhookUrl\\`\\\\* | string | URL of the client\\'s webhook. |\\n| \\`userMetadata\\`\\\\* | object | Object containing key details about the user or merchant generating the payment resource. |\\n| \\`ip\\`\\\\* | string | Alphanumeric parameter that provides the IP address associated with the user\\'s identifier |\\n| \\`identifier\\`\\\\* | string | Alphanumeric parameter of 20 characters specifying the unique identifier of the user or merchant generating the payment resource. |\\n| \\`urlCommerce\\`\\\\* | string | URL that identifies the commerce. Must follow valid URL structure with http:// or https:// protocol. Maximum length: 500 characters. |\\n| \\`reference1\\`\\\\* | string | Customer identifier, must not exceed 20 characters. |\\n| \\`reference2\\` | object | Object for additional information. |\\n| \\`Label\\` | object | Object to send information to be displayed in the payment summary. |\\n| \\`Data\\` | object | Object for information related to the conciliation of the transaction. |\\n| \\`typeKey\\`\\\\* | string | Can be \\`alias\\`, \\`document\\`, \\`email\\`, and \\`cellphone\\` |\\n| \\`key\\` | string | Key to create |\\n| \\`otp\\` | string | OTP code for cellphone and email keys |\\n| \\`termsAndConditions\\`\\\\* | boolean | It must always be set to true. |\n\nContexto: Endpoint: POST /merchant-key/create | Merchant key > Create",
1382
+ inputSchema: merchant_key_createInputShape,
1383
+ jsonSchema: merchant_key_createInputJsonSchema,
1384
+ endpoint: '/merchant-key/create',
1385
+ method: 'POST',
1386
+ parameters: [],
1387
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }, { "key": "x-transaction-token", "value": "{{transactionalToken}}", "type": "text" }, { "key": "Content-Type", "value": "application/json", "type": "text" }],
1388
+ handler: async (rawArgs) => {
1389
+ try {
1390
+ const normalizedArgs = rawArgs ?? {};
1391
+ // Extraer secretId del contexto (si viene del HTTP mode)
1392
+ const secretId = normalizedArgs._secretId;
1393
+ // Remover _secretId de los args antes de validar
1394
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1395
+ const validatedInput = validateToolInput(merchant_key_createInputValidator, argsToValidate);
1396
+ const args = validatedInput;
1397
+ const bodyData = {};
1398
+ const webhookUrlValue = args.webhookUrl !== undefined ? args.webhookUrl : "https://mi-comercio.com/webhook";
1399
+ if (webhookUrlValue !== undefined)
1400
+ bodyData.webhookUrl = webhookUrlValue;
1401
+ const reference1Value = args.reference1 !== undefined ? args.reference1 : "Ref1053";
1402
+ if (reference1Value !== undefined)
1403
+ bodyData.reference1 = reference1Value;
1404
+ const reference2Value = args.reference2 !== undefined ? args.reference2 : { "Label": { "title": "Pago de servicios", "description": "Pago mensual de servicios básicos" }, "Data": { "invoiceId": "INV-001", "customerId": "CUST-123" }, "Commerce": { "name": "Mi Comercio", "category": "Servicios" } };
1405
+ if (reference2Value !== undefined)
1406
+ bodyData.reference2 = reference2Value;
1407
+ const userMetadataValue = args.userMetadata !== undefined ? args.userMetadata : { "identifier": "user-12345", "ip": "192.168.1.100", "urlCommerce": "https://mi-comercio.com" };
1408
+ if (userMetadataValue !== undefined)
1409
+ bodyData.userMetadata = userMetadataValue;
1410
+ const typeKeyValue = args.typeKey !== undefined ? args.typeKey : "document";
1411
+ if (typeKeyValue !== undefined)
1412
+ bodyData.typeKey = typeKeyValue;
1413
+ const keyValue = args.key !== undefined ? args.key : "15545216";
1414
+ if (keyValue !== undefined)
1415
+ bodyData.key = keyValue;
1416
+ const otpValue = args.otp !== undefined ? args.otp : "123456";
1417
+ if (otpValue !== undefined)
1418
+ bodyData.otp = otpValue;
1419
+ const termsAndConditionsValue = args.termsAndConditions !== undefined ? args.termsAndConditions : true;
1420
+ if (termsAndConditionsValue !== undefined)
1421
+ bodyData.termsAndConditions = termsAndConditionsValue;
1422
+ return await makeApiRequest('POST', '/merchant-key/create', bodyData, undefined, secretId);
1423
+ }
1424
+ catch (error) {
1425
+ // Formato estándar del protocolo MCP para errores
1426
+ return {
1427
+ content: [
1428
+ {
1429
+ type: 'text',
1430
+ text: JSON.stringify({
1431
+ success: false,
1432
+ statusCode: 500,
1433
+ data: null,
1434
+ message: error instanceof Error ? error.message : 'Error desconocido',
1435
+ error: 'HANDLER_ERROR'
1436
+ }, null, 2)
1437
+ }
1438
+ ],
1439
+ isError: true
1440
+ };
1441
+ }
1442
+ }
1443
+ };
1444
+ const merchant_key_cancelInputJsonSchema = {
1445
+ "type": "object",
1446
+ "properties": {
1447
+ "userMetadata": {
1448
+ "type": "object",
1449
+ "description": "Campo del body: userMetadata",
1450
+ "default": {
1451
+ "identifier": "user-12345",
1452
+ "ip": "192.168.1.100",
1453
+ "urlCommerce": "https://mi-comercio.com"
1454
+ }
1455
+ },
1456
+ "key": {
1457
+ "type": "string",
1458
+ "description": "Campo del body: key",
1459
+ "default": "15545216"
1460
+ }
1461
+ },
1462
+ "required": []
1463
+ };
1464
+ const merchant_key_cancelInputShape = {
1465
+ userMetadata: z.record(z.any()).optional().describe("Campo del body: userMetadata"),
1466
+ key: z.string().optional().describe("Campo del body: key")
1467
+ };
1468
+ const merchant_key_cancelInputValidator = z.object(merchant_key_cancelInputShape);
1469
+ // Herramienta: merchant_key_cancel
1470
+ export const merchant_key_cancelTool = {
1471
+ name: 'merchant_key_cancel',
1472
+ description: "This endpoint allows you to cancel an existing key, which will then become inactive and unable to receive transactions.\\n\\nHeaders\\n\\n| **Name** | **Value** |\\n| --- | --- |\\n| Content-Type | application/json |\\n| Authorization | Bearer |\\n| x-transaction-token | 9b48edde-652d-11ed-984e-02c840fe**** |\\n\\nBody\\n\\n| Name | Type | Description |\\n| --- | --- | --- |\\n| \\`userMetadata\\`\\\\* | object | Object containing key details about the user or merchant generating the payment resource. |\\n| \\`ip\\`\\\\* | string | Alphanumeric parameter that provides the IP address associated with the user\\'s identifier |\\n| \\`identifier\\`\\\\* | string | Alphanumeric parameter of 20 characters specifying the unique identifier of the user or merchant generating the payment resource. |\\n| \\`urlCommerce\\`\\\\* | string | URL that identifies the commerce. Must follow valid URL structure with http:// or https:// protocol. Maximum length: 500 characters. |\\n| \\`key\\` | string | Key to cancel |\n\nContexto: Endpoint: POST /merchant-key/cancel | Merchant key > Cancel",
1473
+ inputSchema: merchant_key_cancelInputShape,
1474
+ jsonSchema: merchant_key_cancelInputJsonSchema,
1475
+ endpoint: '/merchant-key/cancel',
1476
+ method: 'POST',
1477
+ parameters: [],
1478
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }, { "key": "x-transaction-token", "value": "{{transactionalToken}}", "type": "text" }, { "key": "Content-Type", "value": "application/json", "type": "text" }],
1479
+ handler: async (rawArgs) => {
1480
+ try {
1481
+ const normalizedArgs = rawArgs ?? {};
1482
+ // Extraer secretId del contexto (si viene del HTTP mode)
1483
+ const secretId = normalizedArgs._secretId;
1484
+ // Remover _secretId de los args antes de validar
1485
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1486
+ const validatedInput = validateToolInput(merchant_key_cancelInputValidator, argsToValidate);
1487
+ const args = validatedInput;
1488
+ const bodyData = {};
1489
+ const userMetadataValue = args.userMetadata !== undefined ? args.userMetadata : { "identifier": "user-12345", "ip": "192.168.1.100", "urlCommerce": "https://mi-comercio.com" };
1490
+ if (userMetadataValue !== undefined)
1491
+ bodyData.userMetadata = userMetadataValue;
1492
+ const keyValue = args.key !== undefined ? args.key : "15545216";
1493
+ if (keyValue !== undefined)
1494
+ bodyData.key = keyValue;
1495
+ return await makeApiRequest('POST', '/merchant-key/cancel', bodyData, undefined, secretId);
1496
+ }
1497
+ catch (error) {
1498
+ // Formato estándar del protocolo MCP para errores
1499
+ return {
1500
+ content: [
1501
+ {
1502
+ type: 'text',
1503
+ text: JSON.stringify({
1504
+ success: false,
1505
+ statusCode: 500,
1506
+ data: null,
1507
+ message: error instanceof Error ? error.message : 'Error desconocido',
1508
+ error: 'HANDLER_ERROR'
1509
+ }, null, 2)
1510
+ }
1511
+ ],
1512
+ isError: true
1513
+ };
1514
+ }
1515
+ }
1516
+ };
1517
+ const merchant_key_generate_otpInputJsonSchema = {
1518
+ "type": "object",
1519
+ "properties": {
1520
+ "key": {
1521
+ "type": "string",
1522
+ "description": "Campo del body: key",
1523
+ "default": "j.salgado@refacil.com"
1524
+ },
1525
+ "typeKey": {
1526
+ "type": "string",
1527
+ "description": "Campo del body: typeKey",
1528
+ "default": "email"
1529
+ }
1530
+ },
1531
+ "required": []
1532
+ };
1533
+ const merchant_key_generate_otpInputShape = {
1534
+ key: z.string().optional().describe("Campo del body: key"),
1535
+ typeKey: z.string().optional().describe("Campo del body: typeKey")
1536
+ };
1537
+ const merchant_key_generate_otpInputValidator = z.object(merchant_key_generate_otpInputShape);
1538
+ // Herramienta: merchant_key_generate_otp
1539
+ export const merchant_key_generate_otpTool = {
1540
+ name: 'merchant_key_generate_otp',
1541
+ description: "This endpoint will allow you to generate and send an OTP. It is only permitted and necessary for \\`email\\` and \\`cellphone\\` keys. This OTP will be sent to its corresponding destination.\\n\\nHeaders\\n\\n| **Name** | **Value** |\\n| --- | --- |\\n| Content-Type | application/json |\\n| Authorization | Bearer |\\n\\nBody\\n\\n| Name | Type | Description |\\n| --- | --- | --- |\\n| \\`typeKey\\`\\\\* | string | Can be \\`email\\` and \\`cellphone\\` |\\n| \\`key\\` | string | key for which the OTP will be generated |\n\nContexto: Endpoint: POST /merchant-key/generate-otp | Merchant key > Generate otp",
1542
+ inputSchema: merchant_key_generate_otpInputShape,
1543
+ jsonSchema: merchant_key_generate_otpInputJsonSchema,
1544
+ endpoint: '/merchant-key/generate-otp',
1545
+ method: 'POST',
1546
+ parameters: [],
1547
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }, { "key": "Content-Type", "value": "application/json", "type": "text" }],
1548
+ handler: async (rawArgs) => {
1549
+ try {
1550
+ const normalizedArgs = rawArgs ?? {};
1551
+ // Extraer secretId del contexto (si viene del HTTP mode)
1552
+ const secretId = normalizedArgs._secretId;
1553
+ // Remover _secretId de los args antes de validar
1554
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1555
+ const validatedInput = validateToolInput(merchant_key_generate_otpInputValidator, argsToValidate);
1556
+ const args = validatedInput;
1557
+ const bodyData = {};
1558
+ const keyValue = args.key !== undefined ? args.key : "j.salgado@refacil.com";
1559
+ if (keyValue !== undefined)
1560
+ bodyData.key = keyValue;
1561
+ const typeKeyValue = args.typeKey !== undefined ? args.typeKey : "email";
1562
+ if (typeKeyValue !== undefined)
1563
+ bodyData.typeKey = typeKeyValue;
1564
+ return await makeApiRequest('POST', '/merchant-key/generate-otp', bodyData, undefined, secretId);
1565
+ }
1566
+ catch (error) {
1567
+ // Formato estándar del protocolo MCP para errores
1568
+ return {
1569
+ content: [
1570
+ {
1571
+ type: 'text',
1572
+ text: JSON.stringify({
1573
+ success: false,
1574
+ statusCode: 500,
1575
+ data: null,
1576
+ message: error instanceof Error ? error.message : 'Error desconocido',
1577
+ error: 'HANDLER_ERROR'
1578
+ }, null, 2)
1579
+ }
1580
+ ],
1581
+ isError: true
1582
+ };
1583
+ }
1584
+ }
1585
+ };
1586
+ const merchant_key_get_keysInputJsonSchema = {
1587
+ "type": "object",
1588
+ "properties": {},
1589
+ "required": []
1590
+ };
1591
+ const merchant_key_get_keysInputShape = {};
1592
+ const merchant_key_get_keysInputValidator = z.object(merchant_key_get_keysInputShape);
1593
+ // Herramienta: merchant_key_get_keys
1594
+ export const merchant_key_get_keysTool = {
1595
+ name: 'merchant_key_get_keys',
1596
+ description: "This endpoint allows you to obtain all keys created and in active status that belong to the merchant.\n\nContexto: Endpoint: GET /merchant-key/get-keys | Merchant key > Get keys",
1597
+ inputSchema: merchant_key_get_keysInputShape,
1598
+ jsonSchema: merchant_key_get_keysInputJsonSchema,
1599
+ endpoint: '/merchant-key/get-keys',
1600
+ method: 'GET',
1601
+ parameters: [],
1602
+ headers: [{ "key": "Authorization", "value": "Bearer {{tokenLogin}}", "type": "text" }],
1603
+ handler: async (rawArgs) => {
1604
+ try {
1605
+ const normalizedArgs = rawArgs ?? {};
1606
+ // Extraer secretId del contexto (si viene del HTTP mode)
1607
+ const secretId = normalizedArgs._secretId;
1608
+ // Remover _secretId de los args antes de validar
1609
+ const { _secretId, ...argsToValidate } = normalizedArgs;
1610
+ const validatedInput = validateToolInput(merchant_key_get_keysInputValidator, argsToValidate);
1611
+ const args = validatedInput;
1612
+ return await makeApiRequest('GET', '/merchant-key/get-keys', undefined, undefined, secretId);
1613
+ }
1614
+ catch (error) {
1615
+ // Formato estándar del protocolo MCP para errores
1616
+ return {
1617
+ content: [
1618
+ {
1619
+ type: 'text',
1620
+ text: JSON.stringify({
1621
+ success: false,
1622
+ statusCode: 500,
1623
+ data: null,
1624
+ message: error instanceof Error ? error.message : 'Error desconocido',
1625
+ error: 'HANDLER_ERROR'
1626
+ }, null, 2)
1627
+ }
1628
+ ],
1629
+ isError: true
1630
+ };
1631
+ }
1632
+ }
1633
+ };
1634
+ // Array de todas las herramientas disponibles
1635
+ export const tools = [
1636
+ auth_loginTool,
1637
+ trx_token_generateTool,
1638
+ trx_token_generate_3Tool,
1639
+ trx_token_generate_4Tool,
1640
+ trx_token_generate_5Tool,
1641
+ trx_token_generate_6Tool,
1642
+ cash_in_generate_payment_link_tokenTool,
1643
+ cash_in_generate_payment_method_tokenTool,
1644
+ cash_out_generate_withdraw_method_tokenTool,
1645
+ customer_getbalanceTool,
1646
+ payment_transfiya_banksTool,
1647
+ payment_statusTool,
1648
+ payment_customer_reference_statusTool,
1649
+ payment_featuresTool,
1650
+ webhook_notifyTool,
1651
+ merchant_enrollmentTool,
1652
+ merchant_enrollment_dataTool,
1653
+ merchant_key_createTool,
1654
+ merchant_key_cancelTool,
1655
+ merchant_key_generate_otpTool,
1656
+ merchant_key_get_keysTool
1657
+ ];
1658
+ // Configuración de herramientas del MCP
1659
+ export const toolsConfig = {
1660
+ name: 'refacil-pay',
1661
+ description: 'MCP para Refacil Pay API - Gestión de pagos y transacciones',
1662
+ version: '1.0.0',
1663
+ tools: 21
1664
+ };
1665
+ // Función para obtener información de las herramientas
1666
+ export function getToolsInfo() {
1667
+ return {
1668
+ ...toolsConfig,
1669
+ tools: tools.map(tool => ({
1670
+ name: tool.name,
1671
+ description: tool.description,
1672
+ inputSchema: tool.jsonSchema
1673
+ }))
1674
+ };
1675
+ }
1676
+ // Función helper para validar parámetros de entrada
1677
+ export function validateToolInput(validator, input) {
1678
+ try {
1679
+ return validator.parse(input);
1680
+ }
1681
+ catch (error) {
1682
+ if (error instanceof z.ZodError) {
1683
+ const errors = error.errors.map(err => `${err.path.join('.')} : ${err.message}`).join(', ');
1684
+ throw new Error(`Validación fallida: ${errors}`);
1685
+ }
1686
+ throw error;
1687
+ }
1688
+ }
1689
+ // Sistema de logging para las herramientas
1690
+ export class ToolLogger {
1691
+ toolName;
1692
+ startTime;
1693
+ constructor(toolName) {
1694
+ this.toolName = toolName;
1695
+ this.startTime = Date.now();
1696
+ }
1697
+ logStart(args) {
1698
+ console.log(`[${new Date().toISOString()}] ${this.toolName} iniciada`, {
1699
+ tool: this.toolName,
1700
+ args: JSON.stringify(args),
1701
+ timestamp: this.startTime
1702
+ });
1703
+ }
1704
+ logSuccess(result) {
1705
+ const duration = Date.now() - this.startTime;
1706
+ console.log(`[${new Date().toISOString()}] ${this.toolName} completada exitosamente`, {
1707
+ tool: this.toolName,
1708
+ duration: `${duration}ms`,
1709
+ statusCode: result?.statusCode
1710
+ });
1711
+ }
1712
+ logError(error) {
1713
+ const duration = Date.now() - this.startTime;
1714
+ console.error(`[${new Date().toISOString()}] ${this.toolName} falló`, {
1715
+ tool: this.toolName,
1716
+ duration: `${duration}ms`,
1717
+ error: error?.message || error
1718
+ });
1719
+ }
1720
+ }
1721
+ //# sourceMappingURL=tools.js.map