@centrali-io/centrali-mcp 4.2.7 → 4.2.8
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/dist/tools/compute.js +39 -6
- package/dist/tools/describe.js +1 -1
- package/package.json +1 -1
- package/src/tools/compute.ts +42 -6
- package/src/tools/describe.ts +1 -1
package/dist/tools/compute.js
CHANGED
|
@@ -155,11 +155,22 @@ function registerComputeTools(server, sdk) {
|
|
|
155
155
|
}));
|
|
156
156
|
server.tool("create_function", "Create a new compute function. Compute functions are JavaScript code blocks that run server-side.", {
|
|
157
157
|
name: zod_1.z.string().describe("Display name for the function"),
|
|
158
|
-
code: zod_1.z.string().describe("JavaScript source code. Must
|
|
158
|
+
code: zod_1.z.string().describe("JavaScript source code. Must define 'async function run() { ... }'. Globals: api, triggerParams, executionParams. Do NOT use module.exports."),
|
|
159
159
|
description: zod_1.z.string().optional().describe("Optional description of what the function does"),
|
|
160
|
-
timeoutMs: zod_1.z.number().optional().describe("Execution timeout in milliseconds (default: 30000,
|
|
160
|
+
timeoutMs: zod_1.z.number().optional().describe("Execution timeout in milliseconds (default: 30000, max: 300000 / 5 minutes)"),
|
|
161
161
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ name, code, description, timeoutMs }) {
|
|
162
162
|
try {
|
|
163
|
+
if (/module\.exports\s*=/.test(code)) {
|
|
164
|
+
return {
|
|
165
|
+
content: [
|
|
166
|
+
{
|
|
167
|
+
type: "text",
|
|
168
|
+
text: "Error: Do not use module.exports. Functions must define 'async function run() { ... }'. Globals available: api, triggerParams, executionParams.",
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
isError: true,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
163
174
|
const input = { name, code };
|
|
164
175
|
if (description !== undefined)
|
|
165
176
|
input.description = description;
|
|
@@ -188,10 +199,21 @@ function registerComputeTools(server, sdk) {
|
|
|
188
199
|
functionId: zod_1.z.string().describe("The compute function ID (UUID) to update"),
|
|
189
200
|
name: zod_1.z.string().optional().describe("Updated display name"),
|
|
190
201
|
description: zod_1.z.string().optional().describe("Updated description"),
|
|
191
|
-
code: zod_1.z.string().optional().describe("Updated JavaScript source code"),
|
|
192
|
-
timeoutMs: zod_1.z.number().optional().describe("Updated execution timeout in milliseconds (
|
|
202
|
+
code: zod_1.z.string().optional().describe("Updated JavaScript source code. Must define 'async function run() { ... }'. Do NOT use module.exports."),
|
|
203
|
+
timeoutMs: zod_1.z.number().optional().describe("Updated execution timeout in milliseconds (max: 300000 / 5 minutes)"),
|
|
193
204
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ functionId, name, description, code, timeoutMs }) {
|
|
194
205
|
try {
|
|
206
|
+
if (code && /module\.exports\s*=/.test(code)) {
|
|
207
|
+
return {
|
|
208
|
+
content: [
|
|
209
|
+
{
|
|
210
|
+
type: "text",
|
|
211
|
+
text: "Error: Do not use module.exports. Functions must define 'async function run() { ... }'. Globals available: api, triggerParams, executionParams.",
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
isError: true,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
195
217
|
const input = {};
|
|
196
218
|
if (name !== undefined)
|
|
197
219
|
input.name = name;
|
|
@@ -247,14 +269,25 @@ function registerComputeTools(server, sdk) {
|
|
|
247
269
|
}
|
|
248
270
|
}));
|
|
249
271
|
server.tool("test_function", "Test execute code without saving it as a function. Useful for validating function code before creating or updating.", {
|
|
250
|
-
code: zod_1.z.string().describe("JavaScript code to test. Must
|
|
272
|
+
code: zod_1.z.string().describe("JavaScript code to test. Must define 'async function run() { ... }'. Globals: api, triggerParams, executionParams. Do NOT use module.exports."),
|
|
251
273
|
params: zod_1.z
|
|
252
274
|
.record(zod_1.z.string(), zod_1.z.any())
|
|
253
275
|
.optional()
|
|
254
276
|
.describe("Optional parameters passed to the function as executionParams"),
|
|
255
|
-
timeoutMs: zod_1.z.number().optional().describe("Execution timeout in milliseconds (default: 30000,
|
|
277
|
+
timeoutMs: zod_1.z.number().optional().describe("Execution timeout in milliseconds (default: 30000, max: 300000 / 5 minutes)"),
|
|
256
278
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ code, params, timeoutMs }) {
|
|
257
279
|
try {
|
|
280
|
+
if (/module\.exports\s*=/.test(code)) {
|
|
281
|
+
return {
|
|
282
|
+
content: [
|
|
283
|
+
{
|
|
284
|
+
type: "text",
|
|
285
|
+
text: "Error: Do not use module.exports. Functions must define 'async function run() { ... }'. Globals available: api, triggerParams, executionParams.",
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
isError: true,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
258
291
|
const testInput = { code };
|
|
259
292
|
if (params !== undefined)
|
|
260
293
|
testInput.params = params;
|
package/dist/tools/describe.js
CHANGED
|
@@ -432,7 +432,7 @@ function registerDescribeTools(server) {
|
|
|
432
432
|
description: "Create a new compute function",
|
|
433
433
|
required_params: ["name", "code"],
|
|
434
434
|
optional_params: ["description", "timeoutMs"],
|
|
435
|
-
code_format: "
|
|
435
|
+
code_format: "async function run() { /* api, triggerParams, executionParams are globals */ return result; }",
|
|
436
436
|
},
|
|
437
437
|
update_function: {
|
|
438
438
|
description: "Update an existing function. Partial updates supported.",
|
package/package.json
CHANGED
package/src/tools/compute.ts
CHANGED
|
@@ -174,12 +174,24 @@ export function registerComputeTools(server: McpServer, sdk: CentraliSDK) {
|
|
|
174
174
|
"Create a new compute function. Compute functions are JavaScript code blocks that run server-side.",
|
|
175
175
|
{
|
|
176
176
|
name: z.string().describe("Display name for the function"),
|
|
177
|
-
code: z.string().describe("JavaScript source code. Must
|
|
177
|
+
code: z.string().describe("JavaScript source code. Must define 'async function run() { ... }'. Globals: api, triggerParams, executionParams. Do NOT use module.exports."),
|
|
178
178
|
description: z.string().optional().describe("Optional description of what the function does"),
|
|
179
|
-
timeoutMs: z.number().optional().describe("Execution timeout in milliseconds (default: 30000,
|
|
179
|
+
timeoutMs: z.number().optional().describe("Execution timeout in milliseconds (default: 30000, max: 300000 / 5 minutes)"),
|
|
180
180
|
},
|
|
181
181
|
async ({ name, code, description, timeoutMs }) => {
|
|
182
182
|
try {
|
|
183
|
+
if (/module\.exports\s*=/.test(code)) {
|
|
184
|
+
return {
|
|
185
|
+
content: [
|
|
186
|
+
{
|
|
187
|
+
type: "text",
|
|
188
|
+
text: "Error: Do not use module.exports. Functions must define 'async function run() { ... }'. Globals available: api, triggerParams, executionParams.",
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
isError: true,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
183
195
|
const input: Record<string, any> = { name, code };
|
|
184
196
|
if (description !== undefined) input.description = description;
|
|
185
197
|
if (timeoutMs !== undefined) input.timeoutMs = timeoutMs;
|
|
@@ -211,11 +223,23 @@ export function registerComputeTools(server: McpServer, sdk: CentraliSDK) {
|
|
|
211
223
|
functionId: z.string().describe("The compute function ID (UUID) to update"),
|
|
212
224
|
name: z.string().optional().describe("Updated display name"),
|
|
213
225
|
description: z.string().optional().describe("Updated description"),
|
|
214
|
-
code: z.string().optional().describe("Updated JavaScript source code"),
|
|
215
|
-
timeoutMs: z.number().optional().describe("Updated execution timeout in milliseconds (
|
|
226
|
+
code: z.string().optional().describe("Updated JavaScript source code. Must define 'async function run() { ... }'. Do NOT use module.exports."),
|
|
227
|
+
timeoutMs: z.number().optional().describe("Updated execution timeout in milliseconds (max: 300000 / 5 minutes)"),
|
|
216
228
|
},
|
|
217
229
|
async ({ functionId, name, description, code, timeoutMs }) => {
|
|
218
230
|
try {
|
|
231
|
+
if (code && /module\.exports\s*=/.test(code)) {
|
|
232
|
+
return {
|
|
233
|
+
content: [
|
|
234
|
+
{
|
|
235
|
+
type: "text",
|
|
236
|
+
text: "Error: Do not use module.exports. Functions must define 'async function run() { ... }'. Globals available: api, triggerParams, executionParams.",
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
isError: true,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
219
243
|
const input: Record<string, any> = {};
|
|
220
244
|
if (name !== undefined) input.name = name;
|
|
221
245
|
if (description !== undefined) input.description = description;
|
|
@@ -277,15 +301,27 @@ export function registerComputeTools(server: McpServer, sdk: CentraliSDK) {
|
|
|
277
301
|
"test_function",
|
|
278
302
|
"Test execute code without saving it as a function. Useful for validating function code before creating or updating.",
|
|
279
303
|
{
|
|
280
|
-
code: z.string().describe("JavaScript code to test. Must
|
|
304
|
+
code: z.string().describe("JavaScript code to test. Must define 'async function run() { ... }'. Globals: api, triggerParams, executionParams. Do NOT use module.exports."),
|
|
281
305
|
params: z
|
|
282
306
|
.record(z.string(), z.any())
|
|
283
307
|
.optional()
|
|
284
308
|
.describe("Optional parameters passed to the function as executionParams"),
|
|
285
|
-
timeoutMs: z.number().optional().describe("Execution timeout in milliseconds (default: 30000,
|
|
309
|
+
timeoutMs: z.number().optional().describe("Execution timeout in milliseconds (default: 30000, max: 300000 / 5 minutes)"),
|
|
286
310
|
},
|
|
287
311
|
async ({ code, params, timeoutMs }) => {
|
|
288
312
|
try {
|
|
313
|
+
if (/module\.exports\s*=/.test(code)) {
|
|
314
|
+
return {
|
|
315
|
+
content: [
|
|
316
|
+
{
|
|
317
|
+
type: "text",
|
|
318
|
+
text: "Error: Do not use module.exports. Functions must define 'async function run() { ... }'. Globals available: api, triggerParams, executionParams.",
|
|
319
|
+
},
|
|
320
|
+
],
|
|
321
|
+
isError: true,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
289
325
|
const testInput: Record<string, any> = { code };
|
|
290
326
|
if (params !== undefined) testInput.params = params;
|
|
291
327
|
if (timeoutMs !== undefined) testInput.timeoutMs = timeoutMs;
|
package/src/tools/describe.ts
CHANGED
|
@@ -502,7 +502,7 @@ export function registerDescribeTools(server: McpServer) {
|
|
|
502
502
|
description: "Create a new compute function",
|
|
503
503
|
required_params: ["name", "code"],
|
|
504
504
|
optional_params: ["description", "timeoutMs"],
|
|
505
|
-
code_format: "
|
|
505
|
+
code_format: "async function run() { /* api, triggerParams, executionParams are globals */ return result; }",
|
|
506
506
|
},
|
|
507
507
|
update_function: {
|
|
508
508
|
description: "Update an existing function. Partial updates supported.",
|