@koggitechorg/koggi-mcp-server 1.0.10 → 1.0.12

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
@@ -11,12 +11,24 @@ Una herramienta (MCP server) ligera para exponer un comando/tool llamado `genera
11
11
 
12
12
  ## Características
13
13
 
14
- - Tool MCP: `generate_simulator`
15
- - Propósito: Generar un simulador financiero para un usuario dado.
16
- - Schema (Zod): `identification`, `origen_identification`,`builder`,`email_requester`, `income_updated`, `observations` (todos son obligatorios `index.ts`).
17
- - Comunicación: stdin/stdout (StdioServerTransport) siguiendo el SDK `@modelcontextprotocol/sdk`.
18
- - Cliente HTTP: usa `node-fetch` y `EXTERNAL_URL` como base para las peticiones.
19
-
14
+ * ## Características
15
+
16
+ - Tool MCP: `get_info_calculators`
17
+ - Propósito: Obtener la información de los calculadores asignados a una lista de identificaciones.
18
+ - Schema (Zod): `identifications` (array de números), `entityKey` (string) ambos obligatorios.
19
+
20
+ - Tool MCP: `assign_and_get_last_calculator`
21
+ - Propósito: Asignar y obtener el último calculador asociado a un número de identificación específico.
22
+ - Schema (Zod): `identification` (number), `entityKey` (string) — ambos obligatorios.
23
+
24
+ - Tool MCP: `generate_simulator`
25
+ - Propósito: Generar un simulador financiero para un usuario dado.
26
+ - Schema (Zod): `identification`, `origen_identification`, `builder`, `email_requester`,
27
+ `income_updated`, `observations` (todos son obligatorios — definidos en `index.ts`).
28
+
29
+ - Comunicación: stdin/stdout (StdioServerTransport) siguiendo el SDK `@modelcontextprotocol/sdk`.
30
+ - Cliente HTTP: usa `node-fetch` y la variable de entorno `EXTERNAL_URL` como base para las peticiones.
31
+
20
32
  ## Requisitos
21
33
 
22
34
  - Node.js 18+ (o compatible con ESM y fetch nativo).
@@ -0,0 +1,9 @@
1
+ import { validateRequestToken } from "../middlewares/middleware.js";
2
+ import { apiFetch } from "../utils/apiClient.js";
3
+ async function assign_and_get_last_calculator(data) {
4
+ return await validateRequestToken(async () => apiFetch(`/api/monitoreo-financiero/last-calculator-by-identification-for-builder`, {
5
+ method: "POST",
6
+ body: JSON.stringify(data),
7
+ }));
8
+ }
9
+ export { assign_and_get_last_calculator, };
@@ -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
@@ -4,26 +4,115 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
4
4
  import { z } from "zod";
5
5
  import { generateSimulator } from "./handlers/simulator.js";
6
6
  import { errorHandler } from "./error/error.handler.js";
7
- // Create an MCP server
7
+ import { assign_and_get_last_calculator } from "./handlers/calculator.js";
8
+ import { getHdcByIdLead } from "./handlers/hdc.js";
9
+ // Crear el servidor MCP
8
10
  const server = new McpServer({
9
11
  name: "koggi-mcp-server",
10
- version: "1.0.10",
11
- description: "Custom MCP server for Koggi",
12
+ version: "1.0.11",
13
+ description: "Servidor MCP personalizado para Koggi",
12
14
  });
13
- server.tool("generate_simulator", "Genera un simulador financiero para un usuario usando su número de documento. Campos requeridos: \
14
- identification (string, número de documento del cliente o número del lead), \
15
- origen_identification (string, origen de la identificación del lead puede tener dos valores 'input' o 'state'), \
16
- builder (string, nombre de la constructora), \
17
- email_requester (string, correo electrónico de quien solicita el simulador), \
18
- income_updated (number, ingreso mensual actualizado del cliente), \
19
- observations (string, observaciones o comentarios adicionales sobre la solicitud).", {
20
- email_requester: z.string().email().min(1, "Email is required"),
21
- income_updated: z.number().min(1, "Income is required"),
22
- observations: z.string().min(1, "Observations are required"),
23
- identification: z.string().min(1, "Identification number is required"),
24
- origen_identification: z.string().min(1, "Origen is required"),
25
- builder: z.string().min(1, "Builder is required"),
26
- }, async ({ identification, origen_identification, builder, email_requester, income_updated, observations }) => {
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
+ // ===============================
34
+ // 🧮 Herramienta: Obtener calculadoras
35
+ // ===============================
36
+ server.tool("get_info_calculators", `Args:
37
+ identifications (list[number]): Lista de números de identificación del usuario.
38
+ entityKey (str): Clave de la entidad.`, {
39
+ identifications: z
40
+ .array(z.number())
41
+ .min(1, "Debe proporcionar al menos un número de identificación."),
42
+ entityKey: z
43
+ .string()
44
+ .min(1, "La clave de la entidad es obligatoria."),
45
+ }, async ({ identifications, entityKey }) => {
46
+ return errorHandler(async () => {
47
+ const infoCalculators = [];
48
+ for (const id of identifications) {
49
+ const calculator = await assign_and_get_last_calculator({
50
+ identificationNumber: id,
51
+ entityKey,
52
+ });
53
+ infoCalculators.push({ identification: id, calculator });
54
+ }
55
+ return {
56
+ content: [
57
+ { type: "text", text: JSON.stringify(infoCalculators, null, 2) },
58
+ ],
59
+ };
60
+ });
61
+ });
62
+ // ===============================
63
+ // 🔢 Herramienta: Asignar y obtener última calculadora
64
+ // ===============================
65
+ server.tool("assign_and_get_last_calculator", `Args:
66
+ identification (number): Número de identificación del usuario.
67
+ entityKey (str): Clave de la entidad.`, {
68
+ identification: z
69
+ .number()
70
+ .min(1, "El número de identificación es obligatorio."),
71
+ entityKey: z
72
+ .string()
73
+ .min(1, "La clave de la entidad es obligatoria."),
74
+ }, async ({ identification, entityKey }) => {
75
+ return errorHandler(async () => {
76
+ const calculator = await assign_and_get_last_calculator({
77
+ identificationNumber: identification,
78
+ entityKey,
79
+ });
80
+ return {
81
+ content: [{ type: "text", text: JSON.stringify(calculator, null, 2) }],
82
+ };
83
+ });
84
+ });
85
+ // ===============================
86
+ // 🧾 Herramienta: Generar simulador financiero
87
+ // ===============================
88
+ server.tool("generate_simulator", `Genera un simulador financiero para un usuario usando su número de documento.
89
+ 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').
92
+ - builder (string): Nombre de la constructora.
93
+ - email_requester (string): Correo electrónico de quien solicita el simulador.
94
+ - income_updated (number): Ingreso mensual actualizado del cliente.
95
+ - observations (string): Observaciones o comentarios adicionales.`, {
96
+ email_requester: z
97
+ .string()
98
+ .email("Debe ingresar un correo electrónico válido.")
99
+ .min(1, "El correo electrónico es obligatorio."),
100
+ income_updated: z
101
+ .number()
102
+ .min(1, "El ingreso mensual actualizado es obligatorio."),
103
+ observations: z
104
+ .string()
105
+ .min(1, "Las observaciones son obligatorias."),
106
+ identification: z
107
+ .string()
108
+ .min(1, "El número de identificación es obligatorio."),
109
+ origen_identification: z
110
+ .string()
111
+ .min(1, "El origen de la identificación es obligatorio."),
112
+ builder: z
113
+ .string()
114
+ .min(1, "El nombre de la constructora es obligatorio."),
115
+ }, async ({ identification, origen_identification, builder, email_requester, income_updated, observations, }) => {
27
116
  return errorHandler(async () => {
28
117
  const user = await generateSimulator({
29
118
  identification,
@@ -34,10 +123,12 @@ server.tool("generate_simulator", "Genera un simulador financiero para un usuari
34
123
  emailRequest: email_requester,
35
124
  });
36
125
  return {
37
- content: [{ type: "text", text: JSON.stringify(user, null, 2) }]
126
+ content: [{ type: "text", text: JSON.stringify(user, null, 2) }],
38
127
  };
39
128
  });
40
129
  });
41
- // Start receiving messages on stdin and sending messages on stdout
130
+ // ===============================
131
+ // 🚀 Iniciar servidor MCP
132
+ // ===============================
42
133
  const transport = new StdioServerTransport();
43
134
  await server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koggitechorg/koggi-mcp-server",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -0,0 +1,17 @@
1
+ import { validateRequestToken } from "../middlewares/middleware.js";
2
+ import { apiFetch } from "../utils/apiClient.js";
3
+
4
+ interface CalculatorData {
5
+ [key: string]: any;
6
+ }
7
+
8
+ async function assign_and_get_last_calculator(data: CalculatorData): Promise<any> {
9
+ return await validateRequestToken(async () => apiFetch(`/api/monitoreo-financiero/last-calculator-by-identification-for-builder`, {
10
+ method: "POST",
11
+ body: JSON.stringify(data),
12
+ }));
13
+ }
14
+
15
+ export {
16
+ assign_and_get_last_calculator,
17
+ }
@@ -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
@@ -4,51 +4,170 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
4
4
  import { z } from "zod";
5
5
  import { generateSimulator } from "./handlers/simulator.js";
6
6
  import { errorHandler } from "./error/error.handler.js";
7
+ import { assign_and_get_last_calculator } from "./handlers/calculator.js";
8
+ import { getHdcByIdLead } from "./handlers/hdc.js";
7
9
 
8
- // Create an MCP server
10
+ // Crear el servidor MCP
9
11
  const server = new McpServer({
10
- name: "koggi-mcp-server",
11
- version: "1.0.10",
12
- description: "Custom MCP server for Koggi",
12
+ name: "koggi-mcp-server",
13
+ version: "1.0.12",
14
+ description: "Servidor MCP Profiling personalizado para Koggi",
13
15
  });
14
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
+ );
15
38
 
39
+ // ===============================
40
+ // 🧮 Herramienta: Obtener calculadoras
41
+ // ===============================
16
42
  server.tool(
17
- "generate_simulator",
18
- "Genera un simulador financiero para un usuario usando su número de documento. Campos requeridos: \
19
- identification (string, número de documento del cliente o número del lead), \
20
- origen_identification (string, origen de la identificación del lead puede tener dos valores 'input' o 'state'), \
21
- builder (string, nombre de la constructora), \
22
- email_requester (string, correo electrónico de quien solicita el simulador), \
23
- income_updated (number, ingreso mensual actualizado del cliente), \
24
- observations (string, observaciones o comentarios adicionales sobre la solicitud).",
25
- {
26
- email_requester: z.string().email().min(1, "Email is required"),
27
- income_updated: z.number().min(1, "Income is required"),
28
- observations: z.string().min(1, "Observations are required"),
29
- identification: z.string().min(1, "Identification number is required"),
30
- origen_identification: z.string().min(1, "Origen is required"),
31
- builder: z.string().min(1, "Builder is required"),
32
- },
33
- async ({ identification, origen_identification, builder, email_requester, income_updated, observations }) => {
34
- return errorHandler(async () => {
35
- const user = await generateSimulator({
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:
47
+ identifications (list[number]): Lista de números de identificación del usuario.
48
+ entityKey (str): Clave de la entidad.`,
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 = [];
60
+
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
+ }
68
+
69
+ return {
70
+ content: [
71
+ { type: "text", text: JSON.stringify(infoCalculators, null, 2) },
72
+ ],
73
+ };
74
+ });
75
+ }
76
+ );
77
+
78
+ // ===============================
79
+ // 🔢 Herramienta: Asignar y obtener última calculadora
80
+ // ===============================
81
+ server.tool(
82
+ "assign_and_get_last_calculator",
83
+ `
84
+ obtiene la última calculadora asignada a un número de identificación.
85
+ Args:
86
+ identification (number): Número de identificación del usuario.
87
+ entityKey (str): Clave de la entidad.`,
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
+ });
102
+
103
+ return {
104
+ content: [{ type: "text", text: JSON.stringify(calculator, null, 2) }],
105
+ };
106
+ });
107
+ }
108
+ );
109
+
110
+ // ===============================
111
+ // 🧾 Herramienta: Generar simulador financiero
112
+ // ===============================
113
+ server.tool(
114
+ "generate_simulator",
115
+ `Genera un simulador financiero para un usuario usando su número de documento.
116
+ Campos requeridos:
117
+ - identification (string): Número de documento del cliente o número del lead.
118
+ - origen_identification (string): Origen de la identificación ('input' o 'state').
119
+ - builder (string): Nombre de la constructora.
120
+ - email_requester (string): Correo electrónico de quien solicita el simulador.
121
+ - income_updated (number): Ingreso mensual actualizado del cliente.
122
+ - observations (string): Observaciones o comentarios adicionales.`,
123
+ {
124
+ email_requester: z
125
+ .string()
126
+ .email("Debe ingresar un correo electrónico válido.")
127
+ .min(1, "El correo electrónico es obligatorio."),
128
+ income_updated: z
129
+ .number()
130
+ .min(1, "El ingreso mensual actualizado es obligatorio."),
131
+ observations: z
132
+ .string()
133
+ .min(1, "Las observaciones son obligatorias."),
134
+ identification: z
135
+ .string()
136
+ .min(1, "El número de identificación es obligatorio."),
137
+ origen_identification: z
138
+ .string()
139
+ .min(1, "El origen de la identificación es obligatorio."),
140
+ builder: z
141
+ .string()
142
+ .min(1, "El nombre de la constructora es obligatorio."),
143
+ },
144
+ async ({
36
145
  identification,
37
146
  origen_identification,
38
147
  builder,
39
- ingresosActualizados: income_updated,
40
- observaciones: observations,
41
- emailRequest: email_requester,
42
- });
43
-
44
- return {
45
- content: [{ type: "text", text: JSON.stringify(user, null, 2) }]
46
- };
47
- });
48
- }
49
- );
148
+ email_requester,
149
+ income_updated,
150
+ observations,
151
+ }) => {
152
+ return errorHandler(async () => {
153
+ const user = await generateSimulator({
154
+ identification,
155
+ origen_identification,
156
+ builder,
157
+ ingresosActualizados: income_updated,
158
+ observaciones: observations,
159
+ emailRequest: email_requester,
160
+ });
50
161
 
162
+ return {
163
+ content: [{ type: "text", text: JSON.stringify(user, null, 2) }],
164
+ };
165
+ });
166
+ }
167
+ );
51
168
 
52
- // Start receiving messages on stdin and sending messages on stdout
169
+ // ===============================
170
+ // 🚀 Iniciar servidor MCP
171
+ // ===============================
53
172
  const transport = new StdioServerTransport();
54
- await server.connect(transport);
173
+ await server.connect(transport);