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
@@ -0,0 +1,123 @@
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
+ /**
9
+ * Translates an API error response into an instructional message
10
+ * for the AI agent.
11
+ *
12
+ * @param response The failed API response
13
+ * @param context Description of what was being attempted (e.g., "creating application")
14
+ * @returns A formatted error message with guidance for the agent
15
+ */
16
+ export function handleApiError(response, context) {
17
+ const status = response.status;
18
+ const serverMessage = response.error || "Unknown error";
19
+ switch (status) {
20
+ case 400:
21
+ return [
22
+ `❌ Error ${context}: Bad Request.`,
23
+ `Server message: ${serverMessage}`,
24
+ ``,
25
+ `This usually means the subscription limit was reached.`,
26
+ `Tell the user they need to upgrade their plan. Do NOT retry this request.`,
27
+ ].join("\n");
28
+ case 401:
29
+ return [
30
+ `❌ Error ${context}: Authentication failed.`,
31
+ `Server message: ${serverMessage}`,
32
+ ``,
33
+ `The Agent API Key credentials are invalid, revoked, or the token could not be obtained.`,
34
+ `Tell the user to verify their IGNIRAL_CLIENT_ID and IGNIRAL_CLIENT_SECRET in the .env file.`,
35
+ `They can generate new credentials from the Igniral Dashboard → Agent API Keys.`,
36
+ `Do NOT retry — this requires the user to fix their credentials.`,
37
+ ].join("\n");
38
+ case 403:
39
+ return [
40
+ `❌ Error ${context}: Access denied.`,
41
+ `Server message: ${serverMessage}`,
42
+ ``,
43
+ `The Agent API Key does not have the required permissions,`,
44
+ `or the associated user account has been suspended.`,
45
+ `Tell the user to check their Agent API Key configuration in the Dashboard. Do NOT retry.`,
46
+ ].join("\n");
47
+ case 404:
48
+ return [
49
+ `❌ Error ${context}: Resource not found.`,
50
+ `Server message: ${serverMessage}`,
51
+ ``,
52
+ `The specified resource (applicationId or endpointId) does not exist`,
53
+ `or does not belong to the current user.`,
54
+ `Verify the ID is correct. You can use igniral_list_applications to check existing apps.`,
55
+ ].join("\n");
56
+ case 409:
57
+ return [
58
+ `❌ Error ${context}: Conflict — resource already exists.`,
59
+ `Server message: ${serverMessage}`,
60
+ ``,
61
+ `A resource with that name, subdomain, or endpoint path already exists.`,
62
+ `Try a different name or path and retry the request.`,
63
+ ].join("\n");
64
+ case 429:
65
+ return [
66
+ `🛑 FATAL Error ${context}: Too many requests.`,
67
+ `Server message: ${serverMessage}`,
68
+ ``,
69
+ `The rate limit has been exceeded. You MUST stop immediately.`,
70
+ `Do NOT retry. Do NOT call any other Igniral tools.`,
71
+ `Tell the user to wait a few minutes before trying again.`,
72
+ ].join("\n");
73
+ case 500:
74
+ case 502:
75
+ case 503:
76
+ return [
77
+ `❌ Error ${context}: Server error (${status}).`,
78
+ `Server message: ${serverMessage}`,
79
+ ``,
80
+ `The Igniral backend is experiencing issues.`,
81
+ `Ask the user to try again later. Do NOT retry automatically.`,
82
+ ].join("\n");
83
+ case 0:
84
+ return [
85
+ `❌ Error ${context}: Network error.`,
86
+ `Details: ${serverMessage}`,
87
+ ``,
88
+ `Could not connect to the Igniral API. This could be a network issue`,
89
+ `or the API server might be down.`,
90
+ `Tell the user to check their internet connection and IGNIRAL_API_URL configuration.`,
91
+ ].join("\n");
92
+ default:
93
+ return [
94
+ `❌ Error ${context}: Unexpected error (HTTP ${status}).`,
95
+ `Server message: ${serverMessage}`,
96
+ ``,
97
+ `An unexpected error occurred. Tell the user about this error`,
98
+ `and ask them to try again later.`,
99
+ ].join("\n");
100
+ }
101
+ }
102
+ /**
103
+ * Formats a Zod validation error into a helpful message for the agent.
104
+ */
105
+ export function handleValidationError(error) {
106
+ if (error && typeof error === "object" && "issues" in error) {
107
+ const issues = error.issues;
108
+ const details = issues
109
+ .map((i) => ` • ${i.path.join(".")}: ${i.message}`)
110
+ .join("\n");
111
+ return [
112
+ `❌ Validation Error: The parameters you provided are invalid.`,
113
+ ``,
114
+ `Issues:`,
115
+ details,
116
+ ``,
117
+ `Please fix these issues and try again with corrected values.`,
118
+ ].join("\n");
119
+ }
120
+ const message = error instanceof Error ? error.message : "Unknown validation error";
121
+ return `❌ Validation Error: ${message}. Please check the parameters and try again.`;
122
+ }
123
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAqB,EACrB,OAAe;IAEf,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/B,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,IAAI,eAAe,CAAC;IAExD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO;gBACL,WAAW,OAAO,gBAAgB;gBAClC,mBAAmB,aAAa,EAAE;gBAClC,EAAE;gBACF,wDAAwD;gBACxD,2EAA2E;aAC5E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEf,KAAK,GAAG;YACN,OAAO;gBACL,WAAW,OAAO,0BAA0B;gBAC5C,mBAAmB,aAAa,EAAE;gBAClC,EAAE;gBACF,yFAAyF;gBACzF,6FAA6F;gBAC7F,gFAAgF;gBAChF,iEAAiE;aAClE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEf,KAAK,GAAG;YACN,OAAO;gBACL,WAAW,OAAO,kBAAkB;gBACpC,mBAAmB,aAAa,EAAE;gBAClC,EAAE;gBACF,2DAA2D;gBAC3D,oDAAoD;gBACpD,0FAA0F;aAC3F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEf,KAAK,GAAG;YACN,OAAO;gBACL,WA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AAK,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAI,KAAgE,CAAC,MAAM,CAAC;QACxF,MAAM,OAAO,GAAG,MAAM;aACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;aACnD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,OAAO;YACL,8DAA8D;YAC9D,EAAE;YACF,SAAS;YACT,OAAO;YACP,EAAE;YACF,8DAA8D;SAC/D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC;IACpF,OAAO,uBAAuB,OAAO,8CAA8C,CAAC;AACtF,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Response Wrapper
3
+ *
4
+ * Wraps raw API responses in instructional text that helps the AI agent
5
+ * understand results and take appropriate next actions.
6
+ * This is the "trick" that makes MCP effective — the agent reads plain
7
+ * text, not raw JSON.
8
+ */
9
+ /**
10
+ * Wraps a successful application creation response.
11
+ */
12
+ export declare function wrapApplicationCreated(data: Record<string, unknown>): string;
13
+ /**
14
+ * Wraps a successful endpoint creation response.
15
+ */
16
+ export declare function wrapEndpointCreated(data: Record<string, unknown>): string;
17
+ /**
18
+ * Wraps a successful schema generation (Tool 1) response.
19
+ */
20
+ export declare function wrapGenerationComplete(data: Record<string, unknown>): string;
21
+ /**
22
+ * Wraps a list of applications response.
23
+ */
24
+ export declare function wrapApplicationList(data: Record<string, unknown>): string;
25
+ //# sourceMappingURL=response-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-wrapper.d.ts","sourceRoot":"","sources":["../../src/utils/response-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAgB5E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAqBzE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAe5E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,CA2BR"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Response Wrapper
3
+ *
4
+ * Wraps raw API responses in instructional text that helps the AI agent
5
+ * understand results and take appropriate next actions.
6
+ * This is the "trick" that makes MCP effective — the agent reads plain
7
+ * text, not raw JSON.
8
+ */
9
+ /**
10
+ * Wraps a successful application creation response.
11
+ */
12
+ export function wrapApplicationCreated(data) {
13
+ const id = data.id || "unknown";
14
+ const name = data.name || "unknown";
15
+ const subdomain = data.subdomain || "none";
16
+ return [
17
+ `✅ Success. Application created.`,
18
+ ``,
19
+ `• Application ID: ${id}`,
20
+ `• Name: ${name}`,
21
+ `• Subdomain: ${subdomain}`,
22
+ ``,
23
+ `You now have the applicationId needed to create endpoints.`,
24
+ `Use the igniral_create_dynamic_endpoint tool to add API endpoints to this application.`,
25
+ `Ask the user what data/resources their application should manage (e.g., users, products, orders).`,
26
+ ].join("\n");
27
+ }
28
+ /**
29
+ * Wraps a successful endpoint creation response.
30
+ */
31
+ export function wrapEndpointCreated(data) {
32
+ const id = data.id || "unknown";
33
+ const path = data.endpointPath || "unknown";
34
+ const methods = Array.isArray(data.allowedMethods)
35
+ ? data.allowedMethods.join(", ")
36
+ : "unknown";
37
+ const visibility = data.visibility || "PRIVATE";
38
+ const securityPolicy = data.securityPolicy || "NONE";
39
+ return [
40
+ `✅ Success. Dynamic endpoint created.`,
41
+ ``,
42
+ `• Endpoint ID: ${id}`,
43
+ `• Path: ${path}`,
44
+ `• Methods: ${methods}`,
45
+ `• Visibility: ${visibility}`,
46
+ `• Security Policy: ${securityPolicy}`,
47
+ ``,
48
+ `Ask the user if they want to create another endpoint for this application,`,
49
+ `or if the application is ready for use.`,
50
+ ].join("\n");
51
+ }
52
+ /**
53
+ * Wraps a successful schema generation (Tool 1) response.
54
+ */
55
+ export function wrapGenerationComplete(data) {
56
+ const applicationId = data.applicationId || "unknown";
57
+ const applicationName = data.applicationName || "unknown";
58
+ return [
59
+ `✅ Success. Application fully generated.`,
60
+ ``,
61
+ `• Application ID: ${applicationId}`,
62
+ `• Application Name: ${applicationName}`,
63
+ ``,
64
+ `The application was created with all endpoints, roles, and permissions automatically.`,
65
+ `You do NOT need to call create_application or create_endpoint — everything is already set up.`,
66
+ ``,
67
+ `Show this information to the user and ask if they would like to make any modifications.`,
68
+ ].join("\n");
69
+ }
70
+ /**
71
+ * Wraps a list of applications response.
72
+ */
73
+ export function wrapApplicationList(data) {
74
+ // The API returns a Page object with content array
75
+ const content = data.content || [];
76
+ if (content.length === 0) {
77
+ return [
78
+ `ℹ️ The user has no applications yet.`,
79
+ ``,
80
+ `You can help them create one using:`,
81
+ `• igniral_generate_schema_from_prompt — for automatic generation from a description`,
82
+ `• igniral_create_application — for manual step-by-step creation`,
83
+ ].join("\n");
84
+ }
85
+ const appLines = content.map((app, i) => {
86
+ const status = app.status ? "🟢 Active" : "🔴 Inactive";
87
+ const privacy = app.private ? "🔒 Private" : "🌐 Public";
88
+ return `${i + 1}. ${app.name} (ID: ${app.id}) — ${status} | ${privacy}`;
89
+ });
90
+ return [
91
+ `📋 User's applications (${content.length} total):`,
92
+ ``,
93
+ ...appLines,
94
+ ``,
95
+ `To add endpoints to an existing application, use igniral_create_dynamic_endpoint with the application ID.`,
96
+ ].join("\n");
97
+ }
98
+ //# sourceMappingURL=response-wrapper.js.map
@@ -0,0 +1 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GAAG,QAAQ;QACX,EAAE;QACF,2GAA2G;KAC5G,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Zod validation schemas for all MCP tool inputs.
3
+ *
4
+ * These schemas validate the parameters that the AI agent sends
5
+ * BEFORE forwarding requests to the Igniral backend.
6
+ * This prevents hallucinated or malformed data from reaching the API.
7
+ */
8
+ import { z } from "zod";
9
+ /**
10
+ * Tool 1: igniral_generate_schema_from_prompt
11
+ * Validates the natural language prompt for auto-generation.
12
+ */
13
+ export declare const generateSchemaInput: z.ZodObject<{
14
+ prompt: z.ZodString;
15
+ }, "strip", z.ZodTypeAny, {
16
+ prompt: string;
17
+ }, {
18
+ prompt: string;
19
+ }>;
20
+ /**
21
+ * Tool 2: igniral_create_application
22
+ * Validates application creation parameters.
23
+ * Maps to ApplicationRequest DTO in json-elements.
24
+ */
25
+ export declare const createApplicationInput: z.ZodObject<{
26
+ name: z.ZodString;
27
+ description: z.ZodString;
28
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
29
+ subdomain: z.ZodOptional<z.ZodString>;
30
+ aiGeneratedContext: z.ZodOptional<z.ZodString>;
31
+ isPrivate: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ name: string;
34
+ description: string;
35
+ version: string;
36
+ isPrivate: boolean;
37
+ subdomain?: string | undefined;
38
+ aiGeneratedContext?: string | undefined;
39
+ }, {
40
+ name: string;
41
+ description: string;
42
+ version?: string | undefined;
43
+ subdomain?: string | undefined;
44
+ aiGeneratedContext?: string | undefined;
45
+ isPrivate?: boolean | undefined;
46
+ }>;
47
+ /**
48
+ * Tool 3: igniral_create_dynamic_endpoint
49
+ * Validates endpoint creation parameters.
50
+ * Maps to DynamicEndpointRequest DTO in json-elements.
51
+ */
52
+ export declare const createEndpointInput: z.ZodEffects<z.ZodObject<{
53
+ applicationId: z.ZodString;
54
+ endpointPath: z.ZodString;
55
+ allowedMethods: z.ZodArray<z.ZodEnum<["GET", "POST", "PUT", "DELETE"]>, "many">;
56
+ schemaDefinition: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnknown>, Record<string, unknown>, Record<string, unknown>>;
57
+ type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["JSON", "FILE"]>>>;
58
+ visibility: z.ZodDefault<z.ZodOptional<z.ZodEnum<["PUBLIC", "PRIVATE"]>>>;
59
+ securityPolicy: z.ZodDefault<z.ZodOptional<z.ZodEnum<["NONE", "OWNER_ONLY", "CLAIM_FILTER"]>>>;
60
+ securityConfig: z.ZodOptional<z.ZodObject<{
61
+ claimFilterRules: z.ZodArray<z.ZodObject<{
62
+ payloadPath: z.ZodString;
63
+ claimName: z.ZodString;
64
+ }, "strip", z.ZodTypeAny, {
65
+ payloadPath: string;
66
+ claimName: string;
67
+ }, {
68
+ payloadPath: string;
69
+ claimName: string;
70
+ }>, "many">;
71
+ }, "strip", z.ZodTypeAny, {
72
+ claimFilterRules: {
73
+ payloadPath: string;
74
+ claimName: string;
75
+ }[];
76
+ }, {
77
+ claimFilterRules: {
78
+ payloadPath: string;
79
+ claimName: string;
80
+ }[];
81
+ }>>;
82
+ endpointDocumentation: z.ZodOptional<z.ZodString>;
83
+ }, "strip", z.ZodTypeAny, {
84
+ type: "JSON" | "FILE";
85
+ applicationId: string;
86
+ endpointPath: string;
87
+ allowedMethods: ("POST" | "GET" | "PUT" | "DELETE")[];
88
+ schemaDefinition: Record<string, unknown>;
89
+ visibility: "PUBLIC" | "PRIVATE";
90
+ securityPolicy: "NONE" | "OWNER_ONLY" | "CLAIM_FILTER";
91
+ securityConfig?: {
92
+ claimFilterRules: {
93
+ payloadPath: string;
94
+ claimName: string;
95
+ }[];
96
+ } | undefined;
97
+ endpointDocumentation?: string | undefined;
98
+ }, {
99
+ applicationId: string;
100
+ endpointPath: string;
101
+ allowedMethods: ("POST" | "GET" | "PUT" | "DELETE")[];
102
+ schemaDefinition: Record<string, unknown>;
103
+ type?: "JSON" | "FILE" | undefined;
104
+ visibility?: "PUBLIC" | "PRIVATE" | undefined;
105
+ securityPolicy?: "NONE" | "OWNER_ONLY" | "CLAIM_FILTER" | undefined;
106
+ securityConfig?: {
107
+ claimFilterRules: {
108
+ payloadPath: string;
109
+ claimName: string;
110
+ }[];
111
+ } | undefined;
112
+ endpointDocumentation?: string | undefined;
113
+ }>, {
114
+ type: "JSON" | "FILE";
115
+ applicationId: string;
116
+ endpointPath: string;
117
+ allowedMethods: ("POST" | "GET" | "PUT" | "DELETE")[];
118
+ schemaDefinition: Record<string, unknown>;
119
+ visibility: "PUBLIC" | "PRIVATE";
120
+ securityPolicy: "NONE" | "OWNER_ONLY" | "CLAIM_FILTER";
121
+ securityConfig?: {
122
+ claimFilterRules: {
123
+ payloadPath: string;
124
+ claimName: string;
125
+ }[];
126
+ } | undefined;
127
+ endpointDocumentation?: string | undefined;
128
+ }, {
129
+ applicationId: string;
130
+ endpointPath: string;
131
+ allowedMethods: ("POST" | "GET" | "PUT" | "DELETE")[];
132
+ schemaDefinition: Record<string, unknown>;
133
+ type?: "JSON" | "FILE" | undefined;
134
+ visibility?: "PUBLIC" | "PRIVATE" | undefined;
135
+ securityPolicy?: "NONE" | "OWNER_ONLY" | "CLAIM_FILTER" | undefined;
136
+ securityConfig?: {
137
+ claimFilterRules: {
138
+ payloadPath: string;
139
+ claimName: string;
140
+ }[];
141
+ } | undefined;
142
+ endpointDocumentation?: string | undefined;
143
+ }>;
144
+ export type GenerateSchemaInput = z.infer<typeof generateSchemaInput>;
145
+ export type CreateApplicationInput = z.infer<typeof createApplicationInput>;
146
+ export type CreateEndpointInput = z.infer<typeof createEndpointInput>;
147
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/validation/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;EAK9B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;EAgBjC,CAAC;AAgBH;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkC7B,CAAC;AAGJ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC5E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Zod validation schemas for all MCP tool inputs.
3
+ *
4
+ * These schemas validate the parameters that the AI agent sends
5
+ * BEFORE forwarding requests to the Igniral backend.
6
+ * This prevents hallucinated or malformed data from reaching the API.
7
+ */
8
+ import { z } from "zod";
9
+ /**
10
+ * Tool 1: igniral_generate_schema_from_prompt
11
+ * Validates the natural language prompt for auto-generation.
12
+ */
13
+ export const generateSchemaInput = z.object({
14
+ prompt: z
15
+ .string()
16
+ .min(10, "Prompt must be at least 10 characters to generate a meaningful application")
17
+ .max(2000, "Prompt must be under 2000 characters"),
18
+ });
19
+ /**
20
+ * Tool 2: igniral_create_application
21
+ * Validates application creation parameters.
22
+ * Maps to ApplicationRequest DTO in json-elements.
23
+ */
24
+ export const createApplicationInput = z.object({
25
+ name: z
26
+ .string()
27
+ .min(1, "Application name is required")
28
+ .max(100, "Application name must be under 100 characters"),
29
+ description: z
30
+ .string()
31
+ .min(1, "Application description is required")
32
+ .max(500, "Application description must be under 500 characters"),
33
+ version: z.string().optional().default("v1"),
34
+ subdomain: z
35
+ .string()
36
+ .regex(/^[a-z0-9-]+$/, "Subdomain must contain only lowercase letters, numbers, and hyphens")
37
+ .optional(),
38
+ aiGeneratedContext: z.string().optional(),
39
+ isPrivate: z.boolean().optional().default(true),
40
+ });
41
+ /**
42
+ * Security config for CLAIM_FILTER policy.
43
+ */
44
+ const securityConfigSchema = z.object({
45
+ claimFilterRules: z
46
+ .array(z.object({
47
+ payloadPath: z.string().min(1, "payloadPath is required"),
48
+ claimName: z.string().min(1, "claimName is required"),
49
+ }))
50
+ .min(1, "At least one claim filter rule is required"),
51
+ });
52
+ /**
53
+ * Tool 3: igniral_create_dynamic_endpoint
54
+ * Validates endpoint creation parameters.
55
+ * Maps to DynamicEndpointRequest DTO in json-elements.
56
+ */
57
+ export const createEndpointInput = z
58
+ .object({
59
+ applicationId: z.string().min(1, "applicationId is required"),
60
+ endpointPath: z
61
+ .string()
62
+ .min(1, "endpointPath is required")
63
+ .regex(/^\/[a-z0-9-/]+$/, "endpointPath must start with / and contain only lowercase letters, numbers, hyphens, and slashes"),
64
+ allowedMethods: z
65
+ .array(z.enum(["GET", "POST", "PUT", "DELETE"]))
66
+ .min(1, "At least one HTTP method is required"),
67
+ schemaDefinition: z.record(z.unknown()).refine((schema) => schema["type"] !== undefined || schema["$schema"] !== undefined, "schemaDefinition must be a valid JSON Schema with at least a 'type' or '$schema' property"),
68
+ type: z.enum(["JSON", "FILE"]).optional().default("JSON"),
69
+ visibility: z.enum(["PUBLIC", "PRIVATE"]).optional().default("PRIVATE"),
70
+ securityPolicy: z
71
+ .enum(["NONE", "OWNER_ONLY", "CLAIM_FILTER"])
72
+ .optional()
73
+ .default("NONE"),
74
+ securityConfig: securityConfigSchema.optional(),
75
+ endpointDocumentation: z.string().optional(),
76
+ })
77
+ .refine((data) => data.securityPolicy !== "CLAIM_FILTER" || data.securityConfig != null, {
78
+ message: "securityConfig with claimFilterRules is required when securityPolicy is CLAIM_FILTER",
79
+ path: ["securityConfig"],
80
+ });
81
+ //#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;SACd,IAAI,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;SAC5C,QAAQ,EAAE;SACV,OAAO,CAAC,MAAM,CAAC;IAClB,cAAc,EAAE,oBAAoB,CAAC,QAAQ,EAAE;IAC/C,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7C,CAAC;KACD,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,cAAc,KAAK,cAAc,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,EACvE;IACE,OAAO,EACL,sFAAsF;IACxF,IAAI,EAAE,CAAC,gBAAgB,CAAC;CACzB,CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "igniral-mcp-server",
3
+ "version": "1.0.4",
4
+ "description": "Igniral MCP Server — Model Context Protocol bridge for AI agents to interact with Igniral's backend APIs",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "bin": {
9
+ "igniral-mcp-server": "dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "prepublishOnly": "npm run build",
19
+ "start": "node dist/index.js",
20
+ "dev": "tsx src/index.ts",
21
+ "inspect": "npx @modelcontextprotocol/inspector tsx src/index.ts"
22
+ },
23
+ "keywords": [
24
+ "mcp",
25
+ "igniral",
26
+ "ai",
27
+ "api",
28
+ "model-context-protocol",
29
+ "claude",
30
+ "cursor"
31
+ ],
32
+ "author": "Igniral",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/igniral/igniral-mcp-server.git"
37
+ },
38
+ "homepage": "https://github.com/igniral/igniral-mcp-server#readme",
39
+ "engines": {
40
+ "node": ">=18.0.0"
41
+ },
42
+ "dependencies": {
43
+ "@modelcontextprotocol/sdk": "^1.12.1",
44
+ "zod": "^3.24.4",
45
+ "eventsource": "^3.0.7"
46
+ },
47
+ "devDependencies": {
48
+ "typescript": "^5.8.3",
49
+ "tsx": "^4.19.4",
50
+ "@types/node": "^22.15.3",
51
+ "@types/eventsource": "^1.1.15"
52
+ }
53
+ }