@koggitechorg/koggi-mcp-server 1.0.10 → 1.0.11

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, };
package/dist/index.js CHANGED
@@ -4,26 +4,96 @@ 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
+ // Crear el servidor MCP
8
9
  const server = new McpServer({
9
10
  name: "koggi-mcp-server",
10
- version: "1.0.10",
11
- description: "Custom MCP server for Koggi",
11
+ version: "1.0.11",
12
+ description: "Servidor MCP personalizado para Koggi",
12
13
  });
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 }) => {
14
+ // ===============================
15
+ // 🧮 Herramienta: Obtener calculadoras
16
+ // ===============================
17
+ server.tool("get_info_calculators", `Args:
18
+ identifications (list[number]): Lista de números de identificación del usuario.
19
+ entityKey (str): Clave de la entidad.`, {
20
+ identifications: z
21
+ .array(z.number())
22
+ .min(1, "Debe proporcionar al menos un número de identificación."),
23
+ entityKey: z
24
+ .string()
25
+ .min(1, "La clave de la entidad es obligatoria."),
26
+ }, async ({ identifications, entityKey }) => {
27
+ return errorHandler(async () => {
28
+ const infoCalculators = [];
29
+ for (const id of identifications) {
30
+ const calculator = await assign_and_get_last_calculator({
31
+ identificationNumber: id,
32
+ entityKey,
33
+ });
34
+ infoCalculators.push({ identification: id, calculator });
35
+ }
36
+ return {
37
+ content: [
38
+ { type: "text", text: JSON.stringify(infoCalculators, null, 2) },
39
+ ],
40
+ };
41
+ });
42
+ });
43
+ // ===============================
44
+ // 🔢 Herramienta: Asignar y obtener última calculadora
45
+ // ===============================
46
+ server.tool("assign_and_get_last_calculator", `Args:
47
+ identification (number): Número de identificación del usuario.
48
+ entityKey (str): Clave de la entidad.`, {
49
+ identification: z
50
+ .number()
51
+ .min(1, "El número de identificación es obligatorio."),
52
+ entityKey: z
53
+ .string()
54
+ .min(1, "La clave de la entidad es obligatoria."),
55
+ }, async ({ identification, entityKey }) => {
56
+ return errorHandler(async () => {
57
+ const calculator = await assign_and_get_last_calculator({
58
+ identificationNumber: identification,
59
+ entityKey,
60
+ });
61
+ return {
62
+ content: [{ type: "text", text: JSON.stringify(calculator, null, 2) }],
63
+ };
64
+ });
65
+ });
66
+ // ===============================
67
+ // 🧾 Herramienta: Generar simulador financiero
68
+ // ===============================
69
+ server.tool("generate_simulator", `Genera un simulador financiero para un usuario usando su número de documento.
70
+ Campos requeridos:
71
+ - identification (string): Número de documento del cliente o número del lead.
72
+ - origen_identification (string): Origen de la identificación ('input' o 'state').
73
+ - builder (string): Nombre de la constructora.
74
+ - email_requester (string): Correo electrónico de quien solicita el simulador.
75
+ - income_updated (number): Ingreso mensual actualizado del cliente.
76
+ - observations (string): Observaciones o comentarios adicionales.`, {
77
+ email_requester: z
78
+ .string()
79
+ .email("Debe ingresar un correo electrónico válido.")
80
+ .min(1, "El correo electrónico es obligatorio."),
81
+ income_updated: z
82
+ .number()
83
+ .min(1, "El ingreso mensual actualizado es obligatorio."),
84
+ observations: z
85
+ .string()
86
+ .min(1, "Las observaciones son obligatorias."),
87
+ identification: z
88
+ .string()
89
+ .min(1, "El número de identificación es obligatorio."),
90
+ origen_identification: z
91
+ .string()
92
+ .min(1, "El origen de la identificación es obligatorio."),
93
+ builder: z
94
+ .string()
95
+ .min(1, "El nombre de la constructora es obligatorio."),
96
+ }, async ({ identification, origen_identification, builder, email_requester, income_updated, observations, }) => {
27
97
  return errorHandler(async () => {
28
98
  const user = await generateSimulator({
29
99
  identification,
@@ -34,10 +104,12 @@ server.tool("generate_simulator", "Genera un simulador financiero para un usuari
34
104
  emailRequest: email_requester,
35
105
  });
36
106
  return {
37
- content: [{ type: "text", text: JSON.stringify(user, null, 2) }]
107
+ content: [{ type: "text", text: JSON.stringify(user, null, 2) }],
38
108
  };
39
109
  });
40
110
  });
41
- // Start receiving messages on stdin and sending messages on stdout
111
+ // ===============================
112
+ // 🚀 Iniciar servidor MCP
113
+ // ===============================
42
114
  const transport = new StdioServerTransport();
43
115
  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.11",
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
+ }
package/src/index.ts CHANGED
@@ -4,33 +4,124 @@ 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";
7
8
 
8
- // Create an MCP server
9
+ // Crear el servidor MCP
9
10
  const server = new McpServer({
10
11
  name: "koggi-mcp-server",
11
- version: "1.0.10",
12
- description: "Custom MCP server for Koggi",
12
+ version: "1.0.11",
13
+ description: "Servidor MCP personalizado para Koggi",
13
14
  });
14
15
 
16
+ // ===============================
17
+ // 🧮 Herramienta: Obtener calculadoras
18
+ // ===============================
19
+ server.tool(
20
+ "get_info_calculators",
21
+ `Args:
22
+ identifications (list[number]): Lista de números de identificación del usuario.
23
+ 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 = [];
35
+
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
+ }
43
+
44
+ return {
45
+ content: [
46
+ { type: "text", text: JSON.stringify(infoCalculators, null, 2) },
47
+ ],
48
+ };
49
+ });
50
+ }
51
+ );
52
+
53
+ // ===============================
54
+ // 🔢 Herramienta: Asignar y obtener última calculadora
55
+ // ===============================
56
+ server.tool(
57
+ "assign_and_get_last_calculator",
58
+ `Args:
59
+ identification (number): Número de identificación del usuario.
60
+ 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
+ });
75
+
76
+ return {
77
+ content: [{ type: "text", text: JSON.stringify(calculator, null, 2) }],
78
+ };
79
+ });
80
+ }
81
+ );
15
82
 
83
+ // ===============================
84
+ // 🧾 Herramienta: Generar simulador financiero
85
+ // ===============================
16
86
  server.tool(
17
87
  "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).",
88
+ `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.`,
25
96
  {
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"),
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."),
32
116
  },
33
- async ({ identification, origen_identification, builder, email_requester, income_updated, observations }) => {
117
+ async ({
118
+ identification,
119
+ origen_identification,
120
+ builder,
121
+ email_requester,
122
+ income_updated,
123
+ observations,
124
+ }) => {
34
125
  return errorHandler(async () => {
35
126
  const user = await generateSimulator({
36
127
  identification,
@@ -42,13 +133,14 @@ server.tool(
42
133
  });
43
134
 
44
135
  return {
45
- content: [{ type: "text", text: JSON.stringify(user, null, 2) }]
136
+ content: [{ type: "text", text: JSON.stringify(user, null, 2) }],
46
137
  };
47
138
  });
48
139
  }
49
140
  );
50
141
 
51
-
52
- // Start receiving messages on stdin and sending messages on stdout
142
+ // ===============================
143
+ // 🚀 Iniciar servidor MCP
144
+ // ===============================
53
145
  const transport = new StdioServerTransport();
54
- await server.connect(transport);
146
+ await server.connect(transport);