igniral-mcp-server 1.0.4

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.
Files changed (46) hide show
  1. package/README.md +162 -0
  2. package/dist/api/TokenManager.d.ts +23 -0
  3. package/dist/api/TokenManager.d.ts.map +1 -0
  4. package/dist/api/TokenManager.js +82 -0
  5. package/dist/api/TokenManager.js.map +1 -0
  6. package/dist/api/igniral-client.d.ts +50 -0
  7. package/dist/api/igniral-client.d.ts.map +1 -0
  8. package/dist/api/igniral-client.js +116 -0
  9. package/dist/api/igniral-client.js.map +1 -0
  10. package/dist/config.d.ts +19 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/config.js +34 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/index.d.ts +17 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +181 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/tools/create-application.d.ts +20 -0
  19. package/dist/tools/create-application.d.ts.map +1 -0
  20. package/dist/tools/create-application.js +47 -0
  21. package/dist/tools/create-application.js.map +1 -0
  22. package/dist/tools/create-endpoint.d.ts +17 -0
  23. package/dist/tools/create-endpoint.d.ts.map +1 -0
  24. package/dist/tools/create-endpoint.js +49 -0
  25. package/dist/tools/create-endpoint.js.map +1 -0
  26. package/dist/tools/generate-schema.d.ts +25 -0
  27. package/dist/tools/generate-schema.d.ts.map +1 -0
  28. package/dist/tools/generate-schema.js +142 -0
  29. package/dist/tools/generate-schema.js.map +1 -0
  30. package/dist/tools/list-applications.d.ts +19 -0
  31. package/dist/tools/list-applications.d.ts.map +1 -0
  32. package/dist/tools/list-applications.js +27 -0
  33. package/dist/tools/list-applications.js.map +1 -0
  34. package/dist/utils/error-handler.d.ts +22 -0
  35. package/dist/utils/error-handler.d.ts.map +1 -0
  36. package/dist/utils/error-handler.js +123 -0
  37. package/dist/utils/error-handler.js.map +1 -0
  38. package/dist/utils/response-wrapper.d.ts +25 -0
  39. package/dist/utils/response-wrapper.d.ts.map +1 -0
  40. package/dist/utils/response-wrapper.js +98 -0
  41. package/dist/utils/response-wrapper.js.map +1 -0
  42. package/dist/validation/schemas.d.ts +147 -0
  43. package/dist/validation/schemas.d.ts.map +1 -0
  44. package/dist/validation/schemas.js +81 -0
  45. package/dist/validation/schemas.js.map +1 -0
  46. package/package.json +53 -0
package/dist/index.js ADDED
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Igniral MCP Server — Entry Point
4
+ *
5
+ * A Model Context Protocol server that bridges AI agents (Claude, Cursor, etc.)
6
+ * with Igniral's backend microservices for dynamic API creation and management.
7
+ *
8
+ * Transport: stdio (standard for IDE integrations like Cursor and Claude Desktop)
9
+ *
10
+ * Tools exposed:
11
+ * 1. igniral_generate_schema_from_prompt — Auto-generate a complete app from description
12
+ * 2. igniral_create_application — Create an empty app shell manually
13
+ * 3. igniral_create_dynamic_endpoint — Add endpoints to an existing app
14
+ * 4. igniral_list_applications — List the user's existing applications
15
+ */
16
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
17
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
18
+ import { z } from "zod";
19
+ import { loadConfig } from "./config.js";
20
+ import { IgniralClient } from "./api/igniral-client.js";
21
+ import { executeGenerateSchema } from "./tools/generate-schema.js";
22
+ import { executeCreateApplication } from "./tools/create-application.js";
23
+ import { executeCreateEndpoint } from "./tools/create-endpoint.js";
24
+ import { executeListApplications } from "./tools/list-applications.js";
25
+ // ─── Bootstrap ──────────────────────────────────────────────────────────
26
+ let config;
27
+ let client;
28
+ try {
29
+ config = loadConfig();
30
+ client = new IgniralClient(config);
31
+ }
32
+ catch (error) {
33
+ const message = error instanceof Error ? error.message : String(error);
34
+ console.error(`\n✖ ${message}\n`);
35
+ console.error("Tip: Pass credentials via environment variables when configuring your MCP client:");
36
+ console.error(' "env": { "IGNIRAL_CLIENT_ID": "...", "IGNIRAL_CLIENT_SECRET": "..." }\n');
37
+ console.error("Get your Agent API Key at: https://igniral.com\n");
38
+ process.exit(1);
39
+ }
40
+ const server = new McpServer({
41
+ name: "igniral-mcp-server",
42
+ version: "1.0.2",
43
+ });
44
+ // ─── Tool 1: Generate Schema from Prompt ────────────────────────────────
45
+ server.tool("igniral_generate_schema_from_prompt", `Generates a complete application from a natural language description.
46
+ This tool creates the application, ALL endpoints with their JSON schemas,
47
+ roles, and permissions automatically.
48
+
49
+ Use this when the user gives a general or ambiguous instruction like
50
+ "build me a gym management app" or "create an API for a restaurant".
51
+
52
+ You do NOT need to call igniral_create_application or
53
+ igniral_create_dynamic_endpoint after this — everything is created
54
+ automatically. This may take 30-90 seconds to complete.
55
+
56
+ Returns the applicationId and a summary of what was created.`, {
57
+ prompt: z
58
+ .string()
59
+ .describe("Natural language description of the application to generate. " +
60
+ "Be as detailed as possible about what the app should do and " +
61
+ "what data it should manage. Minimum 10 characters."),
62
+ }, async ({ prompt }) => {
63
+ const result = await executeGenerateSchema(client, { prompt });
64
+ return { content: [{ type: "text", text: result }] };
65
+ });
66
+ // ─── Tool 2: Create Application ─────────────────────────────────────────
67
+ server.tool("igniral_create_application", `Creates an empty application shell (without endpoints).
68
+ Use this when the user wants to manually build an application step by step,
69
+ providing a specific name, description, and settings.
70
+
71
+ After creating the application, use igniral_create_dynamic_endpoint to add
72
+ API endpoints one by one. Returns the applicationId needed for creating endpoints.
73
+
74
+ Do NOT use this after igniral_generate_schema_from_prompt — that tool
75
+ already creates the application automatically.`, {
76
+ name: z.string().describe("Name of the application (e.g., 'GymApp', 'Pet Store API')"),
77
+ description: z.string().describe("Description of what the application does"),
78
+ version: z.string().optional().describe("API version (default: 'v1')"),
79
+ subdomain: z
80
+ .string()
81
+ .optional()
82
+ .describe("Custom subdomain for the API (lowercase, hyphens allowed). " +
83
+ "If not provided, one is generated automatically."),
84
+ aiGeneratedContext: z
85
+ .string()
86
+ .optional()
87
+ .describe("AI-generated context/documentation for the application"),
88
+ isPrivate: z
89
+ .boolean()
90
+ .optional()
91
+ .describe("Whether the app is private (default: true). " +
92
+ "Private apps require authentication for all endpoints. " +
93
+ "Public apps can have some endpoints visible without auth."),
94
+ }, async (params) => {
95
+ const result = await executeCreateApplication(client, params);
96
+ return { content: [{ type: "text", text: result }] };
97
+ });
98
+ // ─── Tool 3: Create Dynamic Endpoint ────────────────────────────────────
99
+ server.tool("igniral_create_dynamic_endpoint", `Creates a dynamic API endpoint within an existing application.
100
+ Requires an applicationId from a previous igniral_create_application call.
101
+
102
+ Use this iteratively to add all needed endpoints to the application.
103
+ Each endpoint defines its data schema (JSON Schema format), HTTP methods,
104
+ visibility (PUBLIC/PRIVATE), and security policy.
105
+
106
+ Security policies:
107
+ - NONE: Anyone with role permissions sees all data
108
+ - OWNER_ONLY: Users only see data they created (most common for personal data)
109
+ - CLAIM_FILTER: Filter data based on JWT claims (requires securityConfig)`, {
110
+ applicationId: z.string().describe("ID of the application to add the endpoint to"),
111
+ endpointPath: z
112
+ .string()
113
+ .describe("URL path for the endpoint (e.g., '/products', '/users', '/orders'). " +
114
+ "Must start with / and use lowercase letters, numbers, and hyphens."),
115
+ allowedMethods: z
116
+ .array(z.string())
117
+ .describe("HTTP methods to enable: ['GET', 'POST', 'PUT', 'DELETE']. " +
118
+ "Include all methods the endpoint should support."),
119
+ schemaDefinition: z
120
+ .record(z.string(), z.unknown())
121
+ .describe("JSON Schema defining the data structure for this endpoint. " +
122
+ 'Must include "$schema", "type": "object", and "properties". ' +
123
+ "Each property needs a type (string, number, integer, boolean, array, object)."),
124
+ type: z
125
+ .enum(["JSON", "FILE"])
126
+ .optional()
127
+ .describe("Endpoint type: 'JSON' for data APIs (default), 'FILE' for file uploads"),
128
+ visibility: z
129
+ .enum(["PUBLIC", "PRIVATE"])
130
+ .optional()
131
+ .describe("Endpoint visibility: 'PRIVATE' (default, requires auth) or " +
132
+ "'PUBLIC' (accessible without auth, only for public apps)"),
133
+ securityPolicy: z
134
+ .enum(["NONE", "OWNER_ONLY", "CLAIM_FILTER"])
135
+ .optional()
136
+ .describe("Data access control: 'NONE' (shared data), " +
137
+ "'OWNER_ONLY' (users see only their data), " +
138
+ "'CLAIM_FILTER' (filter by JWT claims, requires securityConfig)"),
139
+ securityConfig: z
140
+ .object({
141
+ claimFilterRules: z.array(z.object({
142
+ payloadPath: z.string(),
143
+ claimName: z.string(),
144
+ })),
145
+ })
146
+ .optional()
147
+ .describe("Required when securityPolicy is 'CLAIM_FILTER'. " +
148
+ "Defines which JWT claim maps to which data field for filtering."),
149
+ endpointDocumentation: z
150
+ .string()
151
+ .optional()
152
+ .describe("Human-readable documentation for this endpoint"),
153
+ }, async (params) => {
154
+ const result = await executeCreateEndpoint(client, params);
155
+ return { content: [{ type: "text", text: result }] };
156
+ });
157
+ // ─── Tool 4: List Applications ──────────────────────────────────────────
158
+ server.tool("igniral_list_applications", `Lists all applications owned by the current user.
159
+ Use this to check what applications already exist before creating new ones,
160
+ or to get the applicationId of an existing application.
161
+
162
+ Takes no parameters — the user is identified by the configured service token.`, {}, async () => {
163
+ const result = await executeListApplications(client);
164
+ return { content: [{ type: "text", text: result }] };
165
+ });
166
+ // ─── Start Server ───────────────────────────────────────────────────────
167
+ async function main() {
168
+ const transport = new StdioServerTransport();
169
+ await server.connect(transport);
170
+ // Log to stderr (not stdout, which is used by MCP protocol)
171
+ console.error("Igniral MCP Server v1.0.0 started");
172
+ console.error(`Connected to API: ${config.apiUrl}`);
173
+ console.error(`Connected to AI API: ${config.aiApiUrl}`);
174
+ console.error(`Auth server: ${config.authUrl}`);
175
+ }
176
+ main().catch((error) => {
177
+ const message = error instanceof Error ? error.message : String(error);
178
+ console.error(`\n✖ Fatal error: ${message}\n`);
179
+ process.exit(1);
180
+ });
181
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCA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B,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,IAAI,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Tool 2: igniral_create_application
3
+ *
4
+ * Creates an empty application shell (without endpoints).
5
+ * Use this when the user wants to manually build an application
6
+ * step by step, providing specific name, description, and settings.
7
+ *
8
+ * After creating the application, use igniral_create_dynamic_endpoint
9
+ * to add endpoints one by one.
10
+ */
11
+ import { IgniralClient } from "../api/igniral-client.js";
12
+ /**
13
+ * Executes the create-application tool.
14
+ *
15
+ * @param client The Igniral API client
16
+ * @param params Raw parameters from the AI agent
17
+ * @returns MCP tool result content
18
+ */
19
+ export declare function executeCreateApplication(client: IgniralClient, params: Record<string, unknown>): Promise<string>;
20
+ //# sourceMappingURL=create-application.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-application.d.ts","sourceRoot":"","sources":["../../src/tools/create-application.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAQzD;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Tool 2: igniral_create_application
3
+ *
4
+ * Creates an empty application shell (without endpoints).
5
+ * Use this when the user wants to manually build an application
6
+ * step by step, providing specific name, description, and settings.
7
+ *
8
+ * After creating the application, use igniral_create_dynamic_endpoint
9
+ * to add endpoints one by one.
10
+ */
11
+ import { createApplicationInput } from "../validation/schemas.js";
12
+ import { wrapApplicationCreated } from "../utils/response-wrapper.js";
13
+ import { handleApiError, handleValidationError, } from "../utils/error-handler.js";
14
+ /**
15
+ * Executes the create-application tool.
16
+ *
17
+ * @param client The Igniral API client
18
+ * @param params Raw parameters from the AI agent
19
+ * @returns MCP tool result content
20
+ */
21
+ export async function executeCreateApplication(client, params) {
22
+ // 1. Validate input with Zod
23
+ const parsed = createApplicationInput.safeParse(params);
24
+ if (!parsed.success) {
25
+ return handleValidationError(parsed.error);
26
+ }
27
+ const { name, description, version, subdomain, aiGeneratedContext, isPrivate } = parsed.data;
28
+ // 2. Build request body (matches ApplicationRequest DTO)
29
+ const body = {
30
+ name,
31
+ description,
32
+ version,
33
+ isPrivate,
34
+ };
35
+ if (subdomain)
36
+ body.subdomain = subdomain;
37
+ if (aiGeneratedContext)
38
+ body.aiGeneratedContext = aiGeneratedContext;
39
+ // 3. Call the AI-generate endpoint
40
+ const response = await client.postToApi("/api/igniral-user-application/ai-generate", body);
41
+ if (!response.ok) {
42
+ return handleApiError(response, "creating application");
43
+ }
44
+ // 4. Wrap response in instructional text
45
+ return wrapApplicationCreated(response.data);
46
+ }
47
+ //# sourceMappingURL=create-application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-application.js","sourceRoot":"","sources":["../../src/tools/create-application.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,MAAqB,EACrB,MAA+B;IAE/B,6BAA6B;IAC7B,MAAM,MAAM,GAAG,sBAAsB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,qBAAqB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,SAAS,EAAE,GAC5E,MAAM,CAAC,IAAI,CAAC;IAEd,yDAAyD;IACzD,MAAM,IAAI,GAA4B;QACpC,IAAI;QACJ,WAAW;QACX,OAAO;QACP,SAAS;KACV,CAAC;IAEF,IAAI,SAAS;QAAE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC1C,IAAI,kBAAkB;QAAE,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAErE,mCAAmC;IACnC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CACrC,2CAA2C,EAC3C,IAAI,CACL,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,cAAc,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;IAC1D,CAAC;IAED,yCAAyC;IACzC,OAAO,sBAAsB,CAAC,QAAQ,CAAC,IAA+B,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Tool 3: igniral_create_dynamic_endpoint
3
+ *
4
+ * Creates a dynamic API endpoint within an existing application.
5
+ * Requires an applicationId from a previous create_application call.
6
+ * Use this iteratively to add all needed endpoints to the application.
7
+ */
8
+ import { IgniralClient } from "../api/igniral-client.js";
9
+ /**
10
+ * Executes the create-dynamic-endpoint tool.
11
+ *
12
+ * @param client The Igniral API client
13
+ * @param params Raw parameters from the AI agent
14
+ * @returns MCP tool result content
15
+ */
16
+ export declare function executeCreateEndpoint(client: IgniralClient, params: Record<string, unknown>): Promise<string>;
17
+ //# sourceMappingURL=create-endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-endpoint.d.ts","sourceRoot":"","sources":["../../src/tools/create-endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAQzD;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,CAuCjB"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Tool 3: igniral_create_dynamic_endpoint
3
+ *
4
+ * Creates a dynamic API endpoint within an existing application.
5
+ * Requires an applicationId from a previous create_application call.
6
+ * Use this iteratively to add all needed endpoints to the application.
7
+ */
8
+ import { createEndpointInput } from "../validation/schemas.js";
9
+ import { wrapEndpointCreated } from "../utils/response-wrapper.js";
10
+ import { handleApiError, handleValidationError, } from "../utils/error-handler.js";
11
+ /**
12
+ * Executes the create-dynamic-endpoint tool.
13
+ *
14
+ * @param client The Igniral API client
15
+ * @param params Raw parameters from the AI agent
16
+ * @returns MCP tool result content
17
+ */
18
+ export async function executeCreateEndpoint(client, params) {
19
+ // 1. Validate input with Zod (includes securityConfig conditional check)
20
+ const parsed = createEndpointInput.safeParse(params);
21
+ if (!parsed.success) {
22
+ return handleValidationError(parsed.error);
23
+ }
24
+ const validated = parsed.data;
25
+ // 2. Build request body (matches DynamicEndpointRequest DTO)
26
+ const body = {
27
+ applicationId: validated.applicationId,
28
+ endpointPath: validated.endpointPath,
29
+ allowedMethods: validated.allowedMethods,
30
+ schemaDefinition: validated.schemaDefinition,
31
+ type: validated.type,
32
+ visibility: validated.visibility,
33
+ securityPolicy: validated.securityPolicy,
34
+ };
35
+ if (validated.securityConfig) {
36
+ body.securityConfig = validated.securityConfig;
37
+ }
38
+ if (validated.endpointDocumentation) {
39
+ body.endpointDocumentation = validated.endpointDocumentation;
40
+ }
41
+ // 3. Call the AI-generate endpoint
42
+ const response = await client.postToApi("/api/igniral-user-dynamic-endpoint/ai-generate", body);
43
+ if (!response.ok) {
44
+ return handleApiError(response, "creating dynamic endpoint");
45
+ }
46
+ // 4. Wrap response in instructional text
47
+ return wrapEndpointCreated(response.data);
48
+ }
49
+ //# sourceMappingURL=create-endpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-endpoint.js","sourceRoot":"","sources":["../../src/tools/create-endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAqB,EACrB,MAA+B;IAE/B,yEAAyE;IACzE,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,qBAAqB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC;IAE9B,6DAA6D;IAC7D,MAAM,IAAI,GAA4B;QACpC,aAAa,EAAE,SAAS,CAAC,aAAa;QACtC,YAAY,EAAE,SAAS,CAAC,YAAY;QACpC,cAAc,EAAE,SAAS,CAAC,cAAc;QACxC,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;QAC5C,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,UAAU,EAAE,SAAS,CAAC,UAAU;QAChC,cAAc,EAAE,SAAS,CAAC,cAAc;KACzC,CAAC;IAEF,IAAI,SAAS,CAAC,cAAc,EAAE,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,cAAc,CAAC;IACjD,CAAC;IACD,IAAI,SAAS,CAAC,qBAAqB,EAAE,CAAC;QACpC,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC,qBAAqB,CAAC;IAC/D,CAAC;IAED,mCAAmC;IACnC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CACrC,gDAAgD,EAChD,IAAI,CACL,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,cAAc,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;IAC/D,CAAC;IAED,yCAAyC;IACzC,OAAO,mBAAmB,CAAC,QAAQ,CAAC,IAA+B,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Tool 1: igniral_generate_schema_from_prompt
3
+ *
4
+ * Generates a complete application from a natural language description.
5
+ * This tool creates the application, ALL endpoints with their schemas,
6
+ * roles, and permissions automatically.
7
+ *
8
+ * Internally:
9
+ * 1. Opens an SSE connection to listen for generation progress
10
+ * 2. Posts the prompt to the ai-schema-builder (which returns 202 Accepted)
11
+ * 3. Waits for the SSE "complete" or "error" event
12
+ * 4. Returns the final result to the agent
13
+ *
14
+ * The agent sees this as a synchronous tool call.
15
+ */
16
+ import { IgniralClient } from "../api/igniral-client.js";
17
+ /**
18
+ * Executes the generate-schema-from-prompt tool.
19
+ *
20
+ * @param client The Igniral API client
21
+ * @param params Raw parameters from the AI agent
22
+ * @returns MCP tool result content
23
+ */
24
+ export declare function executeGenerateSchema(client: IgniralClient, params: Record<string, unknown>): Promise<string>;
25
+ //# sourceMappingURL=generate-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-schema.d.ts","sourceRoot":"","sources":["../../src/tools/generate-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAoBzD;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,CAmDjB"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Tool 1: igniral_generate_schema_from_prompt
3
+ *
4
+ * Generates a complete application from a natural language description.
5
+ * This tool creates the application, ALL endpoints with their schemas,
6
+ * roles, and permissions automatically.
7
+ *
8
+ * Internally:
9
+ * 1. Opens an SSE connection to listen for generation progress
10
+ * 2. Posts the prompt to the ai-schema-builder (which returns 202 Accepted)
11
+ * 3. Waits for the SSE "complete" or "error" event
12
+ * 4. Returns the final result to the agent
13
+ *
14
+ * The agent sees this as a synchronous tool call.
15
+ */
16
+ import { EventSource } from "eventsource";
17
+ import { generateSchemaInput } from "../validation/schemas.js";
18
+ import { wrapGenerationComplete } from "../utils/response-wrapper.js";
19
+ import { handleApiError, handleValidationError, } from "../utils/error-handler.js";
20
+ /** SSE timeout: 180 seconds (matches server-side SseEmitter timeout) */
21
+ const SSE_TIMEOUT_MS = 180_000;
22
+ /**
23
+ * Executes the generate-schema-from-prompt tool.
24
+ *
25
+ * @param client The Igniral API client
26
+ * @param params Raw parameters from the AI agent
27
+ * @returns MCP tool result content
28
+ */
29
+ export async function executeGenerateSchema(client, params) {
30
+ // 1. Validate input
31
+ const parsed = generateSchemaInput.safeParse(params);
32
+ if (!parsed.success) {
33
+ return handleValidationError(parsed.error);
34
+ }
35
+ const { prompt } = parsed.data;
36
+ try {
37
+ const sseHeaders = await client.getSseHeaders();
38
+ // 2. Open SSE connection FIRST (before triggering generation)
39
+ const resultPromise = waitForGenerationResult(client, sseHeaders);
40
+ // 3. Trigger the async generation
41
+ const triggerResponse = await client.postToAiApi("/api/ai/generate-application", { prompt });
42
+ // If the trigger itself fails (not 202), report immediately
43
+ if (!triggerResponse.ok && triggerResponse.status !== 202) {
44
+ return handleApiError(triggerResponse, "triggering application generation");
45
+ }
46
+ // 4. Wait for SSE to deliver the result
47
+ const result = await resultPromise;
48
+ if (result.status === "SUCCESS") {
49
+ return wrapGenerationComplete(result);
50
+ }
51
+ else {
52
+ return [
53
+ `❌ Application generation failed.`,
54
+ ``,
55
+ `Error: ${result.message || "Unknown error during generation"}`,
56
+ ``,
57
+ `This may be due to a problem with the AI model or the prompt.`,
58
+ `Ask the user to try rephrasing their request with more details.`,
59
+ ].join("\n");
60
+ }
61
+ }
62
+ catch (error) {
63
+ const message = error instanceof Error ? error.message : "Unknown error";
64
+ return [
65
+ `❌ Error during application generation.`,
66
+ ``,
67
+ `Details: ${message}`,
68
+ ``,
69
+ `Ask the user to try again later.`,
70
+ ].join("\n");
71
+ }
72
+ }
73
+ /**
74
+ * Opens an SSE connection and returns a promise that resolves
75
+ * when a "complete" or "error" event is received.
76
+ *
77
+ * eventsource v3 follows the browser spec and doesn't support
78
+ * custom headers directly. We use the `fetch` option to inject
79
+ * Authorization headers via a custom fetch wrapper.
80
+ */
81
+ function waitForGenerationResult(client, sseHeaders) {
82
+ return new Promise((resolve, reject) => {
83
+ const sseUrl = client.getSseUrl();
84
+ // Custom fetch that injects auth headers into the SSE connection
85
+ const fetchWithAuth = (input, init) => {
86
+ const headers = new Headers(init?.headers);
87
+ for (const [key, value] of Object.entries(sseHeaders)) {
88
+ headers.set(key, value);
89
+ }
90
+ return fetch(input, { ...init, headers });
91
+ };
92
+ const eventSource = new EventSource(sseUrl, {
93
+ fetch: fetchWithAuth,
94
+ });
95
+ // Timeout handler
96
+ const timeout = setTimeout(() => {
97
+ eventSource.close();
98
+ reject(new Error("Generation timed out after 180 seconds. " +
99
+ "The AI model may be overloaded. Ask the user to try again later."));
100
+ }, SSE_TIMEOUT_MS);
101
+ // Listen for completion
102
+ eventSource.addEventListener("complete", ((event) => {
103
+ clearTimeout(timeout);
104
+ eventSource.close();
105
+ try {
106
+ const data = JSON.parse(event.data);
107
+ data.status = data.status || "SUCCESS";
108
+ resolve(data);
109
+ }
110
+ catch {
111
+ resolve({ status: "SUCCESS", message: event.data });
112
+ }
113
+ }));
114
+ // Listen for named "error" events from the backend (generation failures)
115
+ eventSource.addEventListener("error", ((event) => {
116
+ const messageEvent = event;
117
+ // Only handle named "error" events with data (not SSE connection errors)
118
+ if (messageEvent.data) {
119
+ clearTimeout(timeout);
120
+ eventSource.close();
121
+ try {
122
+ const data = JSON.parse(messageEvent.data);
123
+ data.status = "ERROR";
124
+ resolve(data);
125
+ }
126
+ catch {
127
+ resolve({ status: "ERROR", message: messageEvent.data });
128
+ }
129
+ }
130
+ }));
131
+ // Handle SSE connection-level errors
132
+ eventSource.onerror = () => {
133
+ // EventSource auto-reconnects, but if it fails completely:
134
+ if (eventSource.readyState === EventSource.CLOSED) {
135
+ clearTimeout(timeout);
136
+ reject(new Error("SSE connection to Igniral backend failed. " +
137
+ "Check that IGNIRAL_AI_API_URL is correct and the server is running."));
138
+ }
139
+ };
140
+ });
141
+ }
142
+ //# sourceMappingURL=generate-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-schema.js","sourceRoot":"","sources":["../../src/tools/generate-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,wEAAwE;AACxE,MAAM,cAAc,GAAG,OAAO,CAAC;AAW/B;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAqB,EACrB,MAA+B;IAE/B,oBAAoB;IACpB,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,qBAAqB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC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AE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,CAAkB,CAAC,CAAC;QAErB,yEAAyE;QACzE,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,KAAY,EAAE,EAAE;YACtD,MAAM,YAAY,GAAG,KAAqB,CAAC;YAC3C,yEAAyE;YACzE,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC;gBACtB,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtB,WAAW,CAAC,KAAK,EAAE,CAAC;gBACpB,IAAI,CAAC;oBACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAoB,CAAC;oBAC9D,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;oBACtB,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;QACH,CAAC,CAAkB,CAAC,CAAC;QAErB,qCAAqC;QACrC,WAAW,CAAC,OAAO,GAAG,GAAG,EAAE;YACzB,2DAA2D;YAC3D,IAAI,WAAW,CAAC,UAAU,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;gBAClD,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtB,MAAM,CACJ,IAAI,KAAK,CACP,4CAA4C;oBAC1C,qEAAqE,CACxE,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Tool 4: igniral_list_applications
3
+ *
4
+ * Lists all applications owned by the current user.
5
+ * Use this to check what applications already exist before creating
6
+ * new ones, or to get the applicationId of an existing application.
7
+ *
8
+ * Note: This calls the standard GET endpoint which uses jwt.sub
9
+ * for user identification. The token must have sub=userId.
10
+ */
11
+ import { IgniralClient } from "../api/igniral-client.js";
12
+ /**
13
+ * Executes the list-applications tool.
14
+ *
15
+ * @param client The Igniral API client
16
+ * @returns MCP tool result content
17
+ */
18
+ export declare function executeListApplications(client: IgniralClient): Promise<string>;
19
+ //# sourceMappingURL=list-applications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-applications.d.ts","sourceRoot":"","sources":["../../src/tools/list-applications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAIzD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,MAAM,CAAC,CAWjB"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Tool 4: igniral_list_applications
3
+ *
4
+ * Lists all applications owned by the current user.
5
+ * Use this to check what applications already exist before creating
6
+ * new ones, or to get the applicationId of an existing application.
7
+ *
8
+ * Note: This calls the standard GET endpoint which uses jwt.sub
9
+ * for user identification. The token must have sub=userId.
10
+ */
11
+ import { wrapApplicationList } from "../utils/response-wrapper.js";
12
+ import { handleApiError } from "../utils/error-handler.js";
13
+ /**
14
+ * Executes the list-applications tool.
15
+ *
16
+ * @param client The Igniral API client
17
+ * @returns MCP tool result content
18
+ */
19
+ export async function executeListApplications(client) {
20
+ // Call GET /api/igniral-user-application with pagination defaults
21
+ const response = await client.getFromApi("/api/igniral-user-application?page=0&size=50&sort=createdAt,desc");
22
+ if (!response.ok) {
23
+ return handleApiError(response, "listing applications");
24
+ }
25
+ return wrapApplicationList(response.data);
26
+ }
27
+ //# sourceMappingURL=list-applications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-applications.js","sourceRoot":"","sources":["../../src/tools/list-applications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAAqB;IAErB,kEAAkE;IAClE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,UAAU,CACtC,kEAAkE,CACnE,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,cAAc,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,mBAAmB,CAAC,QAAQ,CAAC,IAA+B,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Error Handler
3
+ *
4
+ * Maps HTTP error responses from Igniral's backend into clear,
5
+ * actionable messages for the AI agent. Includes instructions on
6
+ * whether to retry, modify input, or ask the user for help.
7
+ */
8
+ import { ApiResponse } from "../api/igniral-client.js";
9
+ /**
10
+ * Translates an API error response into an instructional message
11
+ * for the AI agent.
12
+ *
13
+ * @param response The failed API response
14
+ * @param context Description of what was being attempted (e.g., "creating application")
15
+ * @returns A formatted error message with guidance for the agent
16
+ */
17
+ export declare function handleApiError(response: ApiResponse, context: string): string;
18
+ /**
19
+ * Formats a Zod validation error into a helpful message for the agent.
20
+ */
21
+ export declare function handleValidationError(error: unknown): string;
22
+ //# sourceMappingURL=error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,MAAM,GACd,MAAM,CA8FR;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkB5D"}