@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.
@@ -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 export an async function: module.exports = async (ctx) => { ... }"),
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, min: 1000, max: 300000)"),
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 (min: 1000, max: 300000)"),
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 export an async function: module.exports = async (ctx) => { ... }"),
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, min: 1000, max: 300000)"),
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;
@@ -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: "module.exports = async (ctx) => { /* your code */ return result; }",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centrali-io/centrali-mcp",
3
- "version": "4.2.7",
3
+ "version": "4.2.8",
4
4
  "description": "Centrali MCP Server - AI assistant integration for Centrali workspaces",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
@@ -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 export an async function: module.exports = async (ctx) => { ... }"),
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, min: 1000, max: 300000)"),
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 (min: 1000, max: 300000)"),
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 export an async function: module.exports = async (ctx) => { ... }"),
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, min: 1000, max: 300000)"),
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;
@@ -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: "module.exports = async (ctx) => { /* your code */ return result; }",
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.",