@ibm/ibmi-mcp-server 0.2.0 → 0.3.0

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 (197) hide show
  1. package/README.md +140 -0
  2. package/dist/config/index.d.ts +2 -0
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/config/index.js +14 -0
  5. package/dist/config/index.js.map +1 -1
  6. package/dist/config/resolver.d.ts.map +1 -1
  7. package/dist/config/resolver.js.map +1 -1
  8. package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts +80 -0
  9. package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts.map +1 -0
  10. package/dist/ibmi-mcp-server/tools/executeSql.tool.js +356 -0
  11. package/dist/ibmi-mcp-server/tools/executeSql.tool.js.map +1 -0
  12. package/dist/ibmi-mcp-server/tools/generateSql.tool.d.ts +36 -0
  13. package/dist/ibmi-mcp-server/tools/generateSql.tool.d.ts.map +1 -0
  14. package/dist/ibmi-mcp-server/tools/generateSql.tool.js +281 -0
  15. package/dist/ibmi-mcp-server/tools/generateSql.tool.js.map +1 -0
  16. package/dist/ibmi-mcp-server/tools/index.d.ts +85 -0
  17. package/dist/ibmi-mcp-server/tools/index.d.ts.map +1 -0
  18. package/dist/ibmi-mcp-server/tools/index.js +21 -0
  19. package/dist/ibmi-mcp-server/tools/index.js.map +1 -0
  20. package/dist/ibmi-mcp-server/utils/config/configParser.d.ts +9 -0
  21. package/dist/ibmi-mcp-server/utils/config/configParser.d.ts.map +1 -1
  22. package/dist/ibmi-mcp-server/utils/config/configParser.js +58 -0
  23. package/dist/ibmi-mcp-server/utils/config/configParser.js.map +1 -1
  24. package/dist/ibmi-mcp-server/utils/config/toolDefinitions.d.ts +4 -4
  25. package/dist/ibmi-mcp-server/utils/config/toolDefinitions.d.ts.map +1 -1
  26. package/dist/ibmi-mcp-server/utils/config/toolDefinitions.js +7 -8
  27. package/dist/ibmi-mcp-server/utils/config/toolDefinitions.js.map +1 -1
  28. package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts +0 -8
  29. package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts.map +1 -1
  30. package/dist/ibmi-mcp-server/utils/config/toolFactory.js +0 -31
  31. package/dist/ibmi-mcp-server/utils/config/toolFactory.js.map +1 -1
  32. package/dist/ibmi-mcp-server/utils/config/toolsetManager.d.ts +1 -1
  33. package/dist/ibmi-mcp-server/utils/config/toolsetManager.d.ts.map +1 -1
  34. package/dist/ibmi-mcp-server/utils/config/toolsetManager.js +2 -2
  35. package/dist/ibmi-mcp-server/utils/config/toolsetManager.js.map +1 -1
  36. package/dist/ibmi-mcp-server/utils/language/document.d.ts +26 -0
  37. package/dist/ibmi-mcp-server/utils/language/document.d.ts.map +1 -0
  38. package/dist/ibmi-mcp-server/utils/language/document.js +318 -0
  39. package/dist/ibmi-mcp-server/utils/language/document.js.map +1 -0
  40. package/dist/ibmi-mcp-server/utils/language/statement.d.ts +43 -0
  41. package/dist/ibmi-mcp-server/utils/language/statement.d.ts.map +1 -0
  42. package/dist/ibmi-mcp-server/utils/language/statement.js +796 -0
  43. package/dist/ibmi-mcp-server/utils/language/statement.js.map +1 -0
  44. package/dist/ibmi-mcp-server/utils/language/tokens.d.ts +32 -0
  45. package/dist/ibmi-mcp-server/utils/language/tokens.d.ts.map +1 -0
  46. package/dist/ibmi-mcp-server/utils/language/tokens.js +532 -0
  47. package/dist/ibmi-mcp-server/utils/language/tokens.js.map +1 -0
  48. package/dist/ibmi-mcp-server/utils/language/types.d.ts +138 -0
  49. package/dist/ibmi-mcp-server/utils/language/types.d.ts.map +1 -0
  50. package/dist/ibmi-mcp-server/utils/language/types.js +93 -0
  51. package/dist/ibmi-mcp-server/utils/language/types.js.map +1 -0
  52. package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.d.ts +48 -0
  53. package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.d.ts.map +1 -0
  54. package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.js +93 -0
  55. package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.js.map +1 -0
  56. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.d.ts +35 -59
  57. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.d.ts.map +1 -1
  58. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.js +108 -288
  59. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.js.map +1 -1
  60. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.d.ts +54 -0
  61. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.d.ts.map +1 -0
  62. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.js +91 -0
  63. package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.js.map +1 -0
  64. package/dist/mcp-server/tools/index.d.ts +13 -2
  65. package/dist/mcp-server/tools/index.d.ts.map +1 -1
  66. package/dist/mcp-server/tools/index.js +29 -9
  67. package/dist/mcp-server/tools/index.js.map +1 -1
  68. package/dist/mcp-server/tools/utils/index.d.ts +7 -0
  69. package/dist/mcp-server/tools/utils/index.d.ts.map +1 -0
  70. package/dist/mcp-server/tools/utils/index.js +7 -0
  71. package/dist/mcp-server/tools/utils/index.js.map +1 -0
  72. package/dist/mcp-server/tools/utils/tool-factory.d.ts +129 -0
  73. package/dist/mcp-server/tools/utils/tool-factory.d.ts.map +1 -0
  74. package/dist/mcp-server/tools/utils/tool-factory.js +179 -0
  75. package/dist/mcp-server/tools/utils/tool-factory.js.map +1 -0
  76. package/dist/mcp-server/tools/utils/types.d.ts +117 -0
  77. package/dist/mcp-server/tools/utils/types.d.ts.map +1 -0
  78. package/dist/mcp-server/tools/utils/types.js +11 -0
  79. package/dist/mcp-server/tools/utils/types.js.map +1 -0
  80. package/dist/mcp-server/transports/core/cleanupTransformStream.d.ts +26 -0
  81. package/dist/mcp-server/transports/core/cleanupTransformStream.d.ts.map +1 -0
  82. package/dist/mcp-server/transports/core/cleanupTransformStream.js +60 -0
  83. package/dist/mcp-server/transports/core/cleanupTransformStream.js.map +1 -0
  84. package/dist/mcp-server/transports/core/statefulTransportManager.d.ts +1 -1
  85. package/dist/mcp-server/transports/core/statefulTransportManager.d.ts.map +1 -1
  86. package/dist/mcp-server/transports/core/statefulTransportManager.js +50 -40
  87. package/dist/mcp-server/transports/core/statefulTransportManager.js.map +1 -1
  88. package/dist/mcp-server/transports/core/statelessTransportManager.d.ts +2 -13
  89. package/dist/mcp-server/transports/core/statelessTransportManager.d.ts.map +1 -1
  90. package/dist/mcp-server/transports/core/statelessTransportManager.js +35 -62
  91. package/dist/mcp-server/transports/core/statelessTransportManager.js.map +1 -1
  92. package/dist/mcp-server/transports/core/transportRequest.d.ts +1 -2
  93. package/dist/mcp-server/transports/core/transportRequest.d.ts.map +1 -1
  94. package/dist/mcp-server/transports/http/mcpTransportMiddleware.d.ts.map +1 -1
  95. package/dist/mcp-server/transports/http/mcpTransportMiddleware.js +1 -3
  96. package/dist/mcp-server/transports/http/mcpTransportMiddleware.js.map +1 -1
  97. package/package.json +21 -22
  98. package/dist/ibmi-mcp-server/tools/executeSql/index.d.ts +0 -9
  99. package/dist/ibmi-mcp-server/tools/executeSql/index.d.ts.map +0 -1
  100. package/dist/ibmi-mcp-server/tools/executeSql/index.js +0 -9
  101. package/dist/ibmi-mcp-server/tools/executeSql/index.js.map +0 -1
  102. package/dist/ibmi-mcp-server/tools/executeSql/logic.d.ts +0 -51
  103. package/dist/ibmi-mcp-server/tools/executeSql/logic.d.ts.map +0 -1
  104. package/dist/ibmi-mcp-server/tools/executeSql/logic.js +0 -179
  105. package/dist/ibmi-mcp-server/tools/executeSql/logic.js.map +0 -1
  106. package/dist/ibmi-mcp-server/tools/executeSql/registration.d.ts +0 -52
  107. package/dist/ibmi-mcp-server/tools/executeSql/registration.d.ts.map +0 -1
  108. package/dist/ibmi-mcp-server/tools/executeSql/registration.js +0 -161
  109. package/dist/ibmi-mcp-server/tools/executeSql/registration.js.map +0 -1
  110. package/dist/ibmi-mcp-server/tools/generateSql/index.d.ts +0 -13
  111. package/dist/ibmi-mcp-server/tools/generateSql/index.d.ts.map +0 -1
  112. package/dist/ibmi-mcp-server/tools/generateSql/index.js +0 -13
  113. package/dist/ibmi-mcp-server/tools/generateSql/index.js.map +0 -1
  114. package/dist/ibmi-mcp-server/tools/generateSql/logic.d.ts +0 -64
  115. package/dist/ibmi-mcp-server/tools/generateSql/logic.d.ts.map +0 -1
  116. package/dist/ibmi-mcp-server/tools/generateSql/logic.js +0 -190
  117. package/dist/ibmi-mcp-server/tools/generateSql/logic.js.map +0 -1
  118. package/dist/ibmi-mcp-server/tools/generateSql/registration.d.ts +0 -18
  119. package/dist/ibmi-mcp-server/tools/generateSql/registration.d.ts.map +0 -1
  120. package/dist/ibmi-mcp-server/tools/generateSql/registration.js +0 -64
  121. package/dist/ibmi-mcp-server/tools/generateSql/registration.js.map +0 -1
  122. package/dist/mcp-server/tools/catFactFetcher/index.d.ts +0 -8
  123. package/dist/mcp-server/tools/catFactFetcher/index.d.ts.map +0 -1
  124. package/dist/mcp-server/tools/catFactFetcher/index.js +0 -8
  125. package/dist/mcp-server/tools/catFactFetcher/index.js.map +0 -1
  126. package/dist/mcp-server/tools/catFactFetcher/logic.d.ts +0 -52
  127. package/dist/mcp-server/tools/catFactFetcher/logic.d.ts.map +0 -1
  128. package/dist/mcp-server/tools/catFactFetcher/logic.js +0 -95
  129. package/dist/mcp-server/tools/catFactFetcher/logic.js.map +0 -1
  130. package/dist/mcp-server/tools/catFactFetcher/registration.d.ts +0 -9
  131. package/dist/mcp-server/tools/catFactFetcher/registration.d.ts.map +0 -1
  132. package/dist/mcp-server/tools/catFactFetcher/registration.js +0 -43
  133. package/dist/mcp-server/tools/catFactFetcher/registration.js.map +0 -1
  134. package/dist/mcp-server/tools/echoTool/index.d.ts +0 -13
  135. package/dist/mcp-server/tools/echoTool/index.d.ts.map +0 -1
  136. package/dist/mcp-server/tools/echoTool/index.js +0 -13
  137. package/dist/mcp-server/tools/echoTool/index.js.map +0 -1
  138. package/dist/mcp-server/tools/echoTool/logic.d.ts +0 -69
  139. package/dist/mcp-server/tools/echoTool/logic.d.ts.map +0 -1
  140. package/dist/mcp-server/tools/echoTool/logic.js +0 -119
  141. package/dist/mcp-server/tools/echoTool/logic.js.map +0 -1
  142. package/dist/mcp-server/tools/echoTool/registration.d.ts +0 -9
  143. package/dist/mcp-server/tools/echoTool/registration.d.ts.map +0 -1
  144. package/dist/mcp-server/tools/echoTool/registration.js +0 -45
  145. package/dist/mcp-server/tools/echoTool/registration.js.map +0 -1
  146. package/dist/mcp-server/tools/imageTest/index.d.ts +0 -7
  147. package/dist/mcp-server/tools/imageTest/index.d.ts.map +0 -1
  148. package/dist/mcp-server/tools/imageTest/index.js +0 -7
  149. package/dist/mcp-server/tools/imageTest/index.js.map +0 -1
  150. package/dist/mcp-server/tools/imageTest/logic.d.ts +0 -27
  151. package/dist/mcp-server/tools/imageTest/logic.d.ts.map +0 -1
  152. package/dist/mcp-server/tools/imageTest/logic.js +0 -44
  153. package/dist/mcp-server/tools/imageTest/logic.js.map +0 -1
  154. package/dist/mcp-server/tools/imageTest/registration.d.ts +0 -9
  155. package/dist/mcp-server/tools/imageTest/registration.d.ts.map +0 -1
  156. package/dist/mcp-server/tools/imageTest/registration.js +0 -49
  157. package/dist/mcp-server/tools/imageTest/registration.js.map +0 -1
  158. package/dist/mcp-server/tools/utils/tool-utils.d.ts +0 -43
  159. package/dist/mcp-server/tools/utils/tool-utils.d.ts.map +0 -1
  160. package/dist/mcp-server/tools/utils/tool-utils.js +0 -44
  161. package/dist/mcp-server/tools/utils/tool-utils.js.map +0 -1
  162. package/dist/mcp-server/transports/core/headerUtils.d.ts +0 -27
  163. package/dist/mcp-server/transports/core/headerUtils.d.ts.map +0 -1
  164. package/dist/mcp-server/transports/core/headerUtils.js +0 -53
  165. package/dist/mcp-server/transports/core/headerUtils.js.map +0 -1
  166. package/dist/mcp-server/transports/core/honoNodeBridge.d.ts +0 -77
  167. package/dist/mcp-server/transports/core/honoNodeBridge.d.ts.map +0 -1
  168. package/dist/mcp-server/transports/core/honoNodeBridge.js +0 -150
  169. package/dist/mcp-server/transports/core/honoNodeBridge.js.map +0 -1
  170. package/dist/services/duck-db/duckDBConnectionManager.d.ts +0 -55
  171. package/dist/services/duck-db/duckDBConnectionManager.d.ts.map +0 -1
  172. package/dist/services/duck-db/duckDBConnectionManager.js +0 -184
  173. package/dist/services/duck-db/duckDBConnectionManager.js.map +0 -1
  174. package/dist/services/duck-db/duckDBQueryExecutor.d.ts +0 -18
  175. package/dist/services/duck-db/duckDBQueryExecutor.d.ts.map +0 -1
  176. package/dist/services/duck-db/duckDBQueryExecutor.js +0 -115
  177. package/dist/services/duck-db/duckDBQueryExecutor.js.map +0 -1
  178. package/dist/services/duck-db/duckDBService.d.ts +0 -27
  179. package/dist/services/duck-db/duckDBService.d.ts.map +0 -1
  180. package/dist/services/duck-db/duckDBService.js +0 -151
  181. package/dist/services/duck-db/duckDBService.js.map +0 -1
  182. package/dist/services/duck-db/types.d.ts +0 -135
  183. package/dist/services/duck-db/types.d.ts.map +0 -1
  184. package/dist/services/duck-db/types.js +0 -6
  185. package/dist/services/duck-db/types.js.map +0 -1
  186. package/dist/services/llm-providers/openRouterProvider.d.ts +0 -36
  187. package/dist/services/llm-providers/openRouterProvider.d.ts.map +0 -1
  188. package/dist/services/llm-providers/openRouterProvider.js +0 -235
  189. package/dist/services/llm-providers/openRouterProvider.js.map +0 -1
  190. package/dist/services/supabase/supabaseClient.d.ts +0 -25
  191. package/dist/services/supabase/supabaseClient.d.ts.map +0 -1
  192. package/dist/services/supabase/supabaseClient.js +0 -68
  193. package/dist/services/supabase/supabaseClient.js.map +0 -1
  194. package/dist/storage/duckdbExample.d.ts +0 -8
  195. package/dist/storage/duckdbExample.d.ts.map +0 -1
  196. package/dist/storage/duckdbExample.js +0 -197
  197. package/dist/storage/duckdbExample.js.map +0 -1
@@ -1,9 +0,0 @@
1
- /**
2
- * @fileoverview Barrel file for the execute SQL tool
3
- * This module exports the registration function and configuration utilities
4
- * for the dynamic SQL execution tool.
5
- *
6
- * @module src/mcp-server/tools/executeSql/index
7
- */
8
- export { registerExecuteSqlTool, setExecuteSqlConfig, getExecuteSqlConfig, isExecuteSqlEnabled, } from "./registration.js";
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ibmi-mcp-server/tools/executeSql/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC"}
@@ -1,51 +0,0 @@
1
- /**
2
- * @fileoverview Defines the core logic, schemas, and types for the `execute_sql` tool.
3
- * This module provides dynamic SQL execution capabilities for the IBM i database.
4
- * Unlike YAML tools with predefined statements, this tool accepts arbitrary SQL at runtime.
5
- * @module src/mcp-server/tools/executeSql/logic
6
- * @see {@link src/mcp-server/tools/executeSql/registration.ts} for the handler and registration logic.
7
- */
8
- import { z } from "zod";
9
- /**
10
- * Zod schema defining the input parameters for the `execute_sql` tool.
11
- * CRITICAL: The descriptions are sent to the LLM and must be clear.
12
- */
13
- export declare const ExecuteSqlInputSchema: z.ZodObject<{
14
- sql: z.ZodString;
15
- }, "strip", z.ZodTypeAny, {
16
- sql: string;
17
- }, {
18
- sql: string;
19
- }>;
20
- /**
21
- * Zod schema for the successful response of the `execute_sql` tool.
22
- */
23
- export declare const ExecuteSqlResponseSchema: z.ZodObject<{
24
- data: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
25
- rowCount: z.ZodNumber;
26
- executionTimeMs: z.ZodOptional<z.ZodNumber>;
27
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
28
- }, "strip", z.ZodTypeAny, {
29
- data: Record<string, unknown>[];
30
- rowCount: number;
31
- metadata?: Record<string, unknown> | undefined;
32
- executionTimeMs?: number | undefined;
33
- }, {
34
- data: Record<string, unknown>[];
35
- rowCount: number;
36
- metadata?: Record<string, unknown> | undefined;
37
- executionTimeMs?: number | undefined;
38
- }>;
39
- export type ExecuteSqlInput = z.infer<typeof ExecuteSqlInputSchema>;
40
- export type ExecuteSqlResponse = z.infer<typeof ExecuteSqlResponseSchema>;
41
- /**
42
- * Processes the core logic for the `execute_sql` tool.
43
- * This function executes arbitrary SQL statements against the IBM i database.
44
- * Only read-only operations are allowed for security.
45
- *
46
- * @param params - The validated input parameters containing the SQL statement
47
- * @returns A promise resolving with the structured response data
48
- * @throws {McpError} If the SQL execution encounters an unrecoverable issue
49
- */
50
- export declare function executeSqlLogic(params: ExecuteSqlInput): Promise<ExecuteSqlResponse>;
51
- //# sourceMappingURL=logic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../../../../src/ibmi-mcp-server/tools/executeSql/logic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA6BxB;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;EAShC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAiBnC,CAAC;AAGH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAsE1E;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,kBAAkB,CAAC,CAwF7B"}
@@ -1,179 +0,0 @@
1
- /**
2
- * @fileoverview Defines the core logic, schemas, and types for the `execute_sql` tool.
3
- * This module provides dynamic SQL execution capabilities for the IBM i database.
4
- * Unlike YAML tools with predefined statements, this tool accepts arbitrary SQL at runtime.
5
- * @module src/mcp-server/tools/executeSql/logic
6
- * @see {@link src/mcp-server/tools/executeSql/registration.ts} for the handler and registration logic.
7
- */
8
- import { z } from "zod";
9
- import { JsonRpcErrorCode, McpError } from "../../../types-global/errors.js";
10
- import { getRequestContext } from "../../../utils/index.js";
11
- import { logger } from "../../../utils/internal/logger.js";
12
- import { IBMiConnectionPool } from "../../services/connectionPool.js";
13
- /**
14
- * Restricted SQL keywords that are not allowed in execute-sql tool
15
- * This provides basic protection against destructive operations
16
- */
17
- const RESTRICTED_KEYWORDS = [
18
- "DROP",
19
- "DELETE",
20
- "TRUNCATE",
21
- "ALTER",
22
- "CREATE",
23
- "INSERT",
24
- "UPDATE",
25
- "GRANT",
26
- "REVOKE",
27
- "COMMIT",
28
- "ROLLBACK",
29
- ];
30
- /**
31
- * Maximum allowed SQL statement length to prevent abuse
32
- */
33
- const MAX_SQL_LENGTH = 10000;
34
- /**
35
- * Zod schema defining the input parameters for the `execute_sql` tool.
36
- * CRITICAL: The descriptions are sent to the LLM and must be clear.
37
- */
38
- export const ExecuteSqlInputSchema = z.object({
39
- sql: z
40
- .string()
41
- .min(1, "SQL statement cannot be empty.")
42
- .max(MAX_SQL_LENGTH, `SQL statement cannot exceed ${MAX_SQL_LENGTH} characters.`)
43
- .describe("The SQL statement to execute against the IBM i database."),
44
- });
45
- /**
46
- * Zod schema for the successful response of the `execute_sql` tool.
47
- */
48
- export const ExecuteSqlResponseSchema = z.object({
49
- data: z
50
- .array(z.record(z.unknown()))
51
- .describe("Array of result rows returned by the SQL query."),
52
- rowCount: z
53
- .number()
54
- .int()
55
- .min(0)
56
- .describe("Number of rows returned by the query."),
57
- executionTimeMs: z
58
- .number()
59
- .optional()
60
- .describe("Query execution time in milliseconds."),
61
- metadata: z
62
- .record(z.unknown())
63
- .optional()
64
- .describe("Additional metadata about the query execution."),
65
- });
66
- /**
67
- * Validates SQL statement for security and safety
68
- * @param sql - SQL statement to validate
69
- * @throws {McpError} If the SQL statement contains restricted keywords or patterns
70
- * @private
71
- */
72
- function validateSqlSecurity(sql) {
73
- const context = getRequestContext();
74
- const normalizedSql = sql.trim().toUpperCase();
75
- // Check for restricted keywords at the beginning of statements
76
- for (const keyword of RESTRICTED_KEYWORDS) {
77
- if (normalizedSql.startsWith(keyword)) {
78
- logger.warning({
79
- ...context,
80
- keyword,
81
- sqlPrefix: sql.substring(0, 50),
82
- }, "Restricted SQL keyword detected");
83
- throw new McpError(JsonRpcErrorCode.ValidationError, `SQL statement cannot start with restricted keyword: ${keyword}. Only SELECT and read-only operations are allowed.`, { keyword, sqlPrefix: sql.substring(0, 50) });
84
- }
85
- }
86
- // Check for potentially dangerous patterns
87
- const dangerousPatterns = [
88
- /;\s*(DROP|DELETE|TRUNCATE|ALTER|CREATE|INSERT|UPDATE)\s+/i,
89
- /UNION\s+SELECT.*INTO\s+/i,
90
- /EXEC\s*\(/i,
91
- /(CALL|EXECUTE)\s+/i,
92
- ];
93
- for (const pattern of dangerousPatterns) {
94
- if (pattern.test(sql)) {
95
- logger.warning({
96
- ...context,
97
- pattern: pattern.source,
98
- sqlPrefix: sql.substring(0, 100),
99
- }, "Potentially dangerous SQL pattern detected");
100
- throw new McpError(JsonRpcErrorCode.ValidationError, "SQL statement contains potentially dangerous patterns. Only safe, read-only queries are allowed.", {
101
- pattern: pattern.source,
102
- sqlPrefix: sql.substring(0, 100),
103
- });
104
- }
105
- }
106
- logger.debug({
107
- ...context,
108
- sqlLength: sql.length,
109
- sqlPrefix: sql.substring(0, 50),
110
- }, "SQL security validation passed");
111
- }
112
- /**
113
- * Processes the core logic for the `execute_sql` tool.
114
- * This function executes arbitrary SQL statements against the IBM i database.
115
- * Only read-only operations are allowed for security.
116
- *
117
- * @param params - The validated input parameters containing the SQL statement
118
- * @returns A promise resolving with the structured response data
119
- * @throws {McpError} If the SQL execution encounters an unrecoverable issue
120
- */
121
- export async function executeSqlLogic(params) {
122
- const context = getRequestContext();
123
- logger.debug({
124
- ...context,
125
- sqlLength: params.sql.length,
126
- sqlPrefix: params.sql.substring(0, 50),
127
- }, "Processing execute SQL logic");
128
- // Validate SQL security before execution
129
- validateSqlSecurity(params.sql);
130
- const startTime = Date.now();
131
- try {
132
- // Execute the SQL query using the existing connection pool
133
- const result = await IBMiConnectionPool.executeQuery(params.sql, [], // No parameters for dynamic SQL
134
- context);
135
- const executionTime = Date.now() - startTime;
136
- if (!result.success) {
137
- throw new McpError(JsonRpcErrorCode.DatabaseError, "SQL query execution failed", {
138
- sql: params.sql.substring(0, 100),
139
- sqlReturnCode: result.sql_rc,
140
- executionTime,
141
- });
142
- }
143
- const response = {
144
- data: result.data || [],
145
- rowCount: result.data?.length || 0,
146
- executionTimeMs: executionTime,
147
- };
148
- // Add metadata if available from the query result
149
- if (result.metadata) {
150
- response.metadata = result.metadata;
151
- }
152
- logger.debug({
153
- ...context,
154
- rowCount: response.rowCount,
155
- executionTime: response.executionTimeMs,
156
- sqlPrefix: params.sql.substring(0, 50),
157
- }, "SQL query executed successfully");
158
- return response;
159
- }
160
- catch (error) {
161
- const executionTime = Date.now() - startTime;
162
- logger.error({
163
- ...context,
164
- error: error instanceof Error ? error.message : String(error),
165
- executionTime,
166
- sqlPrefix: params.sql.substring(0, 100),
167
- }, "SQL execution failed");
168
- // Re-throw McpErrors as-is, wrap other errors
169
- if (error instanceof McpError) {
170
- throw error;
171
- }
172
- throw new McpError(JsonRpcErrorCode.DatabaseError, `SQL execution failed: ${error instanceof Error ? error.message : String(error)}`, {
173
- sql: params.sql.substring(0, 100),
174
- executionTime,
175
- originalError: error instanceof Error ? error.name : "Unknown",
176
- });
177
- }
178
- }
179
- //# sourceMappingURL=logic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logic.js","sourceRoot":"","sources":["../../../../src/ibmi-mcp-server/tools/executeSql/logic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,E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C,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;YACjC,aAAa;YACb,aAAa,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;SAC/D,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * @fileoverview Handles registration and error handling for the `execute_sql` tool.
3
- * This module acts as the "handler" layer, connecting the pure business logic to the
4
- * MCP server and ensuring all outcomes (success or failure) are handled gracefully.
5
- * @module src/mcp-server/tools/executeSql/registration
6
- * @see {@link src/mcp-server/tools/executeSql/logic.ts} for the core business logic and schemas.
7
- */
8
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9
- /**
10
- * Configuration interface for the execute SQL tool
11
- * This allows the tool to be enabled/disabled and configured via YAML
12
- */
13
- export interface ExecuteSqlToolConfig {
14
- /** Whether the tool is enabled */
15
- enabled: boolean;
16
- /** Tool description override */
17
- description?: string;
18
- /** Security configuration */
19
- security?: {
20
- /** Whether to enforce read-only mode (default: true) */
21
- readOnly?: boolean;
22
- /** Maximum query length (default: 10000) */
23
- maxQueryLength?: number;
24
- /** Additional forbidden keywords */
25
- forbiddenKeywords?: string[];
26
- };
27
- }
28
- /**
29
- * Set the configuration for the execute SQL tool
30
- * This is called by the YAML configuration system
31
- * @param config - Tool configuration
32
- */
33
- export declare function setExecuteSqlConfig(config: Partial<ExecuteSqlToolConfig>): void;
34
- /**
35
- * Get the current configuration for the execute SQL tool
36
- * @returns Current tool configuration
37
- */
38
- export declare function getExecuteSqlConfig(): ExecuteSqlToolConfig;
39
- /**
40
- * Check if the execute SQL tool is enabled
41
- * @returns True if the tool is enabled
42
- */
43
- export declare function isExecuteSqlEnabled(): boolean;
44
- /**
45
- * Registers the 'execute_sql' tool and its handler with the provided MCP server instance.
46
- * This function uses ErrorHandler.tryCatch to ensure that any failure during the
47
- * registration process itself is caught and logged, preventing server startup failures.
48
- *
49
- * @param server - The MCP server instance to register the tool with.
50
- */
51
- export declare const registerExecuteSqlTool: (server: McpServer) => Promise<void>;
52
- //# sourceMappingURL=registration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../../src/ibmi-mcp-server/tools/executeSql/registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAmCpE;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE;QACT,wDAAwD;QACxD,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,4CAA4C;QAC5C,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,oCAAoC;QACpC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;CACH;AAmBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACpC,IAAI,CAoBN;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,oBAAoB,CAE1D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,SAAS,KAChB,OAAO,CAAC,IAAI,CAmGd,CAAC"}
@@ -1,161 +0,0 @@
1
- /**
2
- * @fileoverview Handles registration and error handling for the `execute_sql` tool.
3
- * This module acts as the "handler" layer, connecting the pure business logic to the
4
- * MCP server and ensuring all outcomes (success or failure) are handled gracefully.
5
- * @module src/mcp-server/tools/executeSql/registration
6
- * @see {@link src/mcp-server/tools/executeSql/logic.ts} for the core business logic and schemas.
7
- */
8
- import { JsonRpcErrorCode } from "../../../types-global/errors.js";
9
- import { ErrorHandler, requestContextService } from "../../../utils/index.js";
10
- import { logOperationStart, logOperationSuccess, } from "../../../utils/internal/logging-helpers.js";
11
- import { measureToolExecution } from "../../../utils/internal/performance.js";
12
- import { getRequestContext } from "../../../utils/internal/asyncContext.js";
13
- import { ExecuteSqlInputSchema, executeSqlLogic, ExecuteSqlResponseSchema, } from "./logic.js";
14
- // The unique name for the tool, used for registration and identification.
15
- const TOOL_NAME = "execute_sql";
16
- // A concise description for the LLM. More detailed guidance should be in the
17
- // parameter descriptions within the Zod schema in `logic.ts`.
18
- const TOOL_DESCRIPTION = `Execute SQL statements against the IBM i database. Only SELECT and read-only operations are allowed for security.`;
19
- const responseFormatter = (result) => ({
20
- structuredContent: result,
21
- content: [
22
- {
23
- type: "text",
24
- text: `SQL Query executed successfully. Returned ${result.rowCount} rows.\n\n${JSON.stringify(result.data, null, 2)}`,
25
- },
26
- ],
27
- });
28
- /**
29
- * Default configuration for the execute SQL tool
30
- */
31
- const DEFAULT_CONFIG = {
32
- enabled: true,
33
- security: {
34
- readOnly: true,
35
- maxQueryLength: 10000,
36
- forbiddenKeywords: [],
37
- },
38
- };
39
- /**
40
- * Internal configuration storage
41
- */
42
- let toolConfig = DEFAULT_CONFIG;
43
- /**
44
- * Set the configuration for the execute SQL tool
45
- * This is called by the YAML configuration system
46
- * @param config - Tool configuration
47
- */
48
- export function setExecuteSqlConfig(config) {
49
- toolConfig = {
50
- ...DEFAULT_CONFIG,
51
- ...config,
52
- security: {
53
- ...DEFAULT_CONFIG.security,
54
- ...config.security,
55
- },
56
- };
57
- const context = requestContextService.createRequestContext({
58
- operation: "ConfigUpdate",
59
- toolName: TOOL_NAME,
60
- });
61
- logOperationSuccess(context, "Execute SQL tool configuration updated", {
62
- enabled: toolConfig.enabled,
63
- readOnly: toolConfig.security?.readOnly,
64
- maxQueryLength: toolConfig.security?.maxQueryLength,
65
- });
66
- }
67
- /**
68
- * Get the current configuration for the execute SQL tool
69
- * @returns Current tool configuration
70
- */
71
- export function getExecuteSqlConfig() {
72
- return toolConfig;
73
- }
74
- /**
75
- * Check if the execute SQL tool is enabled
76
- * @returns True if the tool is enabled
77
- */
78
- export function isExecuteSqlEnabled() {
79
- return toolConfig.enabled;
80
- }
81
- /**
82
- * Registers the 'execute_sql' tool and its handler with the provided MCP server instance.
83
- * This function uses ErrorHandler.tryCatch to ensure that any failure during the
84
- * registration process itself is caught and logged, preventing server startup failures.
85
- *
86
- * @param server - The MCP server instance to register the tool with.
87
- */
88
- export const registerExecuteSqlTool = async (server) => {
89
- const registrationContext = requestContextService.createRequestContext({
90
- operation: "RegisterTool",
91
- toolName: TOOL_NAME,
92
- });
93
- logOperationStart(registrationContext, `Checking if tool should be registered: '${TOOL_NAME}'`, {
94
- enabled: toolConfig.enabled,
95
- });
96
- // Only register if the tool is enabled
97
- if (!toolConfig.enabled) {
98
- logOperationSuccess(registrationContext, `Tool '${TOOL_NAME}' is disabled, skipping registration`);
99
- return;
100
- }
101
- logOperationStart(registrationContext, `Registering tool: '${TOOL_NAME}'`);
102
- await ErrorHandler.tryCatch(async () => {
103
- const description = toolConfig.description || TOOL_DESCRIPTION;
104
- server.registerTool(TOOL_NAME, {
105
- title: "Execute SQL",
106
- description,
107
- inputSchema: ExecuteSqlInputSchema.shape,
108
- outputSchema: ExecuteSqlResponseSchema.shape,
109
- annotations: {
110
- readOnlyHint: toolConfig.security?.readOnly, // Default to true for safety
111
- destructiveHint: !(toolConfig.security?.readOnly ?? true), // Destructive if not read-only
112
- openWorldHint: !(toolConfig.security?.readOnly ?? true), // Open world if not read-only
113
- },
114
- _meta: {
115
- requiresAuth: true, // Requires database authentication
116
- },
117
- }, async (params, mcpContext) => {
118
- try {
119
- const result = await measureToolExecution(TOOL_NAME, () => executeSqlLogic(params), params);
120
- return responseFormatter(result);
121
- }
122
- catch (error) {
123
- const handlerContext = requestContextService.createRequestContext({
124
- parentContext: mcpContext,
125
- operation: `tool:${TOOL_NAME}`,
126
- });
127
- const handledError = ErrorHandler.handleError(error, {
128
- operation: `tool:${TOOL_NAME}`,
129
- context: getRequestContext() ?? handlerContext,
130
- input: params,
131
- });
132
- return {
133
- isError: true,
134
- content: [
135
- {
136
- type: "text",
137
- text: `SQL Error: ${handledError.message}`,
138
- },
139
- ],
140
- structuredContent: {
141
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
- code: handledError.code,
143
- message: handledError.message,
144
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
- details: handledError.details,
146
- },
147
- };
148
- }
149
- });
150
- logOperationSuccess(registrationContext, `Tool '${TOOL_NAME}' registered successfully.`, {
151
- enabled: toolConfig.enabled,
152
- readOnly: toolConfig.security?.readOnly,
153
- });
154
- }, {
155
- operation: `RegisteringTool_${TOOL_NAME}`,
156
- context: registrationContext,
157
- errorCode: JsonRpcErrorCode.InitializationFailed,
158
- critical: true, // A failure to register a tool is a critical startup error.
159
- });
160
- };
161
- //# sourceMappingURL=registration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../src/ibmi-mcp-server/tools/executeSql/registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAEL,qBAAqB,EACrB,eAAe,EAEf,wBAAwB,GACzB,MAAM,YAAY,CAAC;AAEpB,0EAA0E;AAC1E,MAAM,SAAS,GAAG,aAAa,CAAC;AAEhC,6EAA6E;AAC7E,8DAA8D;AAC9D,MAAM,gBAAgB,GAAG,mHAAmH,CAAC;AAE7I,MAAM,iBAAiB,GAA0C,CAAC,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+0,0 @@
1
- /**
2
- * @fileoverview Barrel file for the `generate_sql` tool.
3
- * This file serves as the public interface for the generate SQL tool module,
4
- * primarily exporting the `registerGenerateSqlTool` function. This function is
5
- * responsible for registering the generate SQL tool with an MCP server instance,
6
- * making it available for invocation by clients.
7
- *
8
- * Consuming modules should import from this barrel file to access
9
- * the generate SQL tool's registration capabilities.
10
- * @module src/mcp-server/tools/generateSql/index
11
- */
12
- export { registerGenerateSqlTool } from "./registration.js";
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ibmi-mcp-server/tools/generateSql/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * @fileoverview Barrel file for the `generate_sql` tool.
3
- * This file serves as the public interface for the generate SQL tool module,
4
- * primarily exporting the `registerGenerateSqlTool` function. This function is
5
- * responsible for registering the generate SQL tool with an MCP server instance,
6
- * making it available for invocation by clients.
7
- *
8
- * Consuming modules should import from this barrel file to access
9
- * the generate SQL tool's registration capabilities.
10
- * @module src/mcp-server/tools/generateSql/index
11
- */
12
- export { registerGenerateSqlTool } from "./registration.js";
13
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ibmi-mcp-server/tools/generateSql/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,64 +0,0 @@
1
- /**
2
- * @fileoverview Defines the core logic, schemas, and types for the `generate_sql` tool.
3
- * This module is the single source of truth for the tool's data contracts (Zod schemas)
4
- * and its pure business logic for generating SQL DDL statements from IBM i database objects.
5
- * @module src/mcp-server/tools/generateSql/logic
6
- * @see {@link src/mcp-server/tools/generateSql/registration.ts} for the handler and registration logic.
7
- */
8
- import { z } from "zod";
9
- /**
10
- * Zod schema defining the input parameters for the `generate_sql` tool.
11
- */
12
- export declare const GenerateSqlInputSchema: z.ZodObject<{
13
- object_name: z.ZodString;
14
- object_library: z.ZodDefault<z.ZodString>;
15
- object_type: z.ZodDefault<z.ZodEnum<["ALIAS", "CONSTRAINT", "FUNCTION", "INDEX", "MASK", "PERMISSION", "PROCEDURE", "SCHEMA", "SEQUENCE", "TABLE", "TRIGGER", "TYPE", "VARIABLE", "VIEW", "XSR"]>>;
16
- }, "strip", z.ZodTypeAny, {
17
- object_name: string;
18
- object_library: string;
19
- object_type: "ALIAS" | "CONSTRAINT" | "FUNCTION" | "INDEX" | "MASK" | "PERMISSION" | "PROCEDURE" | "SCHEMA" | "SEQUENCE" | "TABLE" | "TRIGGER" | "TYPE" | "VARIABLE" | "VIEW" | "XSR";
20
- }, {
21
- object_name: string;
22
- object_library?: string | undefined;
23
- object_type?: "ALIAS" | "CONSTRAINT" | "FUNCTION" | "INDEX" | "MASK" | "PERMISSION" | "PROCEDURE" | "SCHEMA" | "SEQUENCE" | "TABLE" | "TRIGGER" | "TYPE" | "VARIABLE" | "VIEW" | "XSR" | undefined;
24
- }>;
25
- /**
26
- * Zod schema for the successful response of the `generate_sql` tool.
27
- * Contains the generated DDL along with metadata about the source object.
28
- */
29
- export declare const GenerateSqlOutputSchema: z.ZodObject<{
30
- sql: z.ZodString;
31
- object_name: z.ZodString;
32
- object_library: z.ZodString;
33
- object_type: z.ZodString;
34
- }, "strip", z.ZodTypeAny, {
35
- object_name: string;
36
- object_library: string;
37
- object_type: string;
38
- sql: string;
39
- }, {
40
- object_name: string;
41
- object_library: string;
42
- object_type: string;
43
- sql: string;
44
- }>;
45
- /**
46
- * TypeScript type inferred from the input schema.
47
- * Represents the validated parameters passed to the generate SQL logic.
48
- */
49
- export type GenerateSqlInput = z.infer<typeof GenerateSqlInputSchema>;
50
- /**
51
- * TypeScript type inferred from the output schema.
52
- * Represents the structured response returned by the generate SQL logic.
53
- */
54
- export type GenerateSqlOutput = z.infer<typeof GenerateSqlOutputSchema>;
55
- /**
56
- * Processes the core logic for the `generate_sql` tool.
57
- * This function calls the QSYS2.GENERATE_SQL procedure to generate DDL for IBM i database objects.
58
- *
59
- * @param params - The validated input parameters containing object details
60
- * @returns A promise resolving with the generated SQL DDL
61
- * @throws {McpError} If the SQL generation encounters an unrecoverable issue
62
- */
63
- export declare function generateSqlLogic(params: GenerateSqlInput): Promise<GenerateSqlOutput>;
64
- //# sourceMappingURL=logic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../../../../src/ibmi-mcp-server/tools/generateSql/logic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA6BxB;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;EAsBe,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAkBc,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CAuJ5B"}