@cloudbase/cloudbase-mcp 1.8.42 → 1.8.43

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/cli.cjs CHANGED
@@ -1247,9 +1247,6 @@ function registerEnvTools(server) {
1247
1247
  if (error) {
1248
1248
  return { content: [{ type: "text", text: error }] };
1249
1249
  }
1250
- if (noEnvs) {
1251
- return { content: [{ type: "text", text: "当前账户下暂无可用的云开发环境,请先在腾讯云控制台创建环境 https://tcb.cloud.tencent.com/dev?from=AIToolkit" }] };
1252
- }
1253
1250
  if (cancelled) {
1254
1251
  return { content: [{ type: "text", text: "用户取消了登录" }] };
1255
1252
  }
@@ -1327,12 +1324,12 @@ function registerEnvTools(server) {
1327
1324
  switch (action) {
1328
1325
  case "list":
1329
1326
  try {
1330
- const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId: false });
1327
+ const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId: true });
1331
1328
  result = await cloudbaseList.env.listEnvs();
1332
1329
  }
1333
1330
  catch (error) {
1334
1331
  (0, logger_js_1.debug)('获取环境列表时出错:', error);
1335
- return { content: [{ type: "text", text: "当前账户下暂无可用的云开发环境,请先在腾讯云控制台创建环境 https://tcb.cloud.tencent.com/dev?from=AIToolkit \n错误信息:" + (error instanceof Error ? error.message : String(error)) }]
1332
+ return { content: [{ type: "text", text: "获取环境列表时出错: " + (error instanceof Error ? error.message : String(error)) }]
1336
1333
  };
1337
1334
  }
1338
1335
  break;
@@ -22466,11 +22463,11 @@ exports.getEnvId = getEnvId;
22466
22463
  exports.resetCloudBaseManagerCache = resetCloudBaseManagerCache;
22467
22464
  exports.getCloudBaseManager = getCloudBaseManager;
22468
22465
  exports.createCloudBaseManagerWithOptions = createCloudBaseManagerWithOptions;
22466
+ const manager_node_1 = __importDefault(__webpack_require__(95492));
22469
22467
  const auth_js_1 = __webpack_require__(77291);
22470
22468
  const interactive_js_1 = __webpack_require__(3461);
22471
- const manager_node_1 = __importDefault(__webpack_require__(95492));
22472
22469
  const logger_js_1 = __webpack_require__(13039);
22473
- const ENV_ID_TIMEOUT = 600000; // 600 seconds
22470
+ const ENV_ID_TIMEOUT = 60000000; // 60000 seconds
22474
22471
  // 统一的环境ID管理类
22475
22472
  class EnvironmentManager {
22476
22473
  cachedEnvId = null;
@@ -22639,14 +22636,14 @@ exports.saveEnvIdToUserConfig = saveEnvIdToUserConfig;
22639
22636
  exports.loadEnvIdFromUserConfig = loadEnvIdFromUserConfig;
22640
22637
  exports.clearUserEnvId = clearUserEnvId;
22641
22638
  exports.autoSetupEnvironmentId = autoSetupEnvironmentId;
22639
+ const promises_1 = __importDefault(__webpack_require__(79748));
22640
+ const os_1 = __importDefault(__webpack_require__(21820));
22641
+ const path_1 = __importDefault(__webpack_require__(39902));
22642
22642
  const zod_1 = __webpack_require__(21614);
22643
- const interactive_server_js_1 = __webpack_require__(92341);
22644
- const cloudbase_manager_js_1 = __webpack_require__(3431);
22645
22643
  const auth_js_1 = __webpack_require__(77291);
22644
+ const cloudbase_manager_js_1 = __webpack_require__(3431);
22645
+ const interactive_server_js_1 = __webpack_require__(92341);
22646
22646
  const logger_js_1 = __webpack_require__(13039);
22647
- const promises_1 = __importDefault(__webpack_require__(79748));
22648
- const path_1 = __importDefault(__webpack_require__(39902));
22649
- const os_1 = __importDefault(__webpack_require__(21820));
22650
22647
  function registerInteractiveTools(server) {
22651
22648
  // 统一的交互式对话工具 (cloud-incompatible)
22652
22649
  server.registerTool("interactiveDialog", {
@@ -101565,11 +101562,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
101565
101562
  Object.defineProperty(exports, "__esModule", ({ value: true }));
101566
101563
  exports.CLOUDRUN_ACCESS_TYPES = exports.CLOUDRUN_SERVICE_TYPES = void 0;
101567
101564
  exports.registerCloudRunTools = registerCloudRunTools;
101565
+ const child_process_1 = __webpack_require__(79646);
101566
+ const fs_1 = __importDefault(__webpack_require__(29021));
101567
+ const path_1 = __importDefault(__webpack_require__(39902));
101568
101568
  const zod_1 = __webpack_require__(21614);
101569
101569
  const cloudbase_manager_js_1 = __webpack_require__(3431);
101570
- const path_1 = __importDefault(__webpack_require__(39902));
101571
- const fs_1 = __importDefault(__webpack_require__(29021));
101572
- const child_process_1 = __webpack_require__(79646);
101573
101570
  // CloudRun service types
101574
101571
  exports.CLOUDRUN_SERVICE_TYPES = ['function', 'container'];
101575
101572
  // CloudRun access types
@@ -101581,7 +101578,7 @@ const queryCloudRunInputSchema = {
101581
101578
  pageSize: zod_1.z.number().min(1).max(100).optional().default(10).describe('分页大小,控制每页返回的服务数量。取值范围:1-100,默认值:10。建议根据网络性能和显示需求调整'),
101582
101579
  pageNum: zod_1.z.number().min(1).optional().default(1).describe('页码,用于分页查询。从1开始,默认值:1。配合pageSize使用可实现分页浏览'),
101583
101580
  serverName: zod_1.z.string().optional().describe('服务名称筛选条件,支持模糊匹配。例如:输入"test"可匹配"test-service"、"my-test-app"等服务名称。留空则查询所有服务'),
101584
- serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function=函数型云托管(简化开发模式,支持WebSocket/SSE/文件上传等特性,适合快速开发),container=容器型服务(传统容器部署模式,支持任意语言和框架,适合复杂应用)'),
101581
+ serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)'),
101585
101582
  // Detail operation parameters
101586
101583
  detailServerName: zod_1.z.string().optional().describe('要查询详细信息的服务名称。当action为detail时必需提供,必须是已存在的服务名称。可通过list操作获取可用的服务名称列表'),
101587
101584
  };
@@ -101595,7 +101592,7 @@ const ManageCloudRunInputSchema = {
101595
101592
  OpenAccessTypes: zod_1.z.array(zod_1.z.enum(exports.CLOUDRUN_ACCESS_TYPES)).optional().describe('公网访问类型配置,控制服务的访问权限:WEB=公网访问(默认,可通过HTTPS域名访问),VPC=私有网络访问(仅同VPC内可访问),PRIVATE=内网访问(仅云开发环境内可访问)。可配置多个类型'),
101596
101593
  Cpu: zod_1.z.number().positive().optional().describe('CPU规格配置,单位为核。可选值:0.25、0.5、1、2、4、8等。注意:内存规格必须是CPU规格的2倍(如CPU=0.25时内存=0.5,CPU=1时内存=2)。影响服务性能和计费'),
101597
101594
  Mem: zod_1.z.number().positive().optional().describe('内存规格配置,单位为GB。可选值:0.5、1、2、4、8、16等。注意:必须是CPU规格的2倍。影响服务性能和计费'),
101598
- MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0时始终保持指定数量的实例运行(确保快速响应但会增加成本)'),
101595
+ MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0时始终保持指定数量的实例运行(确保快速响应但会增加成本)。建议设置为1以降低冷启动延迟,提升用户体验'),
101599
101596
  MaxNum: zod_1.z.number().min(1).optional().describe('最大实例数配置,控制服务的最大运行实例数量。当请求量增加时,服务最多可以扩展到指定数量的实例,超过此数量后将拒绝新的请求。建议根据业务峰值设置'),
101600
101597
  Port: zod_1.z.number().min(1).max(65535).optional().describe('服务监听端口配置。函数型服务固定为3000,容器型服务可自定义。服务代码必须监听此端口才能正常接收请求'),
101601
101598
  EnvParams: zod_1.z.record(zod_1.z.string()).optional().describe('环境变量配置,用于传递配置信息给服务代码。格式为键值对,如{"DATABASE_URL":"mysql://..."}。敏感信息建议使用环境变量而非硬编码'),
@@ -101623,6 +101620,7 @@ const ManageCloudRunInputSchema = {
101623
101620
  }).optional().describe('Agent配置项,仅在createAgent操作时使用'),
101624
101621
  // Common parameters
101625
101622
  force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,用于跳过确认提示。默认false(需要确认),设置为true时跳过所有确认步骤。删除操作时强烈建议设置为true以避免误操作'),
101623
+ serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型配置:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)。不提供时自动检测:1)现有服务类型 2)有Dockerfile→container 3)有@cloudbase/aiagent-framework依赖→function 4)其他情况→container'),
101626
101624
  };
101627
101625
  /**
101628
101626
  * Check if a project is an Agent project
@@ -101997,21 +101995,47 @@ for await (let x of res.textStream) {
101997
101995
  if (!targetPath) {
101998
101996
  throw new Error("targetPath is required for deploy operation");
101999
101997
  }
102000
- // Determine service type automatically
101998
+ // Determine service type - use input.serverType if provided, otherwise auto-detect
102001
101999
  let serverType;
102002
- try {
102003
- // First try to get existing service details
102004
- const details = await cloudrunService.detail({ serverName: input.serverName });
102005
- serverType = details.BaseInfo?.ServerType || 'function';
102000
+ if (input.serverType) {
102001
+ serverType = input.serverType;
102006
102002
  }
102007
- catch (e) {
102008
- // If service doesn't exist, determine by project structure
102009
- const dockerfilePath = path_1.default.join(targetPath, 'Dockerfile');
102010
- if (fs_1.default.existsSync(dockerfilePath)) {
102011
- serverType = 'container';
102003
+ else {
102004
+ try {
102005
+ // First try to get existing service details
102006
+ const details = await cloudrunService.detail({ serverName: input.serverName });
102007
+ serverType = details.BaseInfo?.ServerType || 'container';
102012
102008
  }
102013
- else {
102014
- serverType = 'function';
102009
+ catch (e) {
102010
+ // If service doesn't exist, determine by project structure
102011
+ const dockerfilePath = path_1.default.join(targetPath, 'Dockerfile');
102012
+ if (fs_1.default.existsSync(dockerfilePath)) {
102013
+ serverType = 'container';
102014
+ }
102015
+ else {
102016
+ // Check if it's a Node.js function project (has package.json with specific structure)
102017
+ const packageJsonPath = path_1.default.join(targetPath, 'package.json');
102018
+ if (fs_1.default.existsSync(packageJsonPath)) {
102019
+ try {
102020
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
102021
+ // If it has function-specific dependencies or scripts, treat as function
102022
+ if (packageJson.dependencies?.['@cloudbase/aiagent-framework'] ||
102023
+ packageJson.scripts?.['dev']?.includes('cloudrun run')) {
102024
+ serverType = 'function';
102025
+ }
102026
+ else {
102027
+ serverType = 'container';
102028
+ }
102029
+ }
102030
+ catch (parseError) {
102031
+ serverType = 'container';
102032
+ }
102033
+ }
102034
+ else {
102035
+ // No package.json, default to container
102036
+ serverType = 'container';
102037
+ }
102038
+ }
102015
102039
  }
102016
102040
  }
102017
102041
  const deployParams = {
@@ -122092,7 +122116,7 @@ class TelemetryReporter {
122092
122116
  const nodeVersion = process.version; // Node.js版本
122093
122117
  const arch = os_1.default.arch(); // 系统架构
122094
122118
  // 从构建时注入的版本号获取MCP版本信息
122095
- const mcpVersion = process.env.npm_package_version || "1.8.42" || 0;
122119
+ const mcpVersion = process.env.npm_package_version || "1.8.43" || 0;
122096
122120
  return {
122097
122121
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
122098
122122
  deviceId: this.deviceId,
@@ -179978,7 +180002,7 @@ ${envIdSection}
179978
180002
  ## 环境信息
179979
180003
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
179980
180004
  - Node.js版本: ${process.version}
179981
- - MCP 版本:${process.env.npm_package_version || "1.8.42" || 0}
180005
+ - MCP 版本:${process.env.npm_package_version || "1.8.43" || 0}
179982
180006
  - 系统架构: ${os_1.default.arch()}
179983
180007
  - 时间: ${new Date().toISOString()}
179984
180008
  - 请求ID: ${requestId}
@@ -195004,7 +195028,7 @@ function registerSetupTools(server) {
195004
195028
  // downloadTemplate - 下载项目模板 (cloud-incompatible)
195005
195029
  server.registerTool("downloadTemplate", {
195006
195030
  title: "下载项目模板",
195007
- description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.42" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
195031
+ description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.43" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
195008
195032
  inputSchema: {
195009
195033
  template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
195010
195034
  ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
@@ -196213,9 +196237,9 @@ async function getLoginState() {
196213
196237
  }
196214
196238
  const loginState = await auth.getLoginState();
196215
196239
  if (!loginState) {
196216
- (0, logger_js_1.debug)('loginByApiSecret');
196217
196240
  await auth.loginByWebAuth({});
196218
196241
  const loginState = await auth.getLoginState();
196242
+ (0, logger_js_1.debug)('loginByWebAuth', loginState);
196219
196243
  return loginState;
196220
196244
  }
196221
196245
  else {
@@ -228516,8 +228540,8 @@ exports.resetInteractiveServer = resetInteractiveServer;
228516
228540
  exports.getInteractiveServerSafe = getInteractiveServerSafe;
228517
228541
  const express_1 = __importDefault(__webpack_require__(26083));
228518
228542
  const http_1 = __importDefault(__webpack_require__(81630));
228519
- const ws_1 = __webpack_require__(17699);
228520
228543
  const open_1 = __importDefault(__webpack_require__(45368));
228544
+ const ws_1 = __webpack_require__(17699);
228521
228545
  const logger_js_1 = __webpack_require__(13039);
228522
228546
  // 动态导入 open 模块,兼容 ESM/CJS 环境
228523
228547
  async function openUrl(url, options, server) {
@@ -229400,8 +229424,8 @@ class InteractiveServer {
229400
229424
  </div>
229401
229425
 
229402
229426
  <div class="content">
229403
- <h1 class="content-title">选择云开发环境</h1>
229404
- <p class="content-subtitle">请选择您要使用的云开发环境</p>
229427
+ <h1 class="content-title">选择 CloudBase 环境</h1>
229428
+ <p class="content-subtitle">请选择您要使用的 CloudBase 环境</p>
229405
229429
 
229406
229430
  <div class="env-list" id="envList">
229407
229431
  ${(envs || []).length > 0 ?
@@ -229418,8 +229442,8 @@ class InteractiveServer {
229418
229442
  `).join('') :
229419
229443
  `
229420
229444
  <div class="empty-state">
229421
- <h3 class="empty-title">暂无云开发环境</h3>
229422
- <p class="empty-message">当前没有可用的云开发 CloudBase 环境,请新建后重新在 AI 对话中重试</p>
229445
+ <h3 class="empty-title">暂无 CloudBase 环境</h3>
229446
+ <p class="empty-message">当前没有可用的 CloudBase 环境,请新建后重新在 AI 对话中重试</p>
229423
229447
  <button class="btn btn-primary create-env-btn" onclick="createNewEnv()">
229424
229448
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
229425
229449
  <path d="M12 5v14M5 12h14"/>
@@ -229457,7 +229481,7 @@ class InteractiveServer {
229457
229481
  </svg>
229458
229482
  </div>
229459
229483
  <h2 class="success-title">环境配置成功!</h2>
229460
- <p class="success-message">已成功选择云开发环境</p>
229484
+ <p class="success-message">已成功选择 CloudBase 环境</p>
229461
229485
  <div class="selected-env-info">
229462
229486
  <span class="env-label">环境 ID:</span>
229463
229487
  <span class="env-value" id="selectedEnvDisplay"></span>
package/dist/index.cjs CHANGED
@@ -1246,9 +1246,6 @@ function registerEnvTools(server) {
1246
1246
  if (error) {
1247
1247
  return { content: [{ type: "text", text: error }] };
1248
1248
  }
1249
- if (noEnvs) {
1250
- return { content: [{ type: "text", text: "当前账户下暂无可用的云开发环境,请先在腾讯云控制台创建环境 https://tcb.cloud.tencent.com/dev?from=AIToolkit" }] };
1251
- }
1252
1249
  if (cancelled) {
1253
1250
  return { content: [{ type: "text", text: "用户取消了登录" }] };
1254
1251
  }
@@ -1326,12 +1323,12 @@ function registerEnvTools(server) {
1326
1323
  switch (action) {
1327
1324
  case "list":
1328
1325
  try {
1329
- const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId: false });
1326
+ const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId: true });
1330
1327
  result = await cloudbaseList.env.listEnvs();
1331
1328
  }
1332
1329
  catch (error) {
1333
1330
  (0, logger_js_1.debug)('获取环境列表时出错:', error);
1334
- return { content: [{ type: "text", text: "当前账户下暂无可用的云开发环境,请先在腾讯云控制台创建环境 https://tcb.cloud.tencent.com/dev?from=AIToolkit \n错误信息:" + (error instanceof Error ? error.message : String(error)) }]
1331
+ return { content: [{ type: "text", text: "获取环境列表时出错: " + (error instanceof Error ? error.message : String(error)) }]
1335
1332
  };
1336
1333
  }
1337
1334
  break;
@@ -22465,11 +22462,11 @@ exports.getEnvId = getEnvId;
22465
22462
  exports.resetCloudBaseManagerCache = resetCloudBaseManagerCache;
22466
22463
  exports.getCloudBaseManager = getCloudBaseManager;
22467
22464
  exports.createCloudBaseManagerWithOptions = createCloudBaseManagerWithOptions;
22465
+ const manager_node_1 = __importDefault(__webpack_require__(95492));
22468
22466
  const auth_js_1 = __webpack_require__(77291);
22469
22467
  const interactive_js_1 = __webpack_require__(3461);
22470
- const manager_node_1 = __importDefault(__webpack_require__(95492));
22471
22468
  const logger_js_1 = __webpack_require__(13039);
22472
- const ENV_ID_TIMEOUT = 600000; // 600 seconds
22469
+ const ENV_ID_TIMEOUT = 60000000; // 60000 seconds
22473
22470
  // 统一的环境ID管理类
22474
22471
  class EnvironmentManager {
22475
22472
  cachedEnvId = null;
@@ -22638,14 +22635,14 @@ exports.saveEnvIdToUserConfig = saveEnvIdToUserConfig;
22638
22635
  exports.loadEnvIdFromUserConfig = loadEnvIdFromUserConfig;
22639
22636
  exports.clearUserEnvId = clearUserEnvId;
22640
22637
  exports.autoSetupEnvironmentId = autoSetupEnvironmentId;
22638
+ const promises_1 = __importDefault(__webpack_require__(79748));
22639
+ const os_1 = __importDefault(__webpack_require__(21820));
22640
+ const path_1 = __importDefault(__webpack_require__(39902));
22641
22641
  const zod_1 = __webpack_require__(21614);
22642
- const interactive_server_js_1 = __webpack_require__(92341);
22643
- const cloudbase_manager_js_1 = __webpack_require__(3431);
22644
22642
  const auth_js_1 = __webpack_require__(77291);
22643
+ const cloudbase_manager_js_1 = __webpack_require__(3431);
22644
+ const interactive_server_js_1 = __webpack_require__(92341);
22645
22645
  const logger_js_1 = __webpack_require__(13039);
22646
- const promises_1 = __importDefault(__webpack_require__(79748));
22647
- const path_1 = __importDefault(__webpack_require__(39902));
22648
- const os_1 = __importDefault(__webpack_require__(21820));
22649
22646
  function registerInteractiveTools(server) {
22650
22647
  // 统一的交互式对话工具 (cloud-incompatible)
22651
22648
  server.registerTool("interactiveDialog", {
@@ -101416,11 +101413,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
101416
101413
  Object.defineProperty(exports, "__esModule", ({ value: true }));
101417
101414
  exports.CLOUDRUN_ACCESS_TYPES = exports.CLOUDRUN_SERVICE_TYPES = void 0;
101418
101415
  exports.registerCloudRunTools = registerCloudRunTools;
101416
+ const child_process_1 = __webpack_require__(79646);
101417
+ const fs_1 = __importDefault(__webpack_require__(29021));
101418
+ const path_1 = __importDefault(__webpack_require__(39902));
101419
101419
  const zod_1 = __webpack_require__(21614);
101420
101420
  const cloudbase_manager_js_1 = __webpack_require__(3431);
101421
- const path_1 = __importDefault(__webpack_require__(39902));
101422
- const fs_1 = __importDefault(__webpack_require__(29021));
101423
- const child_process_1 = __webpack_require__(79646);
101424
101421
  // CloudRun service types
101425
101422
  exports.CLOUDRUN_SERVICE_TYPES = ['function', 'container'];
101426
101423
  // CloudRun access types
@@ -101432,7 +101429,7 @@ const queryCloudRunInputSchema = {
101432
101429
  pageSize: zod_1.z.number().min(1).max(100).optional().default(10).describe('分页大小,控制每页返回的服务数量。取值范围:1-100,默认值:10。建议根据网络性能和显示需求调整'),
101433
101430
  pageNum: zod_1.z.number().min(1).optional().default(1).describe('页码,用于分页查询。从1开始,默认值:1。配合pageSize使用可实现分页浏览'),
101434
101431
  serverName: zod_1.z.string().optional().describe('服务名称筛选条件,支持模糊匹配。例如:输入"test"可匹配"test-service"、"my-test-app"等服务名称。留空则查询所有服务'),
101435
- serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function=函数型云托管(简化开发模式,支持WebSocket/SSE/文件上传等特性,适合快速开发),container=容器型服务(传统容器部署模式,支持任意语言和框架,适合复杂应用)'),
101432
+ serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)'),
101436
101433
  // Detail operation parameters
101437
101434
  detailServerName: zod_1.z.string().optional().describe('要查询详细信息的服务名称。当action为detail时必需提供,必须是已存在的服务名称。可通过list操作获取可用的服务名称列表'),
101438
101435
  };
@@ -101446,7 +101443,7 @@ const ManageCloudRunInputSchema = {
101446
101443
  OpenAccessTypes: zod_1.z.array(zod_1.z.enum(exports.CLOUDRUN_ACCESS_TYPES)).optional().describe('公网访问类型配置,控制服务的访问权限:WEB=公网访问(默认,可通过HTTPS域名访问),VPC=私有网络访问(仅同VPC内可访问),PRIVATE=内网访问(仅云开发环境内可访问)。可配置多个类型'),
101447
101444
  Cpu: zod_1.z.number().positive().optional().describe('CPU规格配置,单位为核。可选值:0.25、0.5、1、2、4、8等。注意:内存规格必须是CPU规格的2倍(如CPU=0.25时内存=0.5,CPU=1时内存=2)。影响服务性能和计费'),
101448
101445
  Mem: zod_1.z.number().positive().optional().describe('内存规格配置,单位为GB。可选值:0.5、1、2、4、8、16等。注意:必须是CPU规格的2倍。影响服务性能和计费'),
101449
- MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0时始终保持指定数量的实例运行(确保快速响应但会增加成本)'),
101446
+ MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0时始终保持指定数量的实例运行(确保快速响应但会增加成本)。建议设置为1以降低冷启动延迟,提升用户体验'),
101450
101447
  MaxNum: zod_1.z.number().min(1).optional().describe('最大实例数配置,控制服务的最大运行实例数量。当请求量增加时,服务最多可以扩展到指定数量的实例,超过此数量后将拒绝新的请求。建议根据业务峰值设置'),
101451
101448
  Port: zod_1.z.number().min(1).max(65535).optional().describe('服务监听端口配置。函数型服务固定为3000,容器型服务可自定义。服务代码必须监听此端口才能正常接收请求'),
101452
101449
  EnvParams: zod_1.z.record(zod_1.z.string()).optional().describe('环境变量配置,用于传递配置信息给服务代码。格式为键值对,如{"DATABASE_URL":"mysql://..."}。敏感信息建议使用环境变量而非硬编码'),
@@ -101474,6 +101471,7 @@ const ManageCloudRunInputSchema = {
101474
101471
  }).optional().describe('Agent配置项,仅在createAgent操作时使用'),
101475
101472
  // Common parameters
101476
101473
  force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,用于跳过确认提示。默认false(需要确认),设置为true时跳过所有确认步骤。删除操作时强烈建议设置为true以避免误操作'),
101474
+ serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型配置:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)。不提供时自动检测:1)现有服务类型 2)有Dockerfile→container 3)有@cloudbase/aiagent-framework依赖→function 4)其他情况→container'),
101477
101475
  };
101478
101476
  /**
101479
101477
  * Check if a project is an Agent project
@@ -101848,21 +101846,47 @@ for await (let x of res.textStream) {
101848
101846
  if (!targetPath) {
101849
101847
  throw new Error("targetPath is required for deploy operation");
101850
101848
  }
101851
- // Determine service type automatically
101849
+ // Determine service type - use input.serverType if provided, otherwise auto-detect
101852
101850
  let serverType;
101853
- try {
101854
- // First try to get existing service details
101855
- const details = await cloudrunService.detail({ serverName: input.serverName });
101856
- serverType = details.BaseInfo?.ServerType || 'function';
101851
+ if (input.serverType) {
101852
+ serverType = input.serverType;
101857
101853
  }
101858
- catch (e) {
101859
- // If service doesn't exist, determine by project structure
101860
- const dockerfilePath = path_1.default.join(targetPath, 'Dockerfile');
101861
- if (fs_1.default.existsSync(dockerfilePath)) {
101862
- serverType = 'container';
101854
+ else {
101855
+ try {
101856
+ // First try to get existing service details
101857
+ const details = await cloudrunService.detail({ serverName: input.serverName });
101858
+ serverType = details.BaseInfo?.ServerType || 'container';
101863
101859
  }
101864
- else {
101865
- serverType = 'function';
101860
+ catch (e) {
101861
+ // If service doesn't exist, determine by project structure
101862
+ const dockerfilePath = path_1.default.join(targetPath, 'Dockerfile');
101863
+ if (fs_1.default.existsSync(dockerfilePath)) {
101864
+ serverType = 'container';
101865
+ }
101866
+ else {
101867
+ // Check if it's a Node.js function project (has package.json with specific structure)
101868
+ const packageJsonPath = path_1.default.join(targetPath, 'package.json');
101869
+ if (fs_1.default.existsSync(packageJsonPath)) {
101870
+ try {
101871
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
101872
+ // If it has function-specific dependencies or scripts, treat as function
101873
+ if (packageJson.dependencies?.['@cloudbase/aiagent-framework'] ||
101874
+ packageJson.scripts?.['dev']?.includes('cloudrun run')) {
101875
+ serverType = 'function';
101876
+ }
101877
+ else {
101878
+ serverType = 'container';
101879
+ }
101880
+ }
101881
+ catch (parseError) {
101882
+ serverType = 'container';
101883
+ }
101884
+ }
101885
+ else {
101886
+ // No package.json, default to container
101887
+ serverType = 'container';
101888
+ }
101889
+ }
101866
101890
  }
101867
101891
  }
101868
101892
  const deployParams = {
@@ -121943,7 +121967,7 @@ class TelemetryReporter {
121943
121967
  const nodeVersion = process.version; // Node.js版本
121944
121968
  const arch = os_1.default.arch(); // 系统架构
121945
121969
  // 从构建时注入的版本号获取MCP版本信息
121946
- const mcpVersion = process.env.npm_package_version || "1.8.42" || 0;
121970
+ const mcpVersion = process.env.npm_package_version || "1.8.43" || 0;
121947
121971
  return {
121948
121972
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
121949
121973
  deviceId: this.deviceId,
@@ -179829,7 +179853,7 @@ ${envIdSection}
179829
179853
  ## 环境信息
179830
179854
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
179831
179855
  - Node.js版本: ${process.version}
179832
- - MCP 版本:${process.env.npm_package_version || "1.8.42" || 0}
179856
+ - MCP 版本:${process.env.npm_package_version || "1.8.43" || 0}
179833
179857
  - 系统架构: ${os_1.default.arch()}
179834
179858
  - 时间: ${new Date().toISOString()}
179835
179859
  - 请求ID: ${requestId}
@@ -194855,7 +194879,7 @@ function registerSetupTools(server) {
194855
194879
  // downloadTemplate - 下载项目模板 (cloud-incompatible)
194856
194880
  server.registerTool("downloadTemplate", {
194857
194881
  title: "下载项目模板",
194858
- description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.42" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
194882
+ description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.43" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
194859
194883
  inputSchema: {
194860
194884
  template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
194861
194885
  ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
@@ -196064,9 +196088,9 @@ async function getLoginState() {
196064
196088
  }
196065
196089
  const loginState = await auth.getLoginState();
196066
196090
  if (!loginState) {
196067
- (0, logger_js_1.debug)('loginByApiSecret');
196068
196091
  await auth.loginByWebAuth({});
196069
196092
  const loginState = await auth.getLoginState();
196093
+ (0, logger_js_1.debug)('loginByWebAuth', loginState);
196070
196094
  return loginState;
196071
196095
  }
196072
196096
  else {
@@ -228412,8 +228436,8 @@ exports.resetInteractiveServer = resetInteractiveServer;
228412
228436
  exports.getInteractiveServerSafe = getInteractiveServerSafe;
228413
228437
  const express_1 = __importDefault(__webpack_require__(26083));
228414
228438
  const http_1 = __importDefault(__webpack_require__(81630));
228415
- const ws_1 = __webpack_require__(17699);
228416
228439
  const open_1 = __importDefault(__webpack_require__(45368));
228440
+ const ws_1 = __webpack_require__(17699);
228417
228441
  const logger_js_1 = __webpack_require__(13039);
228418
228442
  // 动态导入 open 模块,兼容 ESM/CJS 环境
228419
228443
  async function openUrl(url, options, server) {
@@ -229296,8 +229320,8 @@ class InteractiveServer {
229296
229320
  </div>
229297
229321
 
229298
229322
  <div class="content">
229299
- <h1 class="content-title">选择云开发环境</h1>
229300
- <p class="content-subtitle">请选择您要使用的云开发环境</p>
229323
+ <h1 class="content-title">选择 CloudBase 环境</h1>
229324
+ <p class="content-subtitle">请选择您要使用的 CloudBase 环境</p>
229301
229325
 
229302
229326
  <div class="env-list" id="envList">
229303
229327
  ${(envs || []).length > 0 ?
@@ -229314,8 +229338,8 @@ class InteractiveServer {
229314
229338
  `).join('') :
229315
229339
  `
229316
229340
  <div class="empty-state">
229317
- <h3 class="empty-title">暂无云开发环境</h3>
229318
- <p class="empty-message">当前没有可用的云开发 CloudBase 环境,请新建后重新在 AI 对话中重试</p>
229341
+ <h3 class="empty-title">暂无 CloudBase 环境</h3>
229342
+ <p class="empty-message">当前没有可用的 CloudBase 环境,请新建后重新在 AI 对话中重试</p>
229319
229343
  <button class="btn btn-primary create-env-btn" onclick="createNewEnv()">
229320
229344
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
229321
229345
  <path d="M12 5v14M5 12h14"/>
@@ -229353,7 +229377,7 @@ class InteractiveServer {
229353
229377
  </svg>
229354
229378
  </div>
229355
229379
  <h2 class="success-title">环境配置成功!</h2>
229356
- <p class="success-message">已成功选择云开发环境</p>
229380
+ <p class="success-message">已成功选择 CloudBase 环境</p>
229357
229381
  <div class="selected-env-info">
229358
229382
  <span class="env-label">环境 ID:</span>
229359
229383
  <span class="env-value" id="selectedEnvDisplay"></span>
package/dist/index.js CHANGED
@@ -31,11 +31,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
31
31
  Object.defineProperty(exports, "__esModule", ({ value: true }));
32
32
  exports.CLOUDRUN_ACCESS_TYPES = exports.CLOUDRUN_SERVICE_TYPES = void 0;
33
33
  exports.registerCloudRunTools = registerCloudRunTools;
34
+ const child_process_1 = __webpack_require__(814);
35
+ const fs_1 = __importDefault(__webpack_require__(421));
36
+ const path_1 = __importDefault(__webpack_require__(521));
34
37
  const zod_1 = __webpack_require__(971);
35
38
  const cloudbase_manager_js_1 = __webpack_require__(431);
36
- const path_1 = __importDefault(__webpack_require__(521));
37
- const fs_1 = __importDefault(__webpack_require__(421));
38
- const child_process_1 = __webpack_require__(814);
39
39
  // CloudRun service types
40
40
  exports.CLOUDRUN_SERVICE_TYPES = ['function', 'container'];
41
41
  // CloudRun access types
@@ -47,7 +47,7 @@ const queryCloudRunInputSchema = {
47
47
  pageSize: zod_1.z.number().min(1).max(100).optional().default(10).describe('分页大小,控制每页返回的服务数量。取值范围:1-100,默认值:10。建议根据网络性能和显示需求调整'),
48
48
  pageNum: zod_1.z.number().min(1).optional().default(1).describe('页码,用于分页查询。从1开始,默认值:1。配合pageSize使用可实现分页浏览'),
49
49
  serverName: zod_1.z.string().optional().describe('服务名称筛选条件,支持模糊匹配。例如:输入"test"可匹配"test-service"、"my-test-app"等服务名称。留空则查询所有服务'),
50
- serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function=函数型云托管(简化开发模式,支持WebSocket/SSE/文件上传等特性,适合快速开发),container=容器型服务(传统容器部署模式,支持任意语言和框架,适合复杂应用)'),
50
+ serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)'),
51
51
  // Detail operation parameters
52
52
  detailServerName: zod_1.z.string().optional().describe('要查询详细信息的服务名称。当action为detail时必需提供,必须是已存在的服务名称。可通过list操作获取可用的服务名称列表'),
53
53
  };
@@ -61,7 +61,7 @@ const ManageCloudRunInputSchema = {
61
61
  OpenAccessTypes: zod_1.z.array(zod_1.z.enum(exports.CLOUDRUN_ACCESS_TYPES)).optional().describe('公网访问类型配置,控制服务的访问权限:WEB=公网访问(默认,可通过HTTPS域名访问),VPC=私有网络访问(仅同VPC内可访问),PRIVATE=内网访问(仅云开发环境内可访问)。可配置多个类型'),
62
62
  Cpu: zod_1.z.number().positive().optional().describe('CPU规格配置,单位为核。可选值:0.25、0.5、1、2、4、8等。注意:内存规格必须是CPU规格的2倍(如CPU=0.25时内存=0.5,CPU=1时内存=2)。影响服务性能和计费'),
63
63
  Mem: zod_1.z.number().positive().optional().describe('内存规格配置,单位为GB。可选值:0.5、1、2、4、8、16等。注意:必须是CPU规格的2倍。影响服务性能和计费'),
64
- MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0时始终保持指定数量的实例运行(确保快速响应但会增加成本)'),
64
+ MinNum: zod_1.z.number().min(0).optional().describe('最小实例数配置,控制服务的最小运行实例数量。设置为0时支持缩容到0(无请求时不产生费用),设置为大于0时始终保持指定数量的实例运行(确保快速响应但会增加成本)。建议设置为1以降低冷启动延迟,提升用户体验'),
65
65
  MaxNum: zod_1.z.number().min(1).optional().describe('最大实例数配置,控制服务的最大运行实例数量。当请求量增加时,服务最多可以扩展到指定数量的实例,超过此数量后将拒绝新的请求。建议根据业务峰值设置'),
66
66
  Port: zod_1.z.number().min(1).max(65535).optional().describe('服务监听端口配置。函数型服务固定为3000,容器型服务可自定义。服务代码必须监听此端口才能正常接收请求'),
67
67
  EnvParams: zod_1.z.record(zod_1.z.string()).optional().describe('环境变量配置,用于传递配置信息给服务代码。格式为键值对,如{"DATABASE_URL":"mysql://..."}。敏感信息建议使用环境变量而非硬编码'),
@@ -89,6 +89,7 @@ const ManageCloudRunInputSchema = {
89
89
  }).optional().describe('Agent配置项,仅在createAgent操作时使用'),
90
90
  // Common parameters
91
91
  force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,用于跳过确认提示。默认false(需要确认),设置为true时跳过所有确认步骤。删除操作时强烈建议设置为true以避免误操作'),
92
+ serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型配置:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)。不提供时自动检测:1)现有服务类型 2)有Dockerfile→container 3)有@cloudbase/aiagent-framework依赖→function 4)其他情况→container'),
92
93
  };
93
94
  /**
94
95
  * Check if a project is an Agent project
@@ -463,21 +464,47 @@ for await (let x of res.textStream) {
463
464
  if (!targetPath) {
464
465
  throw new Error("targetPath is required for deploy operation");
465
466
  }
466
- // Determine service type automatically
467
+ // Determine service type - use input.serverType if provided, otherwise auto-detect
467
468
  let serverType;
468
- try {
469
- // First try to get existing service details
470
- const details = await cloudrunService.detail({ serverName: input.serverName });
471
- serverType = details.BaseInfo?.ServerType || 'function';
469
+ if (input.serverType) {
470
+ serverType = input.serverType;
472
471
  }
473
- catch (e) {
474
- // If service doesn't exist, determine by project structure
475
- const dockerfilePath = path_1.default.join(targetPath, 'Dockerfile');
476
- if (fs_1.default.existsSync(dockerfilePath)) {
477
- serverType = 'container';
472
+ else {
473
+ try {
474
+ // First try to get existing service details
475
+ const details = await cloudrunService.detail({ serverName: input.serverName });
476
+ serverType = details.BaseInfo?.ServerType || 'container';
478
477
  }
479
- else {
480
- serverType = 'function';
478
+ catch (e) {
479
+ // If service doesn't exist, determine by project structure
480
+ const dockerfilePath = path_1.default.join(targetPath, 'Dockerfile');
481
+ if (fs_1.default.existsSync(dockerfilePath)) {
482
+ serverType = 'container';
483
+ }
484
+ else {
485
+ // Check if it's a Node.js function project (has package.json with specific structure)
486
+ const packageJsonPath = path_1.default.join(targetPath, 'package.json');
487
+ if (fs_1.default.existsSync(packageJsonPath)) {
488
+ try {
489
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
490
+ // If it has function-specific dependencies or scripts, treat as function
491
+ if (packageJson.dependencies?.['@cloudbase/aiagent-framework'] ||
492
+ packageJson.scripts?.['dev']?.includes('cloudrun run')) {
493
+ serverType = 'function';
494
+ }
495
+ else {
496
+ serverType = 'container';
497
+ }
498
+ }
499
+ catch (parseError) {
500
+ serverType = 'container';
501
+ }
502
+ }
503
+ else {
504
+ // No package.json, default to container
505
+ serverType = 'container';
506
+ }
507
+ }
481
508
  }
482
509
  }
483
510
  const deployParams = {
@@ -2056,9 +2083,9 @@ async function getLoginState() {
2056
2083
  }
2057
2084
  const loginState = await auth.getLoginState();
2058
2085
  if (!loginState) {
2059
- (0, logger_js_1.debug)('loginByApiSecret');
2060
2086
  await auth.loginByWebAuth({});
2061
2087
  const loginState = await auth.getLoginState();
2088
+ (0, logger_js_1.debug)('loginByWebAuth', loginState);
2062
2089
  return loginState;
2063
2090
  }
2064
2091
  else {
@@ -2135,8 +2162,8 @@ exports.resetInteractiveServer = resetInteractiveServer;
2135
2162
  exports.getInteractiveServerSafe = getInteractiveServerSafe;
2136
2163
  const express_1 = __importDefault(__webpack_require__(674));
2137
2164
  const http_1 = __importDefault(__webpack_require__(782));
2138
- const ws_1 = __webpack_require__(220);
2139
2165
  const open_1 = __importDefault(__webpack_require__(241));
2166
+ const ws_1 = __webpack_require__(220);
2140
2167
  const logger_js_1 = __webpack_require__(39);
2141
2168
  // 动态导入 open 模块,兼容 ESM/CJS 环境
2142
2169
  async function openUrl(url, options, server) {
@@ -3019,8 +3046,8 @@ class InteractiveServer {
3019
3046
  </div>
3020
3047
 
3021
3048
  <div class="content">
3022
- <h1 class="content-title">选择云开发环境</h1>
3023
- <p class="content-subtitle">请选择您要使用的云开发环境</p>
3049
+ <h1 class="content-title">选择 CloudBase 环境</h1>
3050
+ <p class="content-subtitle">请选择您要使用的 CloudBase 环境</p>
3024
3051
 
3025
3052
  <div class="env-list" id="envList">
3026
3053
  ${(envs || []).length > 0 ?
@@ -3037,8 +3064,8 @@ class InteractiveServer {
3037
3064
  `).join('') :
3038
3065
  `
3039
3066
  <div class="empty-state">
3040
- <h3 class="empty-title">暂无云开发环境</h3>
3041
- <p class="empty-message">当前没有可用的云开发 CloudBase 环境,请新建后重新在 AI 对话中重试</p>
3067
+ <h3 class="empty-title">暂无 CloudBase 环境</h3>
3068
+ <p class="empty-message">当前没有可用的 CloudBase 环境,请新建后重新在 AI 对话中重试</p>
3042
3069
  <button class="btn btn-primary create-env-btn" onclick="createNewEnv()">
3043
3070
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
3044
3071
  <path d="M12 5v14M5 12h14"/>
@@ -3076,7 +3103,7 @@ class InteractiveServer {
3076
3103
  </svg>
3077
3104
  </div>
3078
3105
  <h2 class="success-title">环境配置成功!</h2>
3079
- <p class="success-message">已成功选择云开发环境</p>
3106
+ <p class="success-message">已成功选择 CloudBase 环境</p>
3080
3107
  <div class="selected-env-info">
3081
3108
  <span class="env-label">环境 ID:</span>
3082
3109
  <span class="env-value" id="selectedEnvDisplay"></span>
@@ -5008,7 +5035,7 @@ ${envIdSection}
5008
5035
  ## 环境信息
5009
5036
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
5010
5037
  - Node.js版本: ${process.version}
5011
- - MCP 版本:${process.env.npm_package_version || "1.8.42" || 0}
5038
+ - MCP 版本:${process.env.npm_package_version || "1.8.43" || 0}
5012
5039
  - 系统架构: ${os_1.default.arch()}
5013
5040
  - 时间: ${new Date().toISOString()}
5014
5041
  - 请求ID: ${requestId}
@@ -5321,11 +5348,11 @@ exports.getEnvId = getEnvId;
5321
5348
  exports.resetCloudBaseManagerCache = resetCloudBaseManagerCache;
5322
5349
  exports.getCloudBaseManager = getCloudBaseManager;
5323
5350
  exports.createCloudBaseManagerWithOptions = createCloudBaseManagerWithOptions;
5351
+ const manager_node_1 = __importDefault(__webpack_require__(665));
5324
5352
  const auth_js_1 = __webpack_require__(291);
5325
5353
  const interactive_js_1 = __webpack_require__(461);
5326
- const manager_node_1 = __importDefault(__webpack_require__(665));
5327
5354
  const logger_js_1 = __webpack_require__(39);
5328
- const ENV_ID_TIMEOUT = 600000; // 600 seconds
5355
+ const ENV_ID_TIMEOUT = 60000000; // 60000 seconds
5329
5356
  // 统一的环境ID管理类
5330
5357
  class EnvironmentManager {
5331
5358
  cachedEnvId = null;
@@ -5500,14 +5527,14 @@ exports.saveEnvIdToUserConfig = saveEnvIdToUserConfig;
5500
5527
  exports.loadEnvIdFromUserConfig = loadEnvIdFromUserConfig;
5501
5528
  exports.clearUserEnvId = clearUserEnvId;
5502
5529
  exports.autoSetupEnvironmentId = autoSetupEnvironmentId;
5530
+ const promises_1 = __importDefault(__webpack_require__(932));
5531
+ const os_1 = __importDefault(__webpack_require__(116));
5532
+ const path_1 = __importDefault(__webpack_require__(521));
5503
5533
  const zod_1 = __webpack_require__(971);
5504
- const interactive_server_js_1 = __webpack_require__(341);
5505
- const cloudbase_manager_js_1 = __webpack_require__(431);
5506
5534
  const auth_js_1 = __webpack_require__(291);
5535
+ const cloudbase_manager_js_1 = __webpack_require__(431);
5536
+ const interactive_server_js_1 = __webpack_require__(341);
5507
5537
  const logger_js_1 = __webpack_require__(39);
5508
- const promises_1 = __importDefault(__webpack_require__(932));
5509
- const path_1 = __importDefault(__webpack_require__(521));
5510
- const os_1 = __importDefault(__webpack_require__(116));
5511
5538
  function registerInteractiveTools(server) {
5512
5539
  // 统一的交互式对话工具 (cloud-incompatible)
5513
5540
  server.registerTool("interactiveDialog", {
@@ -6051,7 +6078,7 @@ function registerSetupTools(server) {
6051
6078
  // downloadTemplate - 下载项目模板 (cloud-incompatible)
6052
6079
  server.registerTool("downloadTemplate", {
6053
6080
  title: "下载项目模板",
6054
- description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.42" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
6081
+ description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.43" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
6055
6082
  inputSchema: {
6056
6083
  template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
6057
6084
  ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
@@ -6243,9 +6270,6 @@ function registerEnvTools(server) {
6243
6270
  if (error) {
6244
6271
  return { content: [{ type: "text", text: error }] };
6245
6272
  }
6246
- if (noEnvs) {
6247
- return { content: [{ type: "text", text: "当前账户下暂无可用的云开发环境,请先在腾讯云控制台创建环境 https://tcb.cloud.tencent.com/dev?from=AIToolkit" }] };
6248
- }
6249
6273
  if (cancelled) {
6250
6274
  return { content: [{ type: "text", text: "用户取消了登录" }] };
6251
6275
  }
@@ -6323,12 +6347,12 @@ function registerEnvTools(server) {
6323
6347
  switch (action) {
6324
6348
  case "list":
6325
6349
  try {
6326
- const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId: false });
6350
+ const cloudbaseList = await (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions, requireEnvId: true });
6327
6351
  result = await cloudbaseList.env.listEnvs();
6328
6352
  }
6329
6353
  catch (error) {
6330
6354
  (0, logger_js_1.debug)('获取环境列表时出错:', error);
6331
- return { content: [{ type: "text", text: "当前账户下暂无可用的云开发环境,请先在腾讯云控制台创建环境 https://tcb.cloud.tencent.com/dev?from=AIToolkit \n错误信息:" + (error instanceof Error ? error.message : String(error)) }]
6355
+ return { content: [{ type: "text", text: "获取环境列表时出错: " + (error instanceof Error ? error.message : String(error)) }]
6332
6356
  };
6333
6357
  }
6334
6358
  break;
@@ -8907,7 +8931,7 @@ class TelemetryReporter {
8907
8931
  const nodeVersion = process.version; // Node.js版本
8908
8932
  const arch = os_1.default.arch(); // 系统架构
8909
8933
  // 从构建时注入的版本号获取MCP版本信息
8910
- const mcpVersion = process.env.npm_package_version || "1.8.42" || 0;
8934
+ const mcpVersion = process.env.npm_package_version || "1.8.43" || 0;
8911
8935
  return {
8912
8936
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
8913
8937
  deviceId: this.deviceId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cloudbase-mcp",
3
- "version": "1.8.42",
3
+ "version": "1.8.43",
4
4
  "description": "腾讯云开发 MCP Server,通过AI提示词和MCP协议+云开发,让开发更智能、更高效,当你在Cursor/ VSCode GitHub Copilot/WinSurf/CodeBuddy/Augment Code/Claude Code等AI编程工具里写代码时,它能自动帮你生成可直接部署的前后端应用+小程序,并一键发布到腾讯云开发 CloudBase。",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",