@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 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): `identification`, `origen_identification`, `builder`, `email_requester`,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koggitechorg/koggi-mcp-server",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -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
- name: "koggi-mcp-server",
12
- version: "1.0.11",
13
- description: "Servidor MCP personalizado para Koggi",
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
- "get_info_calculators",
21
- `Args:
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
- identifications: z
26
- .array(z.number())
27
- .min(1, "Debe proporcionar al menos un número de identificación."),
28
- entityKey: z
29
- .string()
30
- .min(1, "La clave de la entidad es obligatoria."),
31
- },
32
- async ({ identifications, entityKey }) => {
33
- return errorHandler(async () => {
34
- const infoCalculators = [];
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
- for (const id of identifications) {
37
- const calculator = await assign_and_get_last_calculator({
38
- identificationNumber: id,
39
- entityKey,
40
- });
41
- infoCalculators.push({ identification: id, calculator });
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
- return {
45
- content: [
46
- { type: "text", text: JSON.stringify(infoCalculators, null, 2) },
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
- "assign_and_get_last_calculator",
58
- `Args:
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
- identification: z
63
- .number()
64
- .min(1, "El número de identificación es obligatorio."),
65
- entityKey: z
66
- .string()
67
- .min(1, "La clave de la entidad es obligatoria."),
68
- },
69
- async ({ identification, entityKey }) => {
70
- return errorHandler(async () => {
71
- const calculator = await assign_and_get_last_calculator({
72
- identificationNumber: identification,
73
- entityKey,
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
- return {
77
- content: [{ type: "text", text: JSON.stringify(calculator, null, 2) }],
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
- "generate_simulator",
88
- `Genera un simulador financiero para un usuario usando su número de documento.
114
+ "generate_simulator",
115
+ `Genera un simulador financiero para un usuario usando su número de documento.
89
116
  Campos requeridos:
90
- - identification (string): Número de documento del cliente o número del lead.
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
- email_requester: z
98
- .string()
99
- .email("Debe ingresar un correo electrónico válido.")
100
- .min(1, "El correo electrónico es obligatorio."),
101
- income_updated: z
102
- .number()
103
- .min(1, "El ingreso mensual actualizado es obligatorio."),
104
- observations: z
105
- .string()
106
- .min(1, "Las observaciones son obligatorias."),
107
- identification: z
108
- .string()
109
- .min(1, "El número de identificación es obligatorio."),
110
- origen_identification: z
111
- .string()
112
- .min(1, "El origen de la identificación es obligatorio."),
113
- builder: z
114
- .string()
115
- .min(1, "El nombre de la constructora es obligatorio."),
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
- ingresosActualizados: income_updated,
131
- observaciones: observations,
132
- emailRequest: email_requester,
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
- return {
136
- content: [{ type: "text", text: JSON.stringify(user, null, 2) }],
137
- };
138
- });
139
- }
156
+ return {
157
+ content: [{ type: "text", text: JSON.stringify(user, null, 2) }],
158
+ };
159
+ });
160
+ }
140
161
  );
141
162
 
142
163
  // ===============================