@cloudbase/cloudbase-mcp 2.23.2 → 2.23.5

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
@@ -1585,9 +1585,9 @@ function registerEnvTools(server) {
1585
1585
  .optional()
1586
1586
  .describe("环境地域(action=create 时可选)。默认 ap-shanghai,可选 ap-guangzhou、ap-beijing 等"),
1587
1587
  resources: zod_1.z
1588
- .array(zod_1.z.enum(["flexdb", "storage", "function"]))
1588
+ .array(zod_1.z.enum(["flexdb", "storage", "function", "postgresql"]))
1589
1589
  .optional()
1590
- .describe("启用的资源类型(action=create 时可选)。默认启用全部三项:flexdb(文档数据库)、storage(存储)、function(云函数)"),
1590
+ .describe("启用的资源类型(action=create 时可选)。默认启用全部四项:flexdb(文档数据库)、storage(存储)、function(云函数)、postgresql(PostgreSQL 数据库)"),
1591
1591
  duration: zod_1.z
1592
1592
  .number()
1593
1593
  .int()
@@ -1640,7 +1640,7 @@ function registerEnvTools(server) {
1640
1640
  return (0, tool_result_js_1.buildJsonToolResult)({
1641
1641
  ok: false,
1642
1642
  code: "CONFIRM_REQUIRED",
1643
- message: `创建环境需要您确认。请确认以下配置信息后传入 confirm="yes":\n别名: ${alias}\n套餐: ${packageId}\n地域: ${region}\n资源类型: ${resources?.join(", ") ?? "flexdb, storage, function"}\n时长: ${duration} 个月`,
1643
+ message: `创建环境需要您确认。请确认以下配置信息后传入 confirm="yes":\n别名: ${alias}\n套餐: ${packageId}\n地域: ${region}\n资源类型: ${resources?.join(", ") ?? "flexdb, storage, function, postgresql"}\n时长: ${duration} 个月`,
1644
1644
  next_step: {
1645
1645
  tool: "manageEnv",
1646
1646
  action: "create",
@@ -1767,6 +1767,7 @@ function registerEnvTools(server) {
1767
1767
 
1768
1768
 
1769
1769
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1770
+ exports.removeEmptyStringParams = removeEmptyStringParams;
1770
1771
  exports.buildCapiErrorMessage = buildCapiErrorMessage;
1771
1772
  exports.registerCapiTools = registerCapiTools;
1772
1773
  const zod_1 = __webpack_require__(2971);
@@ -1802,6 +1803,19 @@ function levenshteinDistance(left, right) {
1802
1803
  }
1803
1804
  return matrix[left.length][right.length];
1804
1805
  }
1806
+ /**
1807
+ * Remove empty string parameters from the params object.
1808
+ * Tencent Cloud APIs reject empty strings for required parameters like StartTime/EndTime.
1809
+ */
1810
+ function removeEmptyStringParams(params) {
1811
+ const cleaned = {};
1812
+ for (const [key, value] of Object.entries(params)) {
1813
+ if (value !== "") {
1814
+ cleaned[key] = value;
1815
+ }
1816
+ }
1817
+ return cleaned;
1818
+ }
1805
1819
  function findTcbActionEntry(action) {
1806
1820
  if (tcb_action_index_js_1.TCB_ACTION_INDEX_MAP[action]) {
1807
1821
  return tcb_action_index_js_1.TCB_ACTION_INDEX_MAP[action];
@@ -1988,9 +2002,10 @@ function registerCapiTools(server) {
1988
2002
  }
1989
2003
  let result;
1990
2004
  try {
2005
+ const cleanedParams = params ? removeEmptyStringParams(params) : {};
1991
2006
  result = await cloudbase.commonService(service).call({
1992
2007
  Action: action,
1993
- Param: params ?? {},
2008
+ Param: cleanedParams,
1994
2009
  });
1995
2010
  }
1996
2011
  catch (error) {
@@ -2080,7 +2095,7 @@ ${envIdSection}
2080
2095
  ## 环境信息
2081
2096
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
2082
2097
  - Node.js版本: ${process.version}
2083
- - MCP 版本:${process.env.npm_package_version || "2.23.2" || 0}
2098
+ - MCP 版本:${process.env.npm_package_version || "2.23.5" || 0}
2084
2099
  - 系统架构: ${os_1.default.arch()}
2085
2100
  - 时间: ${new Date().toISOString()}
2086
2101
  - 请求ID: ${requestId}
@@ -2161,7 +2176,7 @@ function createWrappedHandler(name, handler, server) {
2161
2176
  requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
2162
2177
  ide: server.ide || process.env.INTEGRATION_IDE || ''
2163
2178
  });
2164
- const mcpVersion = true ? "2.23.2" : 0;
2179
+ const mcpVersion = true ? "2.23.5" : 0;
2165
2180
  const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
2166
2181
  const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
2167
2182
  // 创建新的错误对象,保持原有的错误类型但更新消息
@@ -7644,7 +7659,7 @@ const queryStorageInputSchema = {
7644
7659
  // Input schema for manageStorage tool
7645
7660
  const manageStorageInputSchema = {
7646
7661
  action: zod_1.z.enum(['upload', 'download', 'delete']).describe('管理操作类型:upload=上传文件或目录,download=下载文件或目录,delete=删除文件或目录'),
7647
- localPath: zod_1.z.string().describe('本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt'),
7662
+ localPath: zod_1.z.string().optional().describe('本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt;upload/download 操作时必填,delete 操作时不需要传该参数'),
7648
7663
  cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt'),
7649
7664
  force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,删除操作时建议设置为true以确认删除,默认false'),
7650
7665
  isDirectory: zod_1.z.boolean().optional().default(false).describe('是否为目录操作,true=目录操作,false=文件操作,默认false')
@@ -7894,14 +7909,16 @@ function registerStorageTools(server) {
7894
7909
  const storageService = manager.storage;
7895
7910
  switch (input.action) {
7896
7911
  case 'upload': {
7912
+ const localPath = input.localPath;
7913
+ const cloudPath = input.cloudPath;
7897
7914
  if (input.isDirectory) {
7898
7915
  if (storageOverrides?.uploadDirectory) {
7899
- await storageOverrides.uploadDirectory({ localPath: input.localPath, cloudPath: input.cloudPath });
7916
+ await storageOverrides.uploadDirectory({ localPath, cloudPath });
7900
7917
  }
7901
7918
  else {
7902
7919
  await storageService.uploadDirectory({
7903
- localPath: input.localPath,
7904
- cloudPath: input.cloudPath,
7920
+ localPath,
7921
+ cloudPath,
7905
7922
  onProgress: (progressData) => {
7906
7923
  console.log("Upload directory progress:", progressData);
7907
7924
  }
@@ -7910,12 +7927,12 @@ function registerStorageTools(server) {
7910
7927
  }
7911
7928
  else {
7912
7929
  if (storageOverrides?.uploadFile) {
7913
- await storageOverrides.uploadFile({ localPath: input.localPath, cloudPath: input.cloudPath });
7930
+ await storageOverrides.uploadFile({ localPath, cloudPath });
7914
7931
  }
7915
7932
  else {
7916
7933
  await storageService.uploadFile({
7917
- localPath: input.localPath,
7918
- cloudPath: input.cloudPath,
7934
+ localPath,
7935
+ cloudPath,
7919
7936
  onProgress: (progressData) => {
7920
7937
  console.log("Upload file progress:", progressData);
7921
7938
  }
@@ -7982,25 +7999,27 @@ function registerStorageTools(server) {
7982
7999
  };
7983
8000
  }
7984
8001
  case 'download': {
8002
+ const dlCloudPath = input.cloudPath;
8003
+ const dlLocalPath = input.localPath;
7985
8004
  if (input.isDirectory) {
7986
8005
  if (storageOverrides?.downloadDirectory) {
7987
- await storageOverrides.downloadDirectory({ cloudPath: input.cloudPath, localPath: input.localPath });
8006
+ await storageOverrides.downloadDirectory({ cloudPath: dlCloudPath, localPath: dlLocalPath });
7988
8007
  }
7989
8008
  else {
7990
8009
  await storageService.downloadDirectory({
7991
- cloudPath: input.cloudPath,
7992
- localPath: input.localPath
8010
+ cloudPath: dlCloudPath,
8011
+ localPath: dlLocalPath
7993
8012
  });
7994
8013
  }
7995
8014
  }
7996
8015
  else {
7997
8016
  if (storageOverrides?.downloadFile) {
7998
- await storageOverrides.downloadFile({ cloudPath: input.cloudPath, localPath: input.localPath });
8017
+ await storageOverrides.downloadFile({ cloudPath: dlCloudPath, localPath: dlLocalPath });
7999
8018
  }
8000
8019
  else {
8001
8020
  await storageService.downloadFile({
8002
- cloudPath: input.cloudPath,
8003
- localPath: input.localPath
8021
+ cloudPath: dlCloudPath,
8022
+ localPath: dlLocalPath
8004
8023
  });
8005
8024
  }
8006
8025
  }
@@ -9737,7 +9756,7 @@ class TelemetryReporter {
9737
9756
  const nodeVersion = process.version; // Node.js版本
9738
9757
  const arch = os_1.default.arch(); // 系统架构
9739
9758
  // 从构建时注入的版本号获取MCP版本信息
9740
- const mcpVersion = process.env.npm_package_version || "2.23.2" || 0;
9759
+ const mcpVersion = process.env.npm_package_version || "2.23.5" || 0;
9741
9760
  return {
9742
9761
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
9743
9762
  deviceId: this.deviceId,
@@ -10026,7 +10045,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10026
10045
  return (mod && mod.__esModule) ? mod : { "default": mod };
10027
10046
  };
10028
10047
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10029
- exports.MANAGE_FUNCTION_ACTIONS = exports.QUERY_FUNCTION_ACTIONS = exports.TRIGGER_CONFIG_EXAMPLES = exports.SUPPORTED_TRIGGER_TYPES = exports.DEFAULT_NODEJS_RUNTIME = exports.SUPPORTED_NODEJS_RUNTIMES = exports.RECOMMENDED_RUNTIMES = exports.DEFAULT_RUNTIME = exports.ALL_SUPPORTED_RUNTIMES = exports.SUPPORTED_RUNTIMES = void 0;
10048
+ exports.CUSTOM_IMAGE_RUNTIME = exports.MANAGE_FUNCTION_ACTIONS = exports.QUERY_FUNCTION_ACTIONS = exports.TRIGGER_CONFIG_EXAMPLES = exports.SUPPORTED_TRIGGER_TYPES = exports.DEFAULT_NODEJS_RUNTIME = exports.SUPPORTED_NODEJS_RUNTIMES = exports.RECOMMENDED_RUNTIMES = exports.DEFAULT_RUNTIME = exports.ALL_SUPPORTED_RUNTIMES = exports.SUPPORTED_RUNTIMES = void 0;
10030
10049
  exports.formatRuntimeList = formatRuntimeList;
10031
10050
  exports.validateTimerCron = validateTimerCron;
10032
10051
  exports.shouldInstallDependencyForFunction = shouldInstallDependencyForFunction;
@@ -10134,6 +10153,41 @@ const VPC_SCHEMA = zod_1.z.object({
10134
10153
  vpcId: zod_1.z.string(),
10135
10154
  subnetId: zod_1.z.string(),
10136
10155
  });
10156
+ // 镜像部署值,对应 SCF Runtime=CustomImage
10157
+ exports.CUSTOM_IMAGE_RUNTIME = "CustomImage";
10158
+ // HTTP 函数镜像部署配置,对应 Manager SDK 的 IFunctionImageConfig(camelCase)。
10159
+ // 用于 zip→COS→CloudApp custom 构建→TCR→SCF 镜像部署链路的「阶段 B」:基于已推送到 TCR 的镜像创建/更新函数。
10160
+ const IMAGE_CONFIG_SCHEMA = zod_1.z.object({
10161
+ imageType: zod_1.z
10162
+ .enum(["enterprise", "personal"])
10163
+ .optional()
10164
+ .describe("镜像仓库类型:enterprise(企业版 TCR)或 personal(个人版)。省略时默认 enterprise。"),
10165
+ imageUri: zod_1.z
10166
+ .string()
10167
+ .describe("完整镜像地址(必须含 tag),格式 {domain}/{namespace}/{image}:{tag}," +
10168
+ "例如 ccr.ccs.tencentyun.com/your-ns/demo-app:demo-app-001。不要使用 :latest。"),
10169
+ registryId: zod_1.z
10170
+ .string()
10171
+ .optional()
10172
+ .describe("TCR 实例 ID,形如 tcr-xxxxxxxx。imageType=enterprise 时必填。"),
10173
+ command: zod_1.z
10174
+ .string()
10175
+ .optional()
10176
+ .describe("覆盖镜像 ENTRYPOINT。不填则使用 Dockerfile 默认值,例如 python。"),
10177
+ args: zod_1.z
10178
+ .string()
10179
+ .optional()
10180
+ .describe("覆盖镜像 CMD,空格分隔,例如 -u app.py。"),
10181
+ entryPoint: zod_1.z.string().optional().describe("镜像入口点,一般不需要单独设置。"),
10182
+ imagePort: zod_1.z
10183
+ .number()
10184
+ .optional()
10185
+ .describe("容器监听端口。Web Server 函数填 9000(默认),Job 型镜像填 -1。"),
10186
+ containerImageAccelerate: zod_1.z
10187
+ .boolean()
10188
+ .optional()
10189
+ .describe("是否开启镜像加速。镜像较大时建议开启以缩短冷启动时间。"),
10190
+ });
10137
10191
  const SEVEN_FIELD_CRON_REGEX = /^\s*\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s*$/;
10138
10192
  function validateTimerCron(config) {
10139
10193
  const trimmed = config.trim();
@@ -10193,7 +10247,11 @@ const CREATE_FUNCTION_SCHEMA = zod_1.z.object({
10193
10247
  ` Python: ${exports.RECOMMENDED_RUNTIMES.python}\n` +
10194
10248
  ` PHP: ${exports.RECOMMENDED_RUNTIMES.php}\n` +
10195
10249
  ` Java: ${exports.RECOMMENDED_RUNTIMES.java}\n` +
10196
- ` Go: ${exports.RECOMMENDED_RUNTIMES.golang}`),
10250
+ ` Go: ${exports.RECOMMENDED_RUNTIMES.golang}\n\n` +
10251
+ `镜像部署(基于 TCR 镜像创建函数)时填 "${exports.CUSTOM_IMAGE_RUNTIME}",并提供 imageConfig;此时无需 functionRootPath/zipFile。`),
10252
+ imageConfig: IMAGE_CONFIG_SCHEMA.optional().describe("镜像部署配置(仅 runtime=CustomImage 时使用)。" +
10253
+ "用于 zip→COS→CloudApp custom 构建→TCR→SCF 的「阶段 B」:基于已推送到 TCR 的镜像创建 HTTP 函数。" +
10254
+ "传入 imageConfig 后即按镜像部署处理,函数无需打包本地代码、scf_bootstrap 或 Handler。"),
10197
10255
  triggers: zod_1.z.array(TRIGGER_SCHEMA).optional().describe("触发器配置数组"),
10198
10256
  handler: zod_1.z.string().optional().describe("函数入口"),
10199
10257
  ignore: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]).optional().describe("忽略文件"),
@@ -10342,7 +10400,12 @@ function registerFunctionTools(server) {
10342
10400
  return;
10343
10401
  }
10344
10402
  if (input.action === "createFunction" || input.action === "updateFunctionCode") {
10345
- throw new Error(`${input.action} 在 cloud mode 下不可用,因为该操作依赖本地函数代码目录。请改用本地模式执行。`);
10403
+ // 镜像部署不依赖本地代码目录(代码已在 TCR),cloud mode 下可用。
10404
+ const hasImageConfig = Boolean(input.imageConfig ?? input.func?.imageConfig);
10405
+ if (hasImageConfig) {
10406
+ return;
10407
+ }
10408
+ throw new Error(`${input.action} 在 cloud mode 下不可用,因为该操作依赖本地函数代码目录。请改用本地模式执行,或使用镜像部署(runtime=CustomImage + imageConfig)。`);
10346
10409
  }
10347
10410
  if (input.action === "createLayerVersion" && input.contentPath) {
10348
10411
  throw new Error("createLayerVersion 在 cloud mode 下不支持 contentPath,本地文件内容请改为 base64Content 或改用本地模式执行。");
@@ -10692,6 +10755,70 @@ function registerFunctionTools(server) {
10692
10755
  const func = { ...input.func };
10693
10756
  const functionName = String(func.name);
10694
10757
  (0, logger_js_1.debug)(`[createFunction] name=${functionName}, type=${String(func.type || "Event")}`);
10758
+ // 镜像部署分支(Runtime=CustomImage):基于已推送到 TCR 的镜像创建 HTTP 函数。
10759
+ // 对应 zip→COS→CloudApp custom 构建→TCR→SCF 链路的「阶段 B」。
10760
+ const createImageConfig = input.imageConfig ??
10761
+ func.imageConfig;
10762
+ const isImageRuntime = typeof func.runtime === "string" &&
10763
+ func.runtime.replace(/\s+/g, "").toLowerCase() ===
10764
+ exports.CUSTOM_IMAGE_RUNTIME.toLowerCase();
10765
+ if (createImageConfig || isImageRuntime) {
10766
+ if (!createImageConfig?.imageUri) {
10767
+ throw new Error("镜像部署(runtime=CustomImage)时,imageConfig.imageUri 是必需的," +
10768
+ "格式为 {domain}/{namespace}/{image}:{tag}(含 tag,不要用 :latest)。");
10769
+ }
10770
+ if ((createImageConfig.imageType ?? "enterprise") === "enterprise" &&
10771
+ !createImageConfig.registryId) {
10772
+ throw new Error("imageType=enterprise(企业版 TCR)时,imageConfig.registryId(tcr-xxxxxxxx)是必需的。");
10773
+ }
10774
+ // 镜像函数即 HTTP 函数;Manager SDK 会自动补 ImageType=enterprise、ImagePort=9000,
10775
+ // 并在镜像部署时剥离 Handler / InstallDependency,故此处不需要 functionRootPath。
10776
+ const imageFunc = {
10777
+ ...func,
10778
+ type: func.type ?? "HTTP",
10779
+ runtime: exports.CUSTOM_IMAGE_RUNTIME,
10780
+ imageConfig: createImageConfig,
10781
+ };
10782
+ delete imageFunc.installDependency;
10783
+ let imageResult;
10784
+ try {
10785
+ imageResult = await cloudbase.functions.createFunction({
10786
+ func: imageFunc,
10787
+ deployMode: "image",
10788
+ force: Boolean(input.force),
10789
+ });
10790
+ }
10791
+ catch (error) {
10792
+ throw wrapFunctionOperationError("createFunction", functionName, undefined, error);
10793
+ }
10794
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, imageResult);
10795
+ return buildEnvelope({
10796
+ action: input.action,
10797
+ functionName,
10798
+ deployMode: "image",
10799
+ imageUri: createImageConfig.imageUri,
10800
+ raw: imageResult,
10801
+ }, `已基于镜像 ${createImageConfig.imageUri} 创建 HTTP 函数 ${functionName}。` +
10802
+ `请确认 TCR、SCF 与构建管道处于同一地域;如需通过 URL 访问,请显式调用 ` +
10803
+ `manageGateway(action="createAccess", type="HTTP") 并按需调整函数安全规则。` +
10804
+ `部署后可用 queryFunctions(action="getFunctionDetail") 确认函数已就绪。`, [
10805
+ {
10806
+ tool: "queryFunctions",
10807
+ action: "getFunctionDetail",
10808
+ reason: "确认镜像函数已就绪(Active)",
10809
+ },
10810
+ {
10811
+ tool: "manageFunctions",
10812
+ action: "updateFunctionCode",
10813
+ reason: "后续迭代只需用新镜像 tag 调用 updateFunctionCode 更新镜像",
10814
+ },
10815
+ {
10816
+ tool: "manageGateway",
10817
+ action: "createAccess",
10818
+ reason: "如需通过 URL 访问镜像 HTTP 函数,显式创建网关访问入口并传 type=\"HTTP\"",
10819
+ },
10820
+ ]);
10821
+ }
10695
10822
  if (func.type !== "HTTP") {
10696
10823
  const originalRuntime = typeof func.runtime === "string" ? func.runtime : undefined;
10697
10824
  func.runtime = resolveEventFunctionRuntime(func.runtime);
@@ -10785,6 +10912,42 @@ function registerFunctionTools(server) {
10785
10912
  throw new Error("updateFunctionCode 操作时,functionName 参数是必需的");
10786
10913
  }
10787
10914
  const cloudbase = await getManager();
10915
+ // 镜像更新分支:后续迭代只需用新镜像 tag 更新函数。
10916
+ const updateImageConfig = input.imageConfig ??
10917
+ input.func?.imageConfig;
10918
+ if (updateImageConfig) {
10919
+ if (!updateImageConfig.imageUri) {
10920
+ throw new Error("镜像更新时,imageConfig.imageUri 是必需的,格式为 {domain}/{namespace}/{image}:{tag}(含 tag,不要用 :latest)。");
10921
+ }
10922
+ let imageResult;
10923
+ try {
10924
+ imageResult = await cloudbase.functions.updateFunctionCode({
10925
+ func: {
10926
+ name: input.functionName,
10927
+ imageConfig: updateImageConfig,
10928
+ },
10929
+ deployMode: "image",
10930
+ });
10931
+ }
10932
+ catch (error) {
10933
+ throw wrapFunctionOperationError("updateFunctionCode", input.functionName, undefined, error);
10934
+ }
10935
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, imageResult);
10936
+ return buildEnvelope({
10937
+ action: input.action,
10938
+ functionName: input.functionName,
10939
+ deployMode: "image",
10940
+ imageUri: updateImageConfig.imageUri,
10941
+ raw: imageResult,
10942
+ }, `已将函数 ${input.functionName} 的镜像更新为 ${updateImageConfig.imageUri}。` +
10943
+ `部署后可用 queryFunctions(action="getFunctionDetail") 确认函数已就绪(Active)。`, [
10944
+ {
10945
+ tool: "queryFunctions",
10946
+ action: "getFunctionDetail",
10947
+ reason: "确认镜像更新后函数已就绪(Active)",
10948
+ },
10949
+ ]);
10950
+ }
10788
10951
  const processedRootPath = processFunctionRootPath(input.functionRootPath, input.functionName);
10789
10952
  const updateParams = {
10790
10953
  func: {
@@ -11195,6 +11358,8 @@ function registerFunctionTools(server) {
11195
11358
  title: "管理 CloudBase 云函数",
11196
11359
  description: "CloudBase 云函数统一写入口。支持创建函数、更新代码、更新配置、调用函数、管理定时跑 / 定时任务 / scheduled job 的 timer 触发器和层绑定。" +
11197
11360
  "如果要创建 cron 定时任务,先用 createFunction 创建函数,再用 createFunctionTrigger 创建 timer 触发器(支持7段cron表达式),deleteFunctionTrigger 删除触发器。" +
11361
+ "镜像部署(Runtime=CustomImage):先把代码经 zip→COS→CloudApp custom 构建→TCR 推镜像(这一阶段为裸腾讯云 API,本工具不覆盖)," +
11362
+ "再用 createFunction(func.runtime=\"CustomImage\", imageConfig) 基于 TCR 镜像创建 HTTP 函数;后续迭代用 updateFunctionCode + imageConfig 换镜像 tag。" +
11198
11363
  "危险操作需要显式 confirm=true。",
11199
11364
  inputSchema: {
11200
11365
  action: zod_1.z
@@ -11234,6 +11399,9 @@ function registerFunctionTools(server) {
11234
11399
  .optional()
11235
11400
  .describe("updateFunctionLayers 的目标层列表,顺序即最终顺序"),
11236
11401
  codeSecret: zod_1.z.string().optional().describe("层绑定时的代码保护密钥"),
11402
+ imageConfig: IMAGE_CONFIG_SCHEMA.optional().describe("镜像部署配置(Runtime=CustomImage)。createFunction 时基于 TCR 镜像创建 HTTP 函数," +
11403
+ "updateFunctionCode 时仅更换镜像 tag。需提供 imageUri(含 tag),企业版 TCR 还需 registryId。" +
11404
+ "也可在 func.imageConfig 中提供;两处都传时以顶层 imageConfig 优先。"),
11237
11405
  confirm: zod_1.z.boolean().optional().describe("危险操作确认开关。deleteFunction、deleteFunctionTrigger、deleteLayerVersion、detachLayer 等删除类操作需要显式传入 confirm=true"),
11238
11406
  incrementalFile: zod_1.z.string().optional().describe("incrementalDeployFunction 增量部署时的变更文件路径"),
11239
11407
  },
@@ -13599,7 +13767,7 @@ function registerSetupTools(server) {
13599
13767
  server.registerTool("downloadTemplate", {
13600
13768
  title: "下载项目模板",
13601
13769
  description: `自动下载并部署CloudBase项目模板。
13602
- **Note**: Call this tool when the user requests to create a new project using a CloudBase template.\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.23.2" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
13770
+ **Note**: Call this tool when the user requests to create a new project using a CloudBase template.\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.23.5" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
13603
13771
  inputSchema: {
13604
13772
  template: zod_1.z
13605
13773
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
@@ -16879,6 +17047,8 @@ function registerAgentTools(server) {
16879
17047
  category: "agents",
16880
17048
  },
16881
17049
  }, async ({ action, agentId, name, description, runtime, timeout, memorySize, installDependency, zipFile, cosBucketRegion, tempCosObjectName, sessionConfig, cwd, params, }) => {
17050
+ let _agentName;
17051
+ let _agentRuntime;
16882
17052
  try {
16883
17053
  const cloudbase = await getManager();
16884
17054
  const payload = normalizeAgentPayload({
@@ -16895,11 +17065,19 @@ function registerAgentTools(server) {
16895
17065
  cwd,
16896
17066
  ...(params ?? {}),
16897
17067
  });
17068
+ _agentName = payload?.Name;
17069
+ _agentRuntime = payload?.Runtime;
16898
17070
  if (action === "createAgent") {
16899
17071
  const normalizedName = normalizeString(payload.Name);
16900
17072
  if (!normalizedName) {
16901
17073
  throw new Error("action=createAgent 时必须提供 name(可通过顶层 name 或 params.name 传入)");
16902
17074
  }
17075
+ // CloudBase 后端在创建 Agent 时会同步创建云函数,函数名/别名长度受 SCF 限制(最大 64 字符)。
17076
+ // envId 可能被用作前缀或别名的一部分,因此这里预留足够余量,避免后端 CreateFunction 失败。
17077
+ if (normalizedName.length > 30) {
17078
+ throw new Error(`agent name 过长(当前 ${normalizedName.length} 字符)。CloudBase 创建 Agent 时会同步创建云函数,` +
17079
+ `函数名/别名受 SCF 64 字符限制,且 envId 可能作为前缀拼接。请将 name 控制在 30 字符以内。`);
17080
+ }
16903
17081
  const createPayload = {
16904
17082
  ...payload,
16905
17083
  Name: normalizedName,
@@ -16938,6 +17116,17 @@ function registerAgentTools(server) {
16938
17116
  }, "Agent 删除成功"));
16939
17117
  }
16940
17118
  catch (error) {
17119
+ // 对后端 InternalError 提供更有意义的错误信息
17120
+ const errMsg = error instanceof Error ? error.message : String(error);
17121
+ if (errMsg.includes("InternalError") || errMsg.includes("服务处理出错")) {
17122
+ server.logger?.({
17123
+ type: "createAgentError",
17124
+ message: "createAgent 后端返回 InternalError,可能是云函数创建失败",
17125
+ originalError: errMsg,
17126
+ name: _agentName,
17127
+ runtime: _agentRuntime,
17128
+ });
17129
+ }
16941
17130
  return (0, json_content_js_1.jsonContent)(buildErrorEnvelope(error));
16942
17131
  }
16943
17132
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cloudbase-mcp",
3
- "version": "2.23.2",
3
+ "version": "2.23.5",
4
4
  "packageManager": "pnpm@10.8.0",
5
5
  "description": "腾讯云开发 MCP Server,通过AI提示词和MCP协议+云开发,让开发更智能、更高效,当你在Cursor/ VSCode GitHub Copilot/WinSurf/CodeBuddy/Augment Code/Claude Code等AI编程工具里写代码时,它能自动帮你生成可直接部署的前后端应用+小程序,并一键发布到腾讯云开发 CloudBase。",
6
6
  "main": "./dist/index.cjs",