@koggitechorg/koggi-mcp-server 1.0.1

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 ADDED
@@ -0,0 +1 @@
1
+ # mcp-koggi-package
@@ -0,0 +1,5 @@
1
+ import dotenv from "dotenv";
2
+ dotenv.config();
3
+ export const CONFIG = {
4
+ apiUrl: process.env.EXTERNAL_URL || "",
5
+ };
@@ -0,0 +1,8 @@
1
+ import { apiFetch } from "../utils/apiClient.js";
2
+ async function generateSimulator(data) {
3
+ return apiFetch(`/api/monitoreo-financiero/simulate-new-calculator-by-id-lead`, {
4
+ method: "POST",
5
+ body: JSON.stringify(data),
6
+ });
7
+ }
8
+ export { generateSimulator };
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { z } from "zod";
4
+ import { generateSimulator } from "./handlers/simulator.js";
5
+ // Create an MCP server
6
+ const server = new McpServer({
7
+ name: "koggi-mcp-server",
8
+ version: "1.0.0",
9
+ description: "Custom MCP server for Koggi",
10
+ });
11
+ server.tool("generateSimulator", "Genera un simulador financiero para un usuario usando su número de documento. Campos requeridos: \
12
+ id_lead (string, identificador único del lead), \
13
+ email_requester (string, correo electrónico de quien solicita el simulador), \
14
+ income_updated (number, ingreso mensual actualizado del cliente), \
15
+ observations (string, observaciones o comentarios adicionales sobre la solicitud).", {
16
+ id_lead: z.string().min(1, "Lead ID is required"),
17
+ email_requester: z.string().email().min(1, "Email is required"),
18
+ income_updated: z.number().min(1, "Income is required"),
19
+ observations: z.string().min(1, "Observations are required"),
20
+ }, async ({ id_lead, email_requester, income_updated, observations }) => {
21
+ const user = await generateSimulator({
22
+ idLead: id_lead,
23
+ ingresosActualizados: income_updated,
24
+ observaciones: observations,
25
+ emailRequest: email_requester,
26
+ });
27
+ return {
28
+ content: [{ type: "text", text: JSON.stringify(user, null, 2) }]
29
+ };
30
+ });
31
+ // Start receiving messages on stdin and sending messages on stdout
32
+ const transport = new StdioServerTransport();
33
+ await server.connect(transport);
@@ -0,0 +1,16 @@
1
+ import { CONFIG } from "../config/config.js";
2
+ export async function apiFetch(path, options = {}) {
3
+ const res = await fetch(`${CONFIG.apiUrl}${path}`, {
4
+ ...options,
5
+ headers: {
6
+ "Content-Type": "application/json",
7
+ "x-forwarded-authorization": "n8n amarilo",
8
+ ...options.headers,
9
+ },
10
+ });
11
+ if (!res.ok) {
12
+ const text = await res.text();
13
+ throw new Error(`API error ${res.status}: ${text}`);
14
+ }
15
+ return res.json();
16
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@koggitechorg/koggi-mcp-server",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "koggi-mcp-server": "dist/index.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Koggitechorg/koggi-mcp-server.git"
12
+ },
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "start": "node dist/index.js",
16
+ "test": "echo \"Error: no test specified\" && exit 1"
17
+ },
18
+ "dependencies": {
19
+ "@modelcontextprotocol/sdk": "^1.20.1",
20
+ "dotenv": "^17.2.3",
21
+ "node-fetch": "^3.3.2"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^20.11.30",
25
+ "ts-node": "^10.9.2",
26
+ "typescript": "^5.6.3"
27
+ }
28
+ }
@@ -0,0 +1,7 @@
1
+ import dotenv from "dotenv";
2
+ dotenv.config();
3
+
4
+ export const CONFIG = {
5
+ apiUrl: process.env.EXTERNAL_URL || "https://api.miapi.com/v1",
6
+ apiHeaders: JSON.parse(process.env.OPENAPI_MCP_HEADERS || "{}"),
7
+ };
@@ -0,0 +1,6 @@
1
+ import dotenv from "dotenv";
2
+ dotenv.config();
3
+
4
+ export const CONFIG: { apiUrl: string } = {
5
+ apiUrl: process.env.EXTERNAL_URL || "",
6
+ };
@@ -0,0 +1,10 @@
1
+ import { apiFetch } from "../utils/apiClient.js";
2
+
3
+ async function generateSimulator(id) {
4
+ return apiFetch(`/simulators/${id}`);
5
+ }
6
+
7
+
8
+ export {
9
+ generateSimulator
10
+ }
@@ -0,0 +1,16 @@
1
+ import { apiFetch } from "../utils/apiClient.js";
2
+
3
+ interface SimulatorData {
4
+ [key: string]: any;
5
+ }
6
+
7
+ async function generateSimulator(data: SimulatorData): Promise<void> {
8
+ return apiFetch(`/api/monitoreo-financiero/simulate-new-calculator-by-id-lead`, {
9
+ method: "POST",
10
+ body: JSON.stringify(data),
11
+ });
12
+ }
13
+
14
+ export {
15
+ generateSimulator
16
+ }
package/src/index.js ADDED
@@ -0,0 +1,29 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { buildHandlers } from "./server.js";
4
+
5
+ async function main() {
6
+ console.log("🚀 Starting koggi-mcp-server...");
7
+
8
+ const server = new McpServer({
9
+ name: "koggi-mcp-server",
10
+ version: "1.0.0",
11
+ description: "Custom MCP server for Koggi",
12
+ });
13
+
14
+ const handlers = await buildHandlers();
15
+
16
+ for (const tool of handlers) {
17
+ server.tool(tool.name, tool.description, tool.schema, tool.handler);
18
+ }
19
+
20
+ const transport = new StdioServerTransport();
21
+ await server.connect(transport);
22
+
23
+ console.log("✅ koggi-mcp-server running...");
24
+ }
25
+
26
+ main().catch((err) => {
27
+ console.error("❌ Server failed:", err);
28
+ process.exit(1);
29
+ });
package/src/index.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { z } from "zod";
4
+ import { generateSimulator } from "./handlers/simulator.js";
5
+
6
+ // Create an MCP server
7
+ const server = new McpServer({
8
+ name: "koggi-mcp-server",
9
+ version: "1.0.0",
10
+ description: "Custom MCP server for Koggi",
11
+ });
12
+
13
+ server.tool(
14
+ "generateSimulator",
15
+ "Genera un simulador financiero para un usuario usando su número de documento. Campos requeridos: \
16
+ id_lead (string, identificador único del lead), \
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
+ {
21
+ id_lead: z.string().min(1, "Lead ID is required"),
22
+ email_requester: z.string().email().min(1, "Email is required"),
23
+ income_updated: z.number().min(1, "Income is required"),
24
+ observations: z.string().min(1, "Observations are required"),
25
+ },
26
+ async ({ id_lead, email_requester, income_updated, observations }) => {
27
+ const user = await generateSimulator({
28
+ idLead: id_lead,
29
+ ingresosActualizados: income_updated,
30
+ observaciones: observations,
31
+ emailRequest: email_requester,
32
+ });
33
+ return {
34
+ content: [{ type: "text", text: JSON.stringify(user, null, 2) }]
35
+ };
36
+ }
37
+ );
38
+
39
+ // Start receiving messages on stdin and sending messages on stdout
40
+ const transport = new StdioServerTransport();
41
+ await server.connect(transport);
package/src/server.js ADDED
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+ import { generateSimulator } from "./handlers/simulator.js";
3
+
4
+ export async function buildHandlers() {
5
+ return [
6
+ {
7
+ name: "generateSimulator",
8
+ description: "generate financial simulator for a user using document number ",
9
+ schema: z.object({
10
+ id: z.string().describe("User ID to fetch"),
11
+ }),
12
+ handler: async ({ id }) => {
13
+ const user = await generateSimulator(id);
14
+ return {
15
+ content: [{ type: "text", text: JSON.stringify(user, null, 2) }],
16
+ };
17
+ },
18
+ },
19
+ ];
20
+ }
@@ -0,0 +1,16 @@
1
+ import { CONFIG } from "../config/config.js";
2
+
3
+
4
+ export async function apiFetch(path, options = {}) {
5
+ const res = await fetch(`${CONFIG.apiUrl}${path}`, {
6
+ ...options,
7
+ headers: { ...CONFIG.apiHeaders, ...(options.headers || {}) },
8
+ });
9
+
10
+ if (!res.ok) {
11
+ const text = await res.text();
12
+ throw new Error(`API error ${res.status}: ${text}`);
13
+ }
14
+
15
+ return res.json();
16
+ }
@@ -0,0 +1,23 @@
1
+ import { CONFIG } from "../config/config.js";
2
+
3
+ interface FetchOptions extends RequestInit {
4
+ headers?: Record<string, string>;
5
+ }
6
+
7
+ export async function apiFetch(path: string, options: FetchOptions = {}): Promise<any> {
8
+ const res = await fetch(`${CONFIG.apiUrl}${path}`, {
9
+ ...options,
10
+ headers: {
11
+ "Content-Type": "application/json",
12
+ "x-forwarded-authorization": "n8n amarilo",
13
+ ...options.headers,
14
+ },
15
+ });
16
+
17
+ if (!res.ok) {
18
+ const text = await res.text();
19
+ throw new Error(`API error ${res.status}: ${text}`);
20
+ }
21
+
22
+ return res.json();
23
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./dist",
4
+ "rootDir": "./src",
5
+ "target": "ESNext",
6
+ "module": "NodeNext",
7
+ "moduleResolution": "nodenext",
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "strict": true,
11
+ "skipLibCheck": true
12
+ }
13
+ }