@cloudbase/cloudbase-mcp 2.11.1 → 2.12.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.
package/dist/index.js CHANGED
@@ -562,7 +562,7 @@ ${envIdSection}
562
562
  ## 环境信息
563
563
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
564
564
  - Node.js版本: ${process.version}
565
- - MCP 版本:${process.env.npm_package_version || "2.11.1" || 0}
565
+ - MCP 版本:${process.env.npm_package_version || "2.12.0" || 0}
566
566
  - 系统架构: ${os_1.default.arch()}
567
567
  - 时间: ${new Date().toISOString()}
568
568
  - 请求ID: ${requestId}
@@ -7404,7 +7404,11 @@ function registerGatewayTools(server) {
7404
7404
  description: "创建云函数的 HTTP 访问",
7405
7405
  inputSchema: {
7406
7406
  name: zod_1.z.string().describe("函数名"),
7407
- path: zod_1.z.string().describe("HTTP 访问路径")
7407
+ path: zod_1.z.string().describe("HTTP 访问路径"),
7408
+ type: zod_1.z
7409
+ .enum(["Event", "HTTP"])
7410
+ .optional()
7411
+ .describe("函数类型,Event 为事件型云函数(默认),HTTP 为 HTTP 云函数")
7408
7412
  },
7409
7413
  annotations: {
7410
7414
  readOnlyHint: false,
@@ -7413,10 +7417,12 @@ function registerGatewayTools(server) {
7413
7417
  openWorldHint: true,
7414
7418
  category: "gateway"
7415
7419
  }
7416
- }, async ({ name, path }) => {
7420
+ }, async ({ name, path, type }) => {
7417
7421
  const cloudbase = await getManager();
7422
+ // Event 云函数 type=1,HTTP 云函数 type=6
7423
+ const accessType = type === "HTTP" ? 6 : 1;
7418
7424
  const result = await cloudbase.access.createAccess({
7419
- type: 1,
7425
+ type: accessType, // HTTP 云函数使用 type=6,需要类型断言
7420
7426
  name,
7421
7427
  path
7422
7428
  });
@@ -8686,7 +8692,7 @@ class TelemetryReporter {
8686
8692
  const nodeVersion = process.version; // Node.js版本
8687
8693
  const arch = os_1.default.arch(); // 系统架构
8688
8694
  // 从构建时注入的版本号获取MCP版本信息
8689
- const mcpVersion = process.env.npm_package_version || "2.11.1" || 0;
8695
+ const mcpVersion = process.env.npm_package_version || "2.12.0" || 0;
8690
8696
  return {
8691
8697
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
8692
8698
  deviceId: this.deviceId,
@@ -9002,20 +9008,22 @@ exports.TRIGGER_CONFIG_EXAMPLES = exports.SUPPORTED_TRIGGER_TYPES = exports.DEFA
9002
9008
  exports.registerFunctionTools = registerFunctionTools;
9003
9009
  const zod_1 = __webpack_require__(2971);
9004
9010
  const cloudbase_manager_js_1 = __webpack_require__(3431);
9011
+ const logger_js_1 = __webpack_require__(3039);
9005
9012
  const path_1 = __importDefault(__webpack_require__(2521));
9006
9013
  // 支持的 Node.js 运行时列表
9007
9014
  exports.SUPPORTED_NODEJS_RUNTIMES = [
9008
- 'Nodejs18.15',
9009
- 'Nodejs16.13',
9010
- 'Nodejs14.18',
9011
- 'Nodejs12.16',
9012
- 'Nodejs10.15',
9013
- 'Nodejs8.9',
9015
+ "Nodejs20.19",
9016
+ "Nodejs18.15",
9017
+ "Nodejs16.13",
9018
+ "Nodejs14.18",
9019
+ "Nodejs12.16",
9020
+ "Nodejs10.15",
9021
+ "Nodejs8.9",
9014
9022
  ];
9015
- exports.DEFAULT_NODEJS_RUNTIME = 'Nodejs18.15';
9023
+ exports.DEFAULT_NODEJS_RUNTIME = "Nodejs18.15";
9016
9024
  // Supported trigger types
9017
9025
  exports.SUPPORTED_TRIGGER_TYPES = [
9018
- 'timer', // Timer trigger
9026
+ "timer", // Timer trigger
9019
9027
  ];
9020
9028
  // Trigger configuration examples
9021
9029
  exports.TRIGGER_CONFIG_EXAMPLES = {
@@ -9026,8 +9034,8 @@ exports.TRIGGER_CONFIG_EXAMPLES = {
9026
9034
  "0 30 9 * * * *", // Execute at 9:30 AM every day
9027
9035
  "0 0 12 * * * *", // Execute at 12:00 PM every day
9028
9036
  "0 0 0 1 1 * *", // Execute at midnight on January 1st every year
9029
- ]
9030
- }
9037
+ ],
9038
+ },
9031
9039
  };
9032
9040
  /**
9033
9041
  * 处理函数根目录路径,确保不包含函数名
@@ -9058,18 +9066,27 @@ function registerFunctionTools(server) {
9058
9066
  title: "查询云函数列表或详情",
9059
9067
  description: "获取云函数列表或单个函数详情。通过 action 参数区分操作类型:list=获取函数列表(默认,无需额外参数),detail=获取函数详情(需要提供 name 参数指定函数名称)",
9060
9068
  inputSchema: {
9061
- action: zod_1.z.enum(["list", "detail"]).optional().describe("操作类型:list=获取函数列表(默认,无需额外参数),detail=获取函数详情(需要提供 name 参数)"),
9069
+ action: zod_1.z
9070
+ .enum(["list", "detail"])
9071
+ .optional()
9072
+ .describe("操作类型:list=获取函数列表(默认,无需额外参数),detail=获取函数详情(需要提供 name 参数)"),
9062
9073
  limit: zod_1.z.number().optional().describe("范围(list 操作时使用)"),
9063
9074
  offset: zod_1.z.number().optional().describe("偏移(list 操作时使用)"),
9064
- name: zod_1.z.string().optional().describe("要查询的函数名称。当 action='detail' 时,此参数为必填项,必须提供已存在的函数名称。可通过 action='list' 操作获取可用的函数名称列表"),
9065
- codeSecret: zod_1.z.string().optional().describe("代码保护密钥(detail 操作时使用)")
9075
+ name: zod_1.z
9076
+ .string()
9077
+ .optional()
9078
+ .describe("要查询的函数名称。当 action='detail' 时,此参数为必填项,必须提供已存在的函数名称。可通过 action='list' 操作获取可用的函数名称列表"),
9079
+ codeSecret: zod_1.z
9080
+ .string()
9081
+ .optional()
9082
+ .describe("代码保护密钥(detail 操作时使用)"),
9066
9083
  },
9067
9084
  annotations: {
9068
9085
  readOnlyHint: true,
9069
9086
  openWorldHint: true,
9070
- category: "functions"
9071
- }
9072
- }, async ({ action = "list", limit, offset, name, codeSecret }) => {
9087
+ category: "functions",
9088
+ },
9089
+ }, async ({ action = "list", limit, offset, name, codeSecret, }) => {
9073
9090
  // 使用闭包中的 cloudBaseOptions
9074
9091
  const cloudbase = await getManager();
9075
9092
  if (action === "list") {
@@ -9079,9 +9096,9 @@ function registerFunctionTools(server) {
9079
9096
  content: [
9080
9097
  {
9081
9098
  type: "text",
9082
- text: JSON.stringify(result, null, 2)
9083
- }
9084
- ]
9099
+ text: JSON.stringify(result, null, 2),
9100
+ },
9101
+ ],
9085
9102
  };
9086
9103
  }
9087
9104
  else if (action === "detail") {
@@ -9094,9 +9111,9 @@ function registerFunctionTools(server) {
9094
9111
  content: [
9095
9112
  {
9096
9113
  type: "text",
9097
- text: JSON.stringify(result, null, 2)
9098
- }
9099
- ]
9114
+ text: JSON.stringify(result, null, 2),
9115
+ },
9116
+ ],
9100
9117
  };
9101
9118
  }
9102
9119
  else {
@@ -9106,59 +9123,115 @@ function registerFunctionTools(server) {
9106
9123
  // createFunction - 创建云函数 (cloud-incompatible)
9107
9124
  server.registerTool("createFunction", {
9108
9125
  title: "创建云函数",
9109
- description: "创建云函数",
9126
+ description: "创建云函数。云函数分为事件型云函数和 HTTP 云函数,请确认你要创建的函数类型。",
9110
9127
  inputSchema: {
9111
- func: zod_1.z.object({
9128
+ func: zod_1.z
9129
+ .object({
9112
9130
  name: zod_1.z.string().describe("函数名称"),
9131
+ type: zod_1.z
9132
+ .enum(["Event", "HTTP"])
9133
+ .optional()
9134
+ .describe("函数类型,Event 为事件型云函数,HTTP 为 HTTP 云函数"),
9135
+ protocolType: zod_1.z
9136
+ .enum(["HTTP", "WS"])
9137
+ .optional()
9138
+ .describe("HTTP 云函数的协议类型,HTTP 为 HTTP 协议(默认),WS 为 WebSocket 协议,仅当 type 为 HTTP 时有效"),
9139
+ protocolParams: zod_1.z
9140
+ .object({
9141
+ wsParams: zod_1.z
9142
+ .object({
9143
+ idleTimeOut: zod_1.z.number().optional().describe("WebSocket 空闲超时时间(秒),默认 15 秒"),
9144
+ })
9145
+ .optional()
9146
+ .describe("WebSocket 协议参数"),
9147
+ })
9148
+ .optional()
9149
+ .describe("协议参数配置,仅当 protocolType 为 WS 时有效"),
9150
+ instanceConcurrencyConfig: zod_1.z
9151
+ .object({
9152
+ dynamicEnabled: zod_1.z.boolean().optional().describe("是否启用动态并发,默认 false"),
9153
+ maxConcurrency: zod_1.z.number().optional().describe("最大并发数,默认 10"),
9154
+ })
9155
+ .optional()
9156
+ .describe("多并发配置,仅当 type 为 HTTP 时有效"),
9113
9157
  timeout: zod_1.z.number().optional().describe("函数超时时间"),
9114
9158
  envVariables: zod_1.z.record(zod_1.z.string()).optional().describe("环境变量"),
9115
- vpc: zod_1.z.object({
9159
+ vpc: zod_1.z
9160
+ .object({
9116
9161
  vpcId: zod_1.z.string(),
9117
- subnetId: zod_1.z.string()
9118
- }).optional().describe("私有网络配置"),
9119
- runtime: zod_1.z.string().optional().describe("运行时环境,建议指定为 'Nodejs18.15',其他可选值:" + exports.SUPPORTED_NODEJS_RUNTIMES.join(',')),
9120
- triggers: zod_1.z.array(zod_1.z.object({
9162
+ subnetId: zod_1.z.string(),
9163
+ })
9164
+ .optional()
9165
+ .describe("私有网络配置"),
9166
+ runtime: zod_1.z
9167
+ .string()
9168
+ .optional()
9169
+ .describe("运行时环境,建议指定为 'Nodejs18.15',其他可选值:" +
9170
+ exports.SUPPORTED_NODEJS_RUNTIMES.join(",")),
9171
+ triggers: zod_1.z
9172
+ .array(zod_1.z.object({
9121
9173
  name: zod_1.z.string().describe("Trigger name"),
9122
- type: zod_1.z.enum(exports.SUPPORTED_TRIGGER_TYPES).describe("Trigger type, currently only supports 'timer'"),
9123
- config: zod_1.z.string().describe("Trigger configuration. For timer triggers, use cron expression format: second minute hour day month week year. IMPORTANT: Must include exactly 7 fields (second minute hour day month week year). Examples: '0 0 2 1 * * *' (monthly), '0 30 9 * * * *' (daily at 9:30 AM)")
9124
- })).optional().describe("Trigger configuration array"),
9174
+ type: zod_1.z
9175
+ .enum(exports.SUPPORTED_TRIGGER_TYPES)
9176
+ .describe("Trigger type, currently only supports 'timer'"),
9177
+ config: zod_1.z
9178
+ .string()
9179
+ .describe("Trigger configuration. For timer triggers, use cron expression format: second minute hour day month week year. IMPORTANT: Must include exactly 7 fields (second minute hour day month week year). Examples: '0 0 2 1 * * *' (monthly), '0 30 9 * * * *' (daily at 9:30 AM)"),
9180
+ }))
9181
+ .optional()
9182
+ .describe("Trigger configuration array"),
9125
9183
  handler: zod_1.z.string().optional().describe("函数入口"),
9126
- ignore: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional().describe("忽略文件"),
9184
+ ignore: zod_1.z
9185
+ .union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())])
9186
+ .optional()
9187
+ .describe("忽略文件"),
9127
9188
  isWaitInstall: zod_1.z.boolean().optional().describe("是否等待依赖安装"),
9128
- layers: zod_1.z.array(zod_1.z.object({
9189
+ layers: zod_1.z
9190
+ .array(zod_1.z.object({
9129
9191
  name: zod_1.z.string(),
9130
- version: zod_1.z.number()
9131
- })).optional().describe("Layer配置")
9132
- }).describe("函数配置"),
9133
- functionRootPath: zod_1.z.string().optional().describe("函数根目录(云函数目录的父目录),这里需要传操作系统上文件的绝对路径,注意:不要包含函数名本身,例如函数名为 'hello',应传入 '/path/to/cloudfunctions',而不是 '/path/to/cloudfunctions/hello'"),
9134
- force: zod_1.z.boolean().describe("是否覆盖")
9192
+ version: zod_1.z.number(),
9193
+ }))
9194
+ .optional()
9195
+ .describe("Layer配置"),
9196
+ })
9197
+ .describe("函数配置"),
9198
+ functionRootPath: zod_1.z
9199
+ .string()
9200
+ .optional()
9201
+ .describe("函数根目录(云函数目录的父目录),这里需要传操作系统上文件的绝对路径,注意:不要包含函数名本身,例如函数名为 'hello',应传入 '/path/to/cloudfunctions',而不是 '/path/to/cloudfunctions/hello'"),
9202
+ force: zod_1.z.boolean().describe("是否覆盖"),
9135
9203
  },
9136
9204
  annotations: {
9137
9205
  readOnlyHint: false,
9138
9206
  destructiveHint: false,
9139
9207
  idempotentHint: false,
9140
9208
  openWorldHint: true,
9141
- category: "functions"
9142
- }
9143
- }, async ({ func, functionRootPath, force }) => {
9144
- // 自动填充默认 runtime
9145
- if (!func.runtime) {
9146
- func.runtime = exports.DEFAULT_NODEJS_RUNTIME;
9147
- }
9148
- else {
9149
- // 验证 runtime 格式,防止常见的空格问题
9150
- const normalizedRuntime = func.runtime.replace(/\s+/g, '');
9151
- if (exports.SUPPORTED_NODEJS_RUNTIMES.includes(normalizedRuntime)) {
9152
- func.runtime = normalizedRuntime;
9209
+ category: "functions",
9210
+ },
9211
+ }, async ({ func, functionRootPath, force, }) => {
9212
+ (0, logger_js_1.debug)(`[createFunction] name=${func.name}, type=${func.type || "Event"}`);
9213
+ // HTTP 云函数跳过 runtime 验证,Event 云函数进行验证
9214
+ const isHttpFunction = func.type === "HTTP";
9215
+ if (!isHttpFunction) {
9216
+ // 自动填充默认 runtime
9217
+ if (!func.runtime) {
9218
+ func.runtime = exports.DEFAULT_NODEJS_RUNTIME;
9153
9219
  }
9154
- else if (func.runtime.includes(' ')) {
9155
- console.warn(`检测到 runtime 参数包含空格: "${func.runtime}",已自动移除空格`);
9156
- func.runtime = normalizedRuntime;
9220
+ else {
9221
+ // 验证 runtime 格式,防止常见的空格问题
9222
+ const normalizedRuntime = func.runtime.replace(/\s+/g, "");
9223
+ if (exports.SUPPORTED_NODEJS_RUNTIMES.includes(normalizedRuntime)) {
9224
+ func.runtime = normalizedRuntime;
9225
+ }
9226
+ else if (func.runtime.includes(" ")) {
9227
+ console.warn(`检测到 runtime 参数包含空格: "${func.runtime}",已自动移除空格`);
9228
+ func.runtime = normalizedRuntime;
9229
+ }
9230
+ }
9231
+ // 验证 runtime 是否有效
9232
+ if (!exports.SUPPORTED_NODEJS_RUNTIMES.includes(func.runtime)) {
9233
+ throw new Error(`不支持的运行时环境: "${func.runtime}"。支持的值:${exports.SUPPORTED_NODEJS_RUNTIMES.join(", ")}`);
9157
9234
  }
9158
- }
9159
- // 验证 runtime 是否有效
9160
- if (!exports.SUPPORTED_NODEJS_RUNTIMES.includes(func.runtime)) {
9161
- throw new Error(`不支持的运行时环境: "${func.runtime}"。支持的值:${exports.SUPPORTED_NODEJS_RUNTIMES.join(', ')}`);
9162
9235
  }
9163
9236
  // 强制设置 installDependency 为 true(不暴露给AI)
9164
9237
  func.installDependency = true;
@@ -9169,16 +9242,16 @@ function registerFunctionTools(server) {
9169
9242
  const result = await cloudbase.functions.createFunction({
9170
9243
  func,
9171
9244
  functionRootPath: processedRootPath,
9172
- force
9245
+ force,
9173
9246
  });
9174
9247
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
9175
9248
  return {
9176
9249
  content: [
9177
9250
  {
9178
9251
  type: "text",
9179
- text: JSON.stringify(result, null, 2)
9180
- }
9181
- ]
9252
+ text: JSON.stringify(result, null, 2),
9253
+ },
9254
+ ],
9182
9255
  };
9183
9256
  });
9184
9257
  // updateFunctionCode - 更新函数代码 (cloud-incompatible)
@@ -9187,7 +9260,9 @@ function registerFunctionTools(server) {
9187
9260
  description: "更新已存在函数的代码。注意:此工具仅用于更新代码,不支持修改函数配置(如 runtime)。如果需要修改 runtime,需要删除函数后使用 createFunction 重新创建。",
9188
9261
  inputSchema: {
9189
9262
  name: zod_1.z.string().describe("函数名称"),
9190
- functionRootPath: zod_1.z.string().describe("函数根目录(云函数目录的父目录),这里需要传操作系统上文件的绝对路径"),
9263
+ functionRootPath: zod_1.z
9264
+ .string()
9265
+ .describe("函数根目录(云函数目录的父目录),这里需要传操作系统上文件的绝对路径"),
9191
9266
  // zipFile: z.string().optional().describe("Base64编码的函数包"),
9192
9267
  // handler: z.string().optional().describe("函数入口"),
9193
9268
  // runtime: z.string().optional().describe("运行时(可选值:" + SUPPORTED_NODEJS_RUNTIMES.join(',') + ",默认 Nodejs 18.15)")
@@ -9197,9 +9272,9 @@ function registerFunctionTools(server) {
9197
9272
  destructiveHint: false,
9198
9273
  idempotentHint: false,
9199
9274
  openWorldHint: true,
9200
- category: "functions"
9201
- }
9202
- }, async ({ name, functionRootPath, zipFile, handler }) => {
9275
+ category: "functions",
9276
+ },
9277
+ }, async ({ name, functionRootPath, zipFile, handler, }) => {
9203
9278
  // 处理函数根目录路径,确保不包含函数名
9204
9279
  const processedRootPath = processFunctionRootPath(functionRootPath, name);
9205
9280
  // 构建更新参数,强制设置 installDependency 为 true(不暴露给AI)
@@ -9208,9 +9283,9 @@ function registerFunctionTools(server) {
9208
9283
  func: {
9209
9284
  name,
9210
9285
  installDependency: true,
9211
- ...(handler && { handler })
9286
+ ...(handler && { handler }),
9212
9287
  },
9213
- functionRootPath: processedRootPath
9288
+ functionRootPath: processedRootPath,
9214
9289
  };
9215
9290
  // 如果提供了zipFile,则添加到参数中
9216
9291
  if (zipFile) {
@@ -9224,9 +9299,9 @@ function registerFunctionTools(server) {
9224
9299
  content: [
9225
9300
  {
9226
9301
  type: "text",
9227
- text: JSON.stringify(result, null, 2)
9228
- }
9229
- ]
9302
+ text: JSON.stringify(result, null, 2),
9303
+ },
9304
+ ],
9230
9305
  };
9231
9306
  });
9232
9307
  // updateFunctionConfig - 更新函数配置
@@ -9234,24 +9309,29 @@ function registerFunctionTools(server) {
9234
9309
  title: "更新云函数配置",
9235
9310
  description: "更新云函数配置",
9236
9311
  inputSchema: {
9237
- funcParam: zod_1.z.object({
9312
+ funcParam: zod_1.z
9313
+ .object({
9238
9314
  name: zod_1.z.string().describe("函数名称"),
9239
9315
  timeout: zod_1.z.number().optional().describe("超时时间"),
9240
9316
  envVariables: zod_1.z.record(zod_1.z.string()).optional().describe("环境变量"),
9241
- vpc: zod_1.z.object({
9317
+ vpc: zod_1.z
9318
+ .object({
9242
9319
  vpcId: zod_1.z.string(),
9243
- subnetId: zod_1.z.string()
9244
- }).optional().describe("VPC配置"),
9320
+ subnetId: zod_1.z.string(),
9321
+ })
9322
+ .optional()
9323
+ .describe("VPC配置"),
9245
9324
  // runtime: z.string().optional().describe("运行时(可选值:" + SUPPORTED_NODEJS_RUNTIMES.join(',') + ",默认 Nodejs 18.15)")
9246
- }).describe("函数配置")
9325
+ })
9326
+ .describe("函数配置"),
9247
9327
  },
9248
9328
  annotations: {
9249
9329
  readOnlyHint: false,
9250
9330
  destructiveHint: false,
9251
9331
  idempotentHint: false,
9252
9332
  openWorldHint: true,
9253
- category: "functions"
9254
- }
9333
+ category: "functions",
9334
+ },
9255
9335
  }, async ({ funcParam }) => {
9256
9336
  // 自动填充默认 runtime
9257
9337
  // if (!funcParam.runtime) {
@@ -9261,10 +9341,15 @@ function registerFunctionTools(server) {
9261
9341
  const cloudbase = await getManager();
9262
9342
  const functionDetail = await cloudbase.functions.getFunctionDetail(funcParam.name);
9263
9343
  functionDetail.Environment;
9264
- const vpc = (typeof functionDetail.VpcConfig === 'object' && functionDetail.VpcConfig !== null && functionDetail.VpcConfig.SubnetId && functionDetail.VpcConfig.VpcId) ? {
9265
- subnetId: functionDetail.VpcConfig.SubnetId,
9266
- vpcId: functionDetail.VpcConfig.VpcId
9267
- } : undefined;
9344
+ const vpc = typeof functionDetail.VpcConfig === "object" &&
9345
+ functionDetail.VpcConfig !== null &&
9346
+ functionDetail.VpcConfig.SubnetId &&
9347
+ functionDetail.VpcConfig.VpcId
9348
+ ? {
9349
+ subnetId: functionDetail.VpcConfig.SubnetId,
9350
+ vpcId: functionDetail.VpcConfig.VpcId,
9351
+ }
9352
+ : undefined;
9268
9353
  const result = await cloudbase.functions.updateFunctionConfig({
9269
9354
  name: funcParam.name,
9270
9355
  envVariables: Object.assign({}, functionDetail.Environment.Variables.reduce((acc, curr) => {
@@ -9279,9 +9364,9 @@ function registerFunctionTools(server) {
9279
9364
  content: [
9280
9365
  {
9281
9366
  type: "text",
9282
- text: JSON.stringify(result, null, 2)
9283
- }
9284
- ]
9367
+ text: JSON.stringify(result, null, 2),
9368
+ },
9369
+ ],
9285
9370
  };
9286
9371
  });
9287
9372
  // invokeFunction - 调用函数
@@ -9290,16 +9375,16 @@ function registerFunctionTools(server) {
9290
9375
  description: "调用云函数",
9291
9376
  inputSchema: {
9292
9377
  name: zod_1.z.string().describe("函数名称"),
9293
- params: zod_1.z.record(zod_1.z.any()).optional().describe("调用参数")
9378
+ params: zod_1.z.record(zod_1.z.any()).optional().describe("调用参数"),
9294
9379
  },
9295
9380
  annotations: {
9296
9381
  readOnlyHint: false,
9297
9382
  destructiveHint: false,
9298
9383
  idempotentHint: false,
9299
9384
  openWorldHint: true,
9300
- category: "functions"
9301
- }
9302
- }, async ({ name, params }) => {
9385
+ category: "functions",
9386
+ },
9387
+ }, async ({ name, params, }) => {
9303
9388
  // 使用闭包中的 cloudBaseOptions
9304
9389
  try {
9305
9390
  const cloudbase = await getManager();
@@ -9309,13 +9394,13 @@ function registerFunctionTools(server) {
9309
9394
  content: [
9310
9395
  {
9311
9396
  type: "text",
9312
- text: JSON.stringify(result, null, 2)
9313
- }
9314
- ]
9397
+ text: JSON.stringify(result, null, 2),
9398
+ },
9399
+ ],
9315
9400
  };
9316
9401
  }
9317
9402
  catch (error) {
9318
- const errorMessage = (error instanceof Error ? error.message : String(error));
9403
+ const errorMessage = error instanceof Error ? error.message : String(error);
9319
9404
  if (errorMessage.includes("Function not found") ||
9320
9405
  errorMessage.includes("函数不存在")) {
9321
9406
  throw new Error(`${errorMessage}\n\n` +
@@ -9332,19 +9417,31 @@ function registerFunctionTools(server) {
9332
9417
  description: "获取云函数日志基础信息(LogList),如需日志详情请用 RequestId 调用 getFunctionLogDetail 工具。此接口基于 manger-node 4.4.0+ 的 getFunctionLogsV2 实现,不返回具体日志内容。参数 offset+limit 不得大于 10000,startTime/endTime 间隔不得超过一天。",
9333
9418
  inputSchema: {
9334
9419
  name: zod_1.z.string().describe("函数名称"),
9335
- offset: zod_1.z.number().optional().describe("数据的偏移量,Offset+Limit 不能大于 10000"),
9336
- limit: zod_1.z.number().optional().describe("返回数据的长度,Offset+Limit 不能大于 10000"),
9337
- startTime: zod_1.z.string().optional().describe("查询的具体日期,例如:2017-05-16 20:00:00,只能与 EndTime 相差一天之内"),
9338
- endTime: zod_1.z.string().optional().describe("查询的具体日期,例如:2017-05-16 20:59:59,只能与 StartTime 相差一天之内"),
9420
+ offset: zod_1.z
9421
+ .number()
9422
+ .optional()
9423
+ .describe("数据的偏移量,Offset+Limit 不能大于 10000"),
9424
+ limit: zod_1.z
9425
+ .number()
9426
+ .optional()
9427
+ .describe("返回数据的长度,Offset+Limit 不能大于 10000"),
9428
+ startTime: zod_1.z
9429
+ .string()
9430
+ .optional()
9431
+ .describe("查询的具体日期,例如:2017-05-16 20:00:00,只能与 EndTime 相差一天之内"),
9432
+ endTime: zod_1.z
9433
+ .string()
9434
+ .optional()
9435
+ .describe("查询的具体日期,例如:2017-05-16 20:59:59,只能与 StartTime 相差一天之内"),
9339
9436
  requestId: zod_1.z.string().optional().describe("执行该函数对应的 requestId"),
9340
- qualifier: zod_1.z.string().optional().describe("函数版本,默认为 $LATEST")
9437
+ qualifier: zod_1.z.string().optional().describe("函数版本,默认为 $LATEST"),
9341
9438
  },
9342
9439
  annotations: {
9343
9440
  readOnlyHint: true,
9344
9441
  openWorldHint: true,
9345
- category: "functions"
9346
- }
9347
- }, async ({ name, offset, limit, startTime, endTime, requestId, qualifier }) => {
9442
+ category: "functions",
9443
+ },
9444
+ }, async ({ name, offset, limit, startTime, endTime, requestId, qualifier, }) => {
9348
9445
  if ((offset || 0) + (limit || 0) > 10000) {
9349
9446
  throw new Error("offset+limit 不能大于 10000");
9350
9447
  }
@@ -9356,15 +9453,23 @@ function registerFunctionTools(server) {
9356
9453
  }
9357
9454
  }
9358
9455
  const cloudbase = await getManager();
9359
- const result = await cloudbase.functions.getFunctionLogsV2({ name, offset, limit, startTime, endTime, requestId, qualifier });
9456
+ const result = await cloudbase.functions.getFunctionLogsV2({
9457
+ name,
9458
+ offset,
9459
+ limit,
9460
+ startTime,
9461
+ endTime,
9462
+ requestId,
9463
+ qualifier,
9464
+ });
9360
9465
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
9361
9466
  return {
9362
9467
  content: [
9363
9468
  {
9364
9469
  type: "text",
9365
- text: JSON.stringify(result, null, 2)
9366
- }
9367
- ]
9470
+ text: JSON.stringify(result, null, 2),
9471
+ },
9472
+ ],
9368
9473
  };
9369
9474
  });
9370
9475
  // getFunctionLogDetail - 查询日志详情(参数直接展开)
@@ -9372,15 +9477,21 @@ function registerFunctionTools(server) {
9372
9477
  title: "获取云函数日志详情",
9373
9478
  description: "根据 getFunctionLogs 返回的 RequestId 查询日志详情。参数 startTime、endTime、requestId,返回日志内容(LogJson 等)。仅支持 manger-node 4.4.0+。",
9374
9479
  inputSchema: {
9375
- startTime: zod_1.z.string().optional().describe("查询的具体日期,例如:2017-05-16 20:00:00,只能与 EndTime 相差一天之内"),
9376
- endTime: zod_1.z.string().optional().describe("查询的具体日期,例如:2017-05-16 20:59:59,只能与 StartTime 相差一天之内"),
9377
- requestId: zod_1.z.string().describe("执行该函数对应的 requestId")
9480
+ startTime: zod_1.z
9481
+ .string()
9482
+ .optional()
9483
+ .describe("查询的具体日期,例如:2017-05-16 20:00:00,只能与 EndTime 相差一天之内"),
9484
+ endTime: zod_1.z
9485
+ .string()
9486
+ .optional()
9487
+ .describe("查询的具体日期,例如:2017-05-16 20:59:59,只能与 StartTime 相差一天之内"),
9488
+ requestId: zod_1.z.string().describe("执行该函数对应的 requestId"),
9378
9489
  },
9379
9490
  annotations: {
9380
9491
  readOnlyHint: true,
9381
9492
  openWorldHint: true,
9382
- category: "functions"
9383
- }
9493
+ category: "functions",
9494
+ },
9384
9495
  }, async ({ startTime, endTime, requestId }) => {
9385
9496
  if (startTime && endTime) {
9386
9497
  const start = new Date(startTime).getTime();
@@ -9393,16 +9504,16 @@ function registerFunctionTools(server) {
9393
9504
  const result = await cloudbase.functions.getFunctionLogDetail({
9394
9505
  startTime,
9395
9506
  endTime,
9396
- logRequestId: requestId
9507
+ logRequestId: requestId,
9397
9508
  });
9398
9509
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
9399
9510
  return {
9400
9511
  content: [
9401
9512
  {
9402
9513
  type: "text",
9403
- text: JSON.stringify(result, null, 2)
9404
- }
9405
- ]
9514
+ text: JSON.stringify(result, null, 2),
9515
+ },
9516
+ ],
9406
9517
  };
9407
9518
  });
9408
9519
  // manageFunctionTriggers - 管理云函数触发器(创建/删除)
@@ -9410,23 +9521,32 @@ function registerFunctionTools(server) {
9410
9521
  title: "管理云函数触发器",
9411
9522
  description: "创建或删除云函数触发器,通过 action 参数区分操作类型",
9412
9523
  inputSchema: {
9413
- action: zod_1.z.enum(["create", "delete"]).describe("操作类型:create=创建触发器,delete=删除触发器"),
9524
+ action: zod_1.z
9525
+ .enum(["create", "delete"])
9526
+ .describe("操作类型:create=创建触发器,delete=删除触发器"),
9414
9527
  name: zod_1.z.string().describe("函数名"),
9415
- triggers: zod_1.z.array(zod_1.z.object({
9528
+ triggers: zod_1.z
9529
+ .array(zod_1.z.object({
9416
9530
  name: zod_1.z.string().describe("Trigger name"),
9417
- type: zod_1.z.enum(exports.SUPPORTED_TRIGGER_TYPES).describe("Trigger type, currently only supports 'timer'"),
9418
- config: zod_1.z.string().describe("Trigger configuration. For timer triggers, use cron expression format: second minute hour day month week year. IMPORTANT: Must include exactly 7 fields (second minute hour day month week year). Examples: '0 0 2 1 * * *' (monthly), '0 30 9 * * * *' (daily at 9:30 AM)")
9419
- })).optional().describe("触发器配置数组(创建时必需)"),
9420
- triggerName: zod_1.z.string().optional().describe("触发器名称(删除时必需)")
9531
+ type: zod_1.z
9532
+ .enum(exports.SUPPORTED_TRIGGER_TYPES)
9533
+ .describe("Trigger type, currently only supports 'timer'"),
9534
+ config: zod_1.z
9535
+ .string()
9536
+ .describe("Trigger configuration. For timer triggers, use cron expression format: second minute hour day month week year. IMPORTANT: Must include exactly 7 fields (second minute hour day month week year). Examples: '0 0 2 1 * * *' (monthly), '0 30 9 * * * *' (daily at 9:30 AM)"),
9537
+ }))
9538
+ .optional()
9539
+ .describe("触发器配置数组(创建时必需)"),
9540
+ triggerName: zod_1.z.string().optional().describe("触发器名称(删除时必需)"),
9421
9541
  },
9422
9542
  annotations: {
9423
9543
  readOnlyHint: false,
9424
9544
  destructiveHint: false,
9425
9545
  idempotentHint: false,
9426
9546
  openWorldHint: true,
9427
- category: "functions"
9428
- }
9429
- }, async ({ action, name, triggers, triggerName }) => {
9547
+ category: "functions",
9548
+ },
9549
+ }, async ({ action, name, triggers, triggerName, }) => {
9430
9550
  // 使用闭包中的 cloudBaseOptions
9431
9551
  const cloudbase = await getManager();
9432
9552
  if (action === "create") {
@@ -9439,9 +9559,9 @@ function registerFunctionTools(server) {
9439
9559
  content: [
9440
9560
  {
9441
9561
  type: "text",
9442
- text: JSON.stringify(result, null, 2)
9443
- }
9444
- ]
9562
+ text: JSON.stringify(result, null, 2),
9563
+ },
9564
+ ],
9445
9565
  };
9446
9566
  }
9447
9567
  else if (action === "delete") {
@@ -9454,9 +9574,9 @@ function registerFunctionTools(server) {
9454
9574
  content: [
9455
9575
  {
9456
9576
  type: "text",
9457
- text: JSON.stringify(result, null, 2)
9458
- }
9459
- ]
9577
+ text: JSON.stringify(result, null, 2),
9578
+ },
9579
+ ],
9460
9580
  };
9461
9581
  }
9462
9582
  else {
@@ -10119,7 +10239,7 @@ function registerSetupTools(server) {
10119
10239
  title: "下载项目模板",
10120
10240
  description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
10121
10241
 
10122
- **CRITICAL**: This tool MUST be called FIRST when starting a new project.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置\n- cursor: Cursor AI编辑器\n- 其他IDE类型见下方列表\n\n注意:如果未传入 ide 参数且无法从环境变量检测到 IDE,将提示错误并要求传入 ide 参数\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- qoder: Qoder AI编辑器\n- antigravity: Google Antigravity AI编辑器\n- vscode: Visual Studio Code\n- kiro: Kiro AI编辑器\n- aider: Aider AI编辑器\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.11.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
10242
+ **CRITICAL**: This tool MUST be called FIRST when starting a new project.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置\n- cursor: Cursor AI编辑器\n- 其他IDE类型见下方列表\n\n注意:如果未传入 ide 参数且无法从环境变量检测到 IDE,将提示错误并要求传入 ide 参数\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- qoder: Qoder AI编辑器\n- antigravity: Google Antigravity AI编辑器\n- vscode: Visual Studio Code\n- kiro: Kiro AI编辑器\n- aider: Aider AI编辑器\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.12.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
10123
10243
  inputSchema: {
10124
10244
  template: zod_1.z
10125
10245
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])