@enfyra/mcp-server 0.1.13 → 0.1.15

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 (71) hide show
  1. package/README.md +14 -1
  2. package/dist/index.d.ts +5 -0
  3. package/{src/index.mjs → dist/index.js} +8 -10
  4. package/dist/index.js.map +1 -0
  5. package/dist/lib/auth.d.ts +34 -0
  6. package/dist/lib/auth.js +161 -0
  7. package/dist/lib/auth.js.map +1 -0
  8. package/dist/lib/config-local.d.ts +1 -0
  9. package/dist/lib/config-local.js +719 -0
  10. package/dist/lib/config-local.js.map +1 -0
  11. package/dist/lib/extension-search-tools.d.ts +59 -0
  12. package/dist/lib/extension-search-tools.js +483 -0
  13. package/dist/lib/extension-search-tools.js.map +1 -0
  14. package/dist/lib/fetch.d.ts +28 -0
  15. package/dist/lib/fetch.js +106 -0
  16. package/dist/lib/fetch.js.map +1 -0
  17. package/dist/lib/mcp-examples.d.ts +99 -0
  18. package/dist/lib/mcp-examples.js +2285 -0
  19. package/dist/lib/mcp-examples.js.map +1 -0
  20. package/dist/lib/mcp-instructions.d.ts +11 -0
  21. package/dist/lib/mcp-instructions.js +78 -0
  22. package/dist/lib/mcp-instructions.js.map +1 -0
  23. package/dist/lib/mutation-guards.d.ts +33 -0
  24. package/dist/lib/mutation-guards.js +106 -0
  25. package/dist/lib/mutation-guards.js.map +1 -0
  26. package/dist/lib/platform-operation-tools.d.ts +12 -0
  27. package/dist/lib/platform-operation-tools.js +2304 -0
  28. package/dist/lib/platform-operation-tools.js.map +1 -0
  29. package/dist/lib/required-knowledge.d.ts +32 -0
  30. package/dist/lib/required-knowledge.js +181 -0
  31. package/dist/lib/required-knowledge.js.map +1 -0
  32. package/dist/lib/response-format.d.ts +7 -0
  33. package/dist/lib/response-format.js +179 -0
  34. package/dist/lib/response-format.js.map +1 -0
  35. package/dist/lib/route-guards.d.ts +1 -0
  36. package/dist/lib/route-guards.js +19 -0
  37. package/dist/lib/route-guards.js.map +1 -0
  38. package/dist/lib/route-permission-tools.d.ts +91 -0
  39. package/dist/lib/route-permission-tools.js +151 -0
  40. package/dist/lib/route-permission-tools.js.map +1 -0
  41. package/dist/lib/source-artifacts.d.ts +27 -0
  42. package/dist/lib/source-artifacts.js +82 -0
  43. package/dist/lib/source-artifacts.js.map +1 -0
  44. package/dist/lib/table-tools.d.ts +62 -0
  45. package/dist/lib/table-tools.js +774 -0
  46. package/dist/lib/table-tools.js.map +1 -0
  47. package/dist/lib/tool-routing.d.ts +297 -0
  48. package/dist/lib/tool-routing.js +585 -0
  49. package/dist/lib/tool-routing.js.map +1 -0
  50. package/dist/lib/types.d.ts +17 -0
  51. package/dist/lib/types.js +2 -0
  52. package/dist/lib/types.js.map +1 -0
  53. package/dist/mcp-server-entry.d.ts +4 -0
  54. package/dist/mcp-server-entry.js +2787 -0
  55. package/dist/mcp-server-entry.js.map +1 -0
  56. package/package.json +17 -10
  57. package/src/lib/auth.js +0 -179
  58. package/src/lib/config-local.mjs +0 -718
  59. package/src/lib/fetch.js +0 -111
  60. package/src/lib/mcp-examples.js +0 -2289
  61. package/src/lib/mcp-instructions.js +0 -80
  62. package/src/lib/mutation-guards.js +0 -118
  63. package/src/lib/platform-operation-tools.js +0 -2616
  64. package/src/lib/required-knowledge.js +0 -188
  65. package/src/lib/response-format.js +0 -187
  66. package/src/lib/route-guards.js +0 -24
  67. package/src/lib/route-permission-tools.js +0 -160
  68. package/src/lib/source-artifacts.js +0 -82
  69. package/src/lib/table-tools.js +0 -907
  70. package/src/lib/tool-routing.js +0 -589
  71. package/src/mcp-server-entry.mjs +0 -3177
package/src/lib/fetch.js DELETED
@@ -1,111 +0,0 @@
1
- /**
2
- * HTTP client module for Enfyra MCP Server
3
- * Handles API requests with auth, timeout, and error handling
4
- */
5
-
6
- import { getValidToken, hasApiToken, resetTokens } from './auth.js';
7
-
8
- // Timeout configuration
9
- const FETCH_TIMEOUT = 30000; // 30 seconds
10
-
11
- /**
12
- * Make HTTP request to Enfyra API
13
- * @param {string} apiUrl - Base API URL
14
- * @param {string} path - Request path
15
- * @param {object} options - Fetch options
16
- * @returns {Promise<any>} Response data
17
- */
18
- export async function fetchAPI(apiUrl, path, options = {}) {
19
- const url = `${apiUrl}${path}`;
20
-
21
- async function requestWithCurrentToken() {
22
- const token = await getValidToken(apiUrl);
23
- const headersList = [
24
- ['Content-Type', 'application/json'],
25
- ['Authorization', `Bearer ${token}`],
26
- ];
27
-
28
- if (options.headers) {
29
- const optHeaders = options.headers;
30
- for (const key of Object.keys(optHeaders)) {
31
- const existingIdx = headersList.findIndex(h => h[0] === key);
32
- if (existingIdx >= 0) {
33
- headersList[existingIdx] = [key, optHeaders[key]];
34
- } else {
35
- headersList.push([key, optHeaders[key]]);
36
- }
37
- }
38
- }
39
-
40
- const controller = new AbortController();
41
- const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
42
- try {
43
- const res = await fetch(url, {
44
- ...options,
45
- headers: headersList,
46
- signal: controller.signal,
47
- });
48
- clearTimeout(timeoutId);
49
- return res;
50
- } catch (error) {
51
- clearTimeout(timeoutId);
52
- if (error.name === 'AbortError') {
53
- throw new Error(`Request timeout after ${FETCH_TIMEOUT}ms`);
54
- }
55
- throw error;
56
- }
57
- }
58
-
59
- let res = await requestWithCurrentToken();
60
- if ((res.status === 401 || res.status === 403) && hasApiToken()) {
61
- resetTokens();
62
- res = await requestWithCurrentToken();
63
- }
64
-
65
- if (!res.ok) {
66
- const error = await res.text().catch(() => res.statusText);
67
- throw new Error(`API error (${res.status}): ${error}`);
68
- }
69
-
70
- return res.json();
71
- }
72
-
73
- /**
74
- * Validate filter JSON and check for injection patterns
75
- * @param {string} filterStr - Filter JSON string
76
- * @returns {object|null} Parsed filter object
77
- */
78
- export function validateFilter(filterStr) {
79
- if (!filterStr) return null;
80
- try {
81
- const parsed = JSON.parse(filterStr);
82
- // Check depth limit (max 10 levels)
83
- function checkDepth(obj, depth = 0) {
84
- if (depth > 10) {
85
- throw new Error('Filter depth exceeds maximum of 10 levels');
86
- }
87
- if (obj && typeof obj === 'object') {
88
- for (const key of Object.keys(obj)) {
89
- checkDepth(obj[key], depth + 1);
90
- }
91
- }
92
- }
93
- checkDepth(parsed);
94
- return parsed;
95
- } catch (e) {
96
- if (e.message.includes('depth')) throw e;
97
- throw new Error(`Invalid filter JSON: ${e.message}`);
98
- }
99
- }
100
-
101
- /**
102
- * Validate table name (alphanumeric, underscores only)
103
- * @param {string} tableName - Table name to validate
104
- * @returns {string} Validated table name
105
- */
106
- export function validateTableName(tableName) {
107
- if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(tableName)) {
108
- throw new Error(`Invalid table name: ${tableName}. Must start with letter/underscore and contain only alphanumeric characters and underscores.`);
109
- }
110
- return tableName;
111
- }