@cloudbase/cloudbase-mcp 2.10.0 → 2.11.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.10.0" || 0}
565
+ - MCP 版本:${process.env.npm_package_version || "2.11.0" || 0}
566
566
  - 系统架构: ${os_1.default.arch()}
567
567
  - 时间: ${new Date().toISOString()}
568
568
  - 请求ID: ${requestId}
@@ -971,11 +971,43 @@ exports.resetInteractiveServer = resetInteractiveServer;
971
971
  exports.getInteractiveServerSafe = getInteractiveServerSafe;
972
972
  const express_1 = __importDefault(__webpack_require__(2674));
973
973
  const http_1 = __importDefault(__webpack_require__(3782));
974
+ const child_process_1 = __webpack_require__(5814);
974
975
  const open_1 = __importDefault(__webpack_require__(1622));
975
976
  const ws_1 = __webpack_require__(6220);
976
977
  const index_js_1 = __webpack_require__(9529);
977
978
  const logger_js_1 = __webpack_require__(3039);
978
- // 动态导入 open 模块,兼容 ESM/CJS 环境
979
+ function isVSCodeEnvironment() {
980
+ return Boolean(process.env.VSCODE_IPC_HOOK_CLI ||
981
+ process.env.VSCODE_PID ||
982
+ process.env.TERM_PROGRAM === "vscode");
983
+ }
984
+ function parseBrowserCommand(browser) {
985
+ const parts = browser.match(/(?:[^\s"]+|"[^"]*")+/g) || [];
986
+ return parts.map((item) => item.replace(/^"(.*)"$/, "$1"));
987
+ }
988
+ async function openUrlByBrowserEnv(url) {
989
+ const browser = process.env.BROWSER?.trim();
990
+ if (!browser) {
991
+ return false;
992
+ }
993
+ const [command, ...args] = parseBrowserCommand(browser);
994
+ if (!command) {
995
+ return false;
996
+ }
997
+ const finalArgs = args.map((arg) => (arg === "%s" ? url : arg));
998
+ if (!args.includes("%s")) {
999
+ finalArgs.push(url);
1000
+ }
1001
+ return new Promise((resolve) => {
1002
+ (0, child_process_1.execFile)(command, finalArgs, (execError) => {
1003
+ resolve(!execError);
1004
+ });
1005
+ });
1006
+ }
1007
+ function shouldUseBrowserEnvFallback() {
1008
+ return process.platform === "linux" && isVSCodeEnvironment();
1009
+ }
1010
+ // Dynamic open behavior with IDE awareness and VSCode/Linux fallback
979
1011
  async function openUrl(url, options, mcpServer) {
980
1012
  // mcpServer 是 ExtendedMcpServer 实例,它有 server 和 ide 属性
981
1013
  // server 属性是 MCP server 的内部 server 实例,有 sendLoggingMessage 方法
@@ -1007,13 +1039,28 @@ async function openUrl(url, options, mcpServer) {
1007
1039
  return;
1008
1040
  }
1009
1041
  }
1010
- // 默认行为:直接打开网页
1042
+ // 默认行为:直接打开网页(带 VSCode/Linux 降级逻辑)
1011
1043
  (0, logger_js_1.debug)(`[openUrl] Opening URL in browser: ${url}`);
1012
1044
  try {
1013
- return await (0, open_1.default)(url, options);
1045
+ const openOptions = options ? { url: true, ...options } : { url: true };
1046
+ const child = await (0, open_1.default)(url, openOptions);
1047
+ if (child?.once) {
1048
+ child.once("error", async () => {
1049
+ if (shouldUseBrowserEnvFallback()) {
1050
+ (0, logger_js_1.debug)("[openUrl] open() failed, trying BROWSER fallback");
1051
+ await openUrlByBrowserEnv(url);
1052
+ }
1053
+ });
1054
+ }
1055
+ return;
1014
1056
  }
1015
1057
  catch (err) {
1016
1058
  (0, logger_js_1.error)(`Failed to open ${url} ${options} ${err instanceof Error ? err.message : err} `, err instanceof Error ? err : new Error(String(err)));
1059
+ if (shouldUseBrowserEnvFallback()) {
1060
+ (0, logger_js_1.debug)("[openUrl] open() threw, trying BROWSER fallback");
1061
+ await openUrlByBrowserEnv(url);
1062
+ return;
1063
+ }
1017
1064
  (0, logger_js_1.warn)(`Please manually open: ${url}`);
1018
1065
  }
1019
1066
  }
@@ -5267,8 +5314,11 @@ checkIndex: 检查索引是否存在`),
5267
5314
  title: "修改 NoSQL 数据库结构",
5268
5315
  description: "修改 NoSQL 数据库结构",
5269
5316
  inputSchema: {
5270
- action: zod_1.z.enum(["createCollection", "updateCollection", "deleteCollection"])
5271
- .describe(`createCollection: 创建集合
5317
+ action: zod_1.z.enum([
5318
+ "createCollection",
5319
+ "updateCollection",
5320
+ "deleteCollection",
5321
+ ]).describe(`createCollection: 创建集合
5272
5322
  updateCollection: 更新集合
5273
5323
  deleteCollection: 删除集合`),
5274
5324
  collectionName: zod_1.z.string().describe("集合名称"),
@@ -5348,9 +5398,7 @@ deleteCollection: 删除集合`),
5348
5398
  success: true,
5349
5399
  requestId: result.RequestId,
5350
5400
  action,
5351
- message: result.Exists === false
5352
- ? "集合不存在"
5353
- : "云开发数据库集合删除成功",
5401
+ message: result.Exists === false ? "集合不存在" : "云开发数据库集合删除成功",
5354
5402
  };
5355
5403
  if (result.Exists === false) {
5356
5404
  body.exists = false;
@@ -5381,9 +5429,17 @@ deleteCollection: 删除集合`),
5381
5429
  .optional()
5382
5430
  .describe("返回字段投影(对象或字符串,推荐对象)"),
5383
5431
  sort: zod_1.z
5384
- .union([zod_1.z.object({}).passthrough(), zod_1.z.string()])
5432
+ .union([
5433
+ zod_1.z.array(zod_1.z
5434
+ .object({
5435
+ key: zod_1.z.string().describe("sort 字段名"),
5436
+ direction: zod_1.z.number().describe("排序方向,1:升序,-1:降序"),
5437
+ })
5438
+ .passthrough()),
5439
+ zod_1.z.string(),
5440
+ ])
5385
5441
  .optional()
5386
- .describe("排序条件(对象或字符串,推荐对象)"),
5442
+ .describe("排序条件,使用对象或字符串。"),
5387
5443
  limit: zod_1.z.number().optional().describe("返回数量限制"),
5388
5444
  offset: zod_1.z.number().optional().describe("跳过的记录数"),
5389
5445
  },
@@ -5429,7 +5485,8 @@ deleteCollection: 删除集合`),
5429
5485
  title: "修改 NoSQL 数据库数据记录",
5430
5486
  description: "修改 NoSQL 数据库数据记录",
5431
5487
  inputSchema: {
5432
- action: zod_1.z.enum(["insert", "update", "delete"])
5488
+ action: zod_1.z
5489
+ .enum(["insert", "update", "delete"])
5433
5490
  .describe(`insert: 插入数据(新增文档)\nupdate: 更新数据\ndelete: 删除数据`),
5434
5491
  collectionName: zod_1.z.string().describe("集合名称"),
5435
5492
  documents: zod_1.z
@@ -8606,7 +8663,7 @@ class TelemetryReporter {
8606
8663
  const nodeVersion = process.version; // Node.js版本
8607
8664
  const arch = os_1.default.arch(); // 系统架构
8608
8665
  // 从构建时注入的版本号获取MCP版本信息
8609
- const mcpVersion = process.env.npm_package_version || "2.10.0" || 0;
8666
+ const mcpVersion = process.env.npm_package_version || "2.11.0" || 0;
8610
8667
  return {
8611
8668
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
8612
8669
  deviceId: this.deviceId,
@@ -10039,7 +10096,7 @@ function registerSetupTools(server) {
10039
10096
  title: "下载项目模板",
10040
10097
  description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
10041
10098
 
10042
- **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.10.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
10099
+ **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.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
10043
10100
  inputSchema: {
10044
10101
  template: zod_1.z
10045
10102
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cloudbase-mcp",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
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",