@koggitechorg/koggi-mcp-server 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/handlers/hdc.js +9 -0
- package/dist/index.js +19 -0
- package/package.json +1 -1
- package/src/handlers/hdc.ts +12 -0
- package/src/index.ts +118 -97
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Una herramienta (MCP server) ligera para exponer un comando/tool llamado `genera
|
|
|
23
23
|
|
|
24
24
|
- Tool MCP: `generate_simulator`
|
|
25
25
|
- Propósito: Generar un simulador financiero para un usuario dado.
|
|
26
|
-
- Schema (Zod): `
|
|
26
|
+
- Schema (Zod): `id_lead`, `builder`, `email_requester`,
|
|
27
27
|
`income_updated`, `observations` (todos son obligatorios — definidos en `index.ts`).
|
|
28
28
|
|
|
29
29
|
- Comunicación: stdin/stdout (StdioServerTransport) siguiendo el SDK `@modelcontextprotocol/sdk`.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { validateRequestToken } from "../middlewares/middleware.js";
|
|
2
|
+
import { apiFetch } from "../utils/apiClient.js";
|
|
3
|
+
async function getHdcByIdLead(idLead) {
|
|
4
|
+
return await validateRequestToken(async () => apiFetch(`/api/monitoreo-financiero/get-hdc-by-lead`, {
|
|
5
|
+
method: "POST",
|
|
6
|
+
body: JSON.stringify({ idLead }),
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
9
|
+
export { getHdcByIdLead };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
import { generateSimulator } from "./handlers/simulator.js";
|
|
6
6
|
import { errorHandler } from "./error/error.handler.js";
|
|
7
7
|
import { assign_and_get_last_calculator } from "./handlers/calculator.js";
|
|
8
|
+
import { getHdcByIdLead } from "./handlers/hdc.js";
|
|
8
9
|
// Crear el servidor MCP
|
|
9
10
|
const server = new McpServer({
|
|
10
11
|
name: "koggi-mcp-server",
|
|
@@ -12,6 +13,24 @@ const server = new McpServer({
|
|
|
12
13
|
description: "Servidor MCP personalizado para Koggi",
|
|
13
14
|
});
|
|
14
15
|
// ===============================
|
|
16
|
+
// 🧮 Herramienta: Obtener Historia de Crédito
|
|
17
|
+
// ===============================
|
|
18
|
+
server.tool("get_hdc_by_lead", `Args:
|
|
19
|
+
id_lead (number): ID del lead para obtener la historia de crédito.`, {
|
|
20
|
+
idLead: z
|
|
21
|
+
.number()
|
|
22
|
+
.min(1, "El ID del lead es obligatorio."),
|
|
23
|
+
}, async ({ idLead }) => {
|
|
24
|
+
return errorHandler(async () => {
|
|
25
|
+
const hdcData = await getHdcByIdLead(idLead);
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{ type: "text", text: JSON.stringify(hdcData, null, 2) },
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
// ===============================
|
|
15
34
|
// 🧮 Herramienta: Obtener calculadoras
|
|
16
35
|
// ===============================
|
|
17
36
|
server.tool("get_info_calculators", `Args:
|
package/package.json
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { validateRequestToken } from "../middlewares/middleware.js";
|
|
2
|
+
import { apiFetch } from "../utils/apiClient.js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
async function getHdcByIdLead(idLead: number): Promise<any> {
|
|
7
|
+
return await validateRequestToken(async () => apiFetch(`/api/monitoreo-financiero/get-hdc-by-lead`, {
|
|
8
|
+
method: "POST",
|
|
9
|
+
body: JSON.stringify({ idLead }),
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
export { getHdcByIdLead };
|
package/src/index.ts
CHANGED
|
@@ -5,138 +5,159 @@ import { z } from "zod";
|
|
|
5
5
|
import { generateSimulator } from "./handlers/simulator.js";
|
|
6
6
|
import { errorHandler } from "./error/error.handler.js";
|
|
7
7
|
import { assign_and_get_last_calculator } from "./handlers/calculator.js";
|
|
8
|
+
import { getHdcByIdLead } from "./handlers/hdc.js";
|
|
8
9
|
|
|
9
10
|
// Crear el servidor MCP
|
|
10
11
|
const server = new McpServer({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
name: "koggi-mcp-server",
|
|
13
|
+
version: "1.0.13",
|
|
14
|
+
description: "Servidor MCP Profiling personalizado para Koggi",
|
|
14
15
|
});
|
|
15
16
|
|
|
17
|
+
// ===============================
|
|
18
|
+
// 🧮 Herramienta: Obtener Historia de Crédito
|
|
19
|
+
// ===============================
|
|
20
|
+
server.tool("get_hdc_by_lead", `
|
|
21
|
+
Obtiene la historia de crédito (HDC) de un lead dado su ID.
|
|
22
|
+
Args:
|
|
23
|
+
id_lead (number): ID del lead para obtener la historia de crédito.`, {
|
|
24
|
+
idLead: z
|
|
25
|
+
.number()
|
|
26
|
+
.min(1, "El ID del lead es obligatorio."),
|
|
27
|
+
}, async ({ idLead }) => {
|
|
28
|
+
return errorHandler(async () => {
|
|
29
|
+
const hdcData = await getHdcByIdLead(idLead);
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{ type: "text", text: JSON.stringify(hdcData, null, 2) },
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
16
39
|
// ===============================
|
|
17
40
|
// 🧮 Herramienta: Obtener calculadoras
|
|
18
41
|
// ===============================
|
|
19
42
|
server.tool(
|
|
20
|
-
|
|
21
|
-
|
|
43
|
+
"get_info_calculators",
|
|
44
|
+
`
|
|
45
|
+
Obtene información de las últimas calculadoras asignadas a una lista de números de identificación.
|
|
46
|
+
Args:
|
|
22
47
|
identifications (list[number]): Lista de números de identificación del usuario.
|
|
23
48
|
entityKey (str): Clave de la entidad.`,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
{
|
|
50
|
+
identifications: z
|
|
51
|
+
.array(z.number())
|
|
52
|
+
.min(1, "Debe proporcionar al menos un número de identificación."),
|
|
53
|
+
entityKey: z
|
|
54
|
+
.string()
|
|
55
|
+
.min(1, "La clave de la entidad es obligatoria."),
|
|
56
|
+
},
|
|
57
|
+
async ({ identifications, entityKey }) => {
|
|
58
|
+
return errorHandler(async () => {
|
|
59
|
+
const infoCalculators = [];
|
|
35
60
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
61
|
+
for (const id of identifications) {
|
|
62
|
+
const calculator = await assign_and_get_last_calculator({
|
|
63
|
+
identificationNumber: id,
|
|
64
|
+
entityKey,
|
|
65
|
+
});
|
|
66
|
+
infoCalculators.push({ identification: id, calculator });
|
|
67
|
+
}
|
|
43
68
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{ type: "text", text: JSON.stringify(infoCalculators, null, 2) },
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
}
|
|
51
76
|
);
|
|
52
77
|
|
|
53
78
|
// ===============================
|
|
54
79
|
// 🔢 Herramienta: Asignar y obtener última calculadora
|
|
55
80
|
// ===============================
|
|
56
81
|
server.tool(
|
|
57
|
-
|
|
58
|
-
|
|
82
|
+
"assign_and_get_last_calculator",
|
|
83
|
+
`
|
|
84
|
+
obtiene la última calculadora asignada a un número de identificación.
|
|
85
|
+
Args:
|
|
59
86
|
identification (number): Número de identificación del usuario.
|
|
60
87
|
entityKey (str): Clave de la entidad.`,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
88
|
+
{
|
|
89
|
+
identification: z
|
|
90
|
+
.number()
|
|
91
|
+
.min(1, "El número de identificación es obligatorio."),
|
|
92
|
+
entityKey: z
|
|
93
|
+
.string()
|
|
94
|
+
.min(1, "La clave de la entidad es obligatoria."),
|
|
95
|
+
},
|
|
96
|
+
async ({ identification, entityKey }) => {
|
|
97
|
+
return errorHandler(async () => {
|
|
98
|
+
const calculator = await assign_and_get_last_calculator({
|
|
99
|
+
identificationNumber: identification,
|
|
100
|
+
entityKey,
|
|
101
|
+
});
|
|
75
102
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
return {
|
|
104
|
+
content: [{ type: "text", text: JSON.stringify(calculator, null, 2) }],
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}
|
|
81
108
|
);
|
|
82
109
|
|
|
83
110
|
// ===============================
|
|
84
111
|
// 🧾 Herramienta: Generar simulador financiero
|
|
85
112
|
// ===============================
|
|
86
113
|
server.tool(
|
|
87
|
-
|
|
88
|
-
|
|
114
|
+
"generate_simulator",
|
|
115
|
+
`Genera un simulador financiero para un usuario usando su número de documento.
|
|
89
116
|
Campos requeridos:
|
|
90
|
-
-
|
|
91
|
-
- origen_identification (string): Origen de la identificación ('input' o 'state').
|
|
117
|
+
- id_lead (string): Número de documento del cliente o número del lead.
|
|
92
118
|
- builder (string): Nombre de la constructora.
|
|
93
119
|
- email_requester (string): Correo electrónico de quien solicita el simulador.
|
|
94
120
|
- income_updated (number): Ingreso mensual actualizado del cliente.
|
|
95
121
|
- observations (string): Observaciones o comentarios adicionales.`,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
},
|
|
117
|
-
async ({
|
|
118
|
-
identification,
|
|
119
|
-
origen_identification,
|
|
120
|
-
builder,
|
|
121
|
-
email_requester,
|
|
122
|
-
income_updated,
|
|
123
|
-
observations,
|
|
124
|
-
}) => {
|
|
125
|
-
return errorHandler(async () => {
|
|
126
|
-
const user = await generateSimulator({
|
|
127
|
-
identification,
|
|
128
|
-
origen_identification,
|
|
122
|
+
{
|
|
123
|
+
email_requester: z
|
|
124
|
+
.string()
|
|
125
|
+
.email("Debe ingresar un correo electrónico válido.")
|
|
126
|
+
.min(1, "El correo electrónico es obligatorio."),
|
|
127
|
+
income_updated: z
|
|
128
|
+
.number()
|
|
129
|
+
.min(1, "El ingreso mensual actualizado es obligatorio."),
|
|
130
|
+
observations: z
|
|
131
|
+
.string()
|
|
132
|
+
.min(1, "Las observaciones son obligatorias."),
|
|
133
|
+
id_lead: z
|
|
134
|
+
.string()
|
|
135
|
+
.min(1, "El número de id_lead es obligatorio."),
|
|
136
|
+
builder: z
|
|
137
|
+
.string()
|
|
138
|
+
.min(1, "El nombre de la constructora es obligatorio."),
|
|
139
|
+
},
|
|
140
|
+
async ({
|
|
141
|
+
id_lead,
|
|
129
142
|
builder,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
email_requester,
|
|
144
|
+
income_updated,
|
|
145
|
+
observations,
|
|
146
|
+
}) => {
|
|
147
|
+
return errorHandler(async () => {
|
|
148
|
+
const user = await generateSimulator({
|
|
149
|
+
id_lead,
|
|
150
|
+
builder,
|
|
151
|
+
ingresosActualizados: income_updated,
|
|
152
|
+
observaciones: observations,
|
|
153
|
+
emailRequest: email_requester,
|
|
154
|
+
});
|
|
134
155
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
156
|
+
return {
|
|
157
|
+
content: [{ type: "text", text: JSON.stringify(user, null, 2) }],
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
}
|
|
140
161
|
);
|
|
141
162
|
|
|
142
163
|
// ===============================
|