@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.
- package/README.md +14 -1
- package/dist/index.d.ts +5 -0
- package/{src/index.mjs → dist/index.js} +8 -10
- package/dist/index.js.map +1 -0
- package/dist/lib/auth.d.ts +34 -0
- package/dist/lib/auth.js +161 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/config-local.d.ts +1 -0
- package/dist/lib/config-local.js +719 -0
- package/dist/lib/config-local.js.map +1 -0
- package/dist/lib/extension-search-tools.d.ts +59 -0
- package/dist/lib/extension-search-tools.js +483 -0
- package/dist/lib/extension-search-tools.js.map +1 -0
- package/dist/lib/fetch.d.ts +28 -0
- package/dist/lib/fetch.js +106 -0
- package/dist/lib/fetch.js.map +1 -0
- package/dist/lib/mcp-examples.d.ts +99 -0
- package/dist/lib/mcp-examples.js +2285 -0
- package/dist/lib/mcp-examples.js.map +1 -0
- package/dist/lib/mcp-instructions.d.ts +11 -0
- package/dist/lib/mcp-instructions.js +78 -0
- package/dist/lib/mcp-instructions.js.map +1 -0
- package/dist/lib/mutation-guards.d.ts +33 -0
- package/dist/lib/mutation-guards.js +106 -0
- package/dist/lib/mutation-guards.js.map +1 -0
- package/dist/lib/platform-operation-tools.d.ts +12 -0
- package/dist/lib/platform-operation-tools.js +2304 -0
- package/dist/lib/platform-operation-tools.js.map +1 -0
- package/dist/lib/required-knowledge.d.ts +32 -0
- package/dist/lib/required-knowledge.js +181 -0
- package/dist/lib/required-knowledge.js.map +1 -0
- package/dist/lib/response-format.d.ts +7 -0
- package/dist/lib/response-format.js +179 -0
- package/dist/lib/response-format.js.map +1 -0
- package/dist/lib/route-guards.d.ts +1 -0
- package/dist/lib/route-guards.js +19 -0
- package/dist/lib/route-guards.js.map +1 -0
- package/dist/lib/route-permission-tools.d.ts +91 -0
- package/dist/lib/route-permission-tools.js +151 -0
- package/dist/lib/route-permission-tools.js.map +1 -0
- package/dist/lib/source-artifacts.d.ts +27 -0
- package/dist/lib/source-artifacts.js +82 -0
- package/dist/lib/source-artifacts.js.map +1 -0
- package/dist/lib/table-tools.d.ts +62 -0
- package/dist/lib/table-tools.js +774 -0
- package/dist/lib/table-tools.js.map +1 -0
- package/dist/lib/tool-routing.d.ts +297 -0
- package/dist/lib/tool-routing.js +585 -0
- package/dist/lib/tool-routing.js.map +1 -0
- package/dist/lib/types.d.ts +17 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/mcp-server-entry.d.ts +4 -0
- package/dist/mcp-server-entry.js +2787 -0
- package/dist/mcp-server-entry.js.map +1 -0
- package/package.json +17 -10
- package/src/lib/auth.js +0 -179
- package/src/lib/config-local.mjs +0 -718
- package/src/lib/fetch.js +0 -111
- package/src/lib/mcp-examples.js +0 -2289
- package/src/lib/mcp-instructions.js +0 -80
- package/src/lib/mutation-guards.js +0 -118
- package/src/lib/platform-operation-tools.js +0 -2616
- package/src/lib/required-knowledge.js +0 -188
- package/src/lib/response-format.js +0 -187
- package/src/lib/route-guards.js +0 -24
- package/src/lib/route-permission-tools.js +0 -160
- package/src/lib/source-artifacts.js +0 -82
- package/src/lib/table-tools.js +0 -907
- package/src/lib/tool-routing.js +0 -589
- 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
|
-
}
|