@cloudbase/cloudbase-mcp 2.1.0 → 2.2.0-alpha.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.
Files changed (4) hide show
  1. package/dist/cli.cjs +574 -177
  2. package/dist/index.cjs +574 -177
  3. package/dist/index.js +156 -141
  4. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6224,7 +6224,7 @@ ${envIdSection}
6224
6224
  ## 环境信息
6225
6225
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
6226
6226
  - Node.js版本: ${process.version}
6227
- - MCP 版本:${process.env.npm_package_version || "2.1.0" || 0}
6227
+ - MCP 版本:${process.env.npm_package_version || "2.2.0-alpha.0" || 0}
6228
6228
  - 系统架构: ${os_1.default.arch()}
6229
6229
  - 时间: ${new Date().toISOString()}
6230
6230
  - 请求ID: ${requestId}
@@ -6852,7 +6852,7 @@ async function getCloudBaseManager(options = {}) {
6852
6852
  secretKey,
6853
6853
  envId: finalEnvId || loginEnvId,
6854
6854
  token,
6855
- proxy: process.env.http_proxy
6855
+ proxy: process.env.http_proxy,
6856
6856
  });
6857
6857
  return manager;
6858
6858
  }
@@ -6869,13 +6869,8 @@ async function getCloudBaseManager(options = {}) {
6869
6869
  function createCloudBaseManagerWithOptions(cloudBaseOptions) {
6870
6870
  (0, logger_js_1.debug)('使用传入的 CloudBase 配置创建 manager:', cloudBaseOptions);
6871
6871
  const manager = new manager_node_1.default({
6872
- secretId: cloudBaseOptions.secretId,
6873
- secretKey: cloudBaseOptions.secretKey,
6874
- envId: cloudBaseOptions.envId,
6875
- token: cloudBaseOptions.token,
6872
+ ...cloudBaseOptions,
6876
6873
  proxy: cloudBaseOptions.proxy || process.env.http_proxy,
6877
- region: cloudBaseOptions.region,
6878
- envType: cloudBaseOptions.envType
6879
6874
  });
6880
6875
  return manager;
6881
6876
  }
@@ -7130,26 +7125,26 @@ const path = __importStar(__webpack_require__(521));
7130
7125
  const zod_1 = __webpack_require__(971);
7131
7126
  // CloudBase 模板配置
7132
7127
  const TEMPLATES = {
7133
- "react": {
7128
+ react: {
7134
7129
  description: "React + CloudBase 全栈应用模板",
7135
- url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-react-template.zip"
7130
+ url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-react-template.zip",
7136
7131
  },
7137
- "vue": {
7132
+ vue: {
7138
7133
  description: "Vue + CloudBase 全栈应用模板",
7139
- url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-vue-template.zip"
7134
+ url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-vue-template.zip",
7140
7135
  },
7141
- "miniprogram": {
7136
+ miniprogram: {
7142
7137
  description: "微信小程序 + 云开发模板",
7143
- url: "https://static.cloudbase.net/cloudbase-examples/miniprogram-cloudbase-miniprogram-template.zip"
7138
+ url: "https://static.cloudbase.net/cloudbase-examples/miniprogram-cloudbase-miniprogram-template.zip",
7144
7139
  },
7145
- "uniapp": {
7140
+ uniapp: {
7146
7141
  description: "UniApp + CloudBase 跨端应用模板",
7147
- url: "https://static.cloudbase.net/cloudbase-examples/universal-cloudbase-uniapp-template.zip"
7142
+ url: "https://static.cloudbase.net/cloudbase-examples/universal-cloudbase-uniapp-template.zip",
7148
7143
  },
7149
- "rules": {
7144
+ rules: {
7150
7145
  description: "AI编辑器配置模板(包含所有主流编辑器配置)",
7151
- url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-project.zip"
7152
- }
7146
+ url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-project.zip",
7147
+ },
7153
7148
  };
7154
7149
  // IDE类型枚举
7155
7150
  const IDE_TYPES = [
@@ -7169,22 +7164,13 @@ const IDE_TYPES = [
7169
7164
  "roocode", // RooCode AI编辑器
7170
7165
  "tongyi-lingma", // 通义灵码
7171
7166
  "trae", // Trae AI编辑器
7172
- "vscode" // Visual Studio Code
7167
+ "vscode", // Visual Studio Code
7173
7168
  ];
7174
7169
  // IDE到文件的映射关系
7175
7170
  const IDE_FILE_MAPPINGS = {
7176
- "cursor": [
7177
- ".cursor/rules/cloudbase-rules.mdc",
7178
- ".cursor/mcp.json"
7179
- ],
7180
- "windsurf": [
7181
- ".windsurf/rules/cloudbase-rules.md"
7182
- ],
7183
- "codebuddy": [
7184
- ".rules/cloudbase-rules.md",
7185
- "CODEBUDDY.md",
7186
- ".mcp.json"
7187
- ],
7171
+ cursor: [".cursor/rules/cloudbase-rules.mdc", ".cursor/mcp.json"],
7172
+ windsurf: [".windsurf/rules/cloudbase-rules.md"],
7173
+ codebuddy: [".rules/cloudbase-rules.md", "CODEBUDDY.md", ".mcp.json"],
7188
7174
  "claude-code": [
7189
7175
  "CLAUDE.md",
7190
7176
  ".mcp.json",
@@ -7193,49 +7179,22 @@ const IDE_FILE_MAPPINGS = {
7193
7179
  ".claude/commands/spec.md",
7194
7180
  ".claude/commands/no_spec.md",
7195
7181
  ],
7196
- "cline": [
7197
- ".clinerules/cloudbase-rules.mdc"
7198
- ],
7199
- "gemini-cli": [
7200
- ".gemini/GEMINI.md",
7201
- ".gemini/settings.json"
7202
- ],
7203
- "opencode": [
7204
- ".opencode.json"
7205
- ],
7206
- "qwen-code": [
7207
- ".qwen/QWEN.md",
7208
- ".qwen/settings.json"
7209
- ],
7182
+ cline: [".clinerules/cloudbase-rules.mdc"],
7183
+ "gemini-cli": [".gemini/GEMINI.md", ".gemini/settings.json"],
7184
+ opencode: [".opencode.json"],
7185
+ "qwen-code": [".qwen/QWEN.md", ".qwen/settings.json"],
7210
7186
  "baidu-comate": [
7211
7187
  ".comate/rules/cloudbase-rules.mdr",
7212
7188
  ".comate/rules/cloudbaase-rules.mdr",
7213
- ".comate/mcp.json"
7214
- ],
7215
- "openai-codex-cli": [
7216
- ".codex/config.toml",
7217
- "AGENTS.md",
7218
- ],
7219
- "augment-code": [
7220
- ".augment-guidelines"
7221
- ],
7222
- "github-copilot": [
7223
- ".github/copilot-instructions.md"
7189
+ ".comate/mcp.json",
7224
7190
  ],
7225
- "roocode": [
7226
- ".roo/rules/cloudbaase-rules.md",
7227
- ".roo/mcp.json"
7228
- ],
7229
- "tongyi-lingma": [
7230
- ".lingma/rules/cloudbaase-rules.md"
7231
- ],
7232
- "trae": [
7233
- ".trae/rules/cloudbase-rules.md"
7234
- ],
7235
- "vscode": [
7236
- ".vscode/mcp.json",
7237
- ".vscode/settings.json"
7238
- ]
7191
+ "openai-codex-cli": [".codex/config.toml", "AGENTS.md"],
7192
+ "augment-code": [".augment-guidelines"],
7193
+ "github-copilot": [".github/copilot-instructions.md"],
7194
+ roocode: [".roo/rules/cloudbaase-rules.md", ".roo/mcp.json"],
7195
+ "tongyi-lingma": [".lingma/rules/cloudbaase-rules.md"],
7196
+ trae: [".trae/rules/cloudbase-rules.md"],
7197
+ vscode: [".vscode/mcp.json", ".vscode/settings.json"],
7239
7198
  };
7240
7199
  // 所有IDE配置文件的完整列表 - 通过IDE_FILE_MAPPINGS计算得出
7241
7200
  const ALL_IDE_FILES = Array.from(new Set(Object.values(IDE_FILE_MAPPINGS).flat()));
@@ -7243,51 +7202,87 @@ const ALL_IDE_FILES = Array.from(new Set(Object.values(IDE_FILE_MAPPINGS).flat()
7243
7202
  IDE_FILE_MAPPINGS["all"] = ALL_IDE_FILES;
7244
7203
  // IDE描述映射
7245
7204
  const IDE_DESCRIPTIONS = {
7246
- "all": "所有IDE配置",
7247
- "cursor": "Cursor AI编辑器",
7248
- "windsurf": "WindSurf AI编辑器",
7249
- "codebuddy": "CodeBuddy AI编辑器",
7205
+ all: "所有IDE配置",
7206
+ cursor: "Cursor AI编辑器",
7207
+ windsurf: "WindSurf AI编辑器",
7208
+ codebuddy: "CodeBuddy AI编辑器",
7250
7209
  "claude-code": "Claude Code AI编辑器",
7251
- "cline": "Cline AI编辑器",
7210
+ cline: "Cline AI编辑器",
7252
7211
  "gemini-cli": "Gemini CLI",
7253
- "opencode": "OpenCode AI编辑器",
7212
+ opencode: "OpenCode AI编辑器",
7254
7213
  "qwen-code": "通义灵码",
7255
7214
  "baidu-comate": "百度Comate",
7256
7215
  "openai-codex-cli": "OpenAI Codex CLI",
7257
7216
  "augment-code": "Augment Code",
7258
7217
  "github-copilot": "GitHub Copilot",
7259
- "roocode": "RooCode AI编辑器",
7218
+ roocode: "RooCode AI编辑器",
7260
7219
  "tongyi-lingma": "通义灵码",
7261
- "trae": "Trae AI编辑器",
7262
- "vscode": "Visual Studio Code"
7220
+ trae: "Trae AI编辑器",
7221
+ vscode: "Visual Studio Code",
7263
7222
  };
7223
+ // INTEGRATION_IDE 环境变量值到 IDE 类型的映射
7224
+ const INTEGRATION_IDE_MAPPING = {
7225
+ Cursor: "cursor",
7226
+ WindSurf: "windsurf",
7227
+ CodeBuddy: "codebuddy",
7228
+ CodeBuddyManual: "codebuddy",
7229
+ CodeBuddyCode: "codebuddy",
7230
+ "Claude Code": "claude-code",
7231
+ CLINE: "cline",
7232
+ "Gemini CLI": "gemini-cli",
7233
+ OpenCode: "opencode",
7234
+ "Qwen Code": "qwen-code",
7235
+ "Baidu Comate": "baidu-comate",
7236
+ "OpenAI Codex CLI": "openai-codex-cli",
7237
+ "Augment Code": "augment-code",
7238
+ "GitHub Copilot": "github-copilot",
7239
+ RooCode: "roocode",
7240
+ "Tongyi Lingma": "tongyi-lingma",
7241
+ Trae: "trae",
7242
+ VSCode: "vscode",
7243
+ };
7244
+ // 根据 INTEGRATION_IDE 环境变量获取默认 IDE 类型
7245
+ function getDefaultIDEFromEnv() {
7246
+ const integrationIDE = process.env.INTEGRATION_IDE;
7247
+ if (integrationIDE) {
7248
+ const mappedIDE = INTEGRATION_IDE_MAPPING[integrationIDE];
7249
+ if (mappedIDE) {
7250
+ return mappedIDE;
7251
+ }
7252
+ }
7253
+ return "all";
7254
+ }
7264
7255
  // 下载文件到临时目录
7265
7256
  async function downloadFile(url, filePath) {
7266
7257
  return new Promise((resolve, reject) => {
7267
- const client = url.startsWith('https:') ? https : http;
7268
- client.get(url, (res) => {
7258
+ const client = url.startsWith("https:") ? https : http;
7259
+ client
7260
+ .get(url, (res) => {
7269
7261
  if (res.statusCode === 200) {
7270
7262
  const file = fs.createWriteStream(filePath);
7271
7263
  res.pipe(file);
7272
- file.on('finish', () => {
7264
+ file.on("finish", () => {
7273
7265
  file.close();
7274
7266
  resolve();
7275
7267
  });
7276
- file.on('error', reject);
7268
+ file.on("error", reject);
7277
7269
  }
7278
7270
  else if (res.statusCode === 302 || res.statusCode === 301) {
7279
7271
  // 处理重定向
7280
7272
  if (res.headers.location) {
7281
- downloadFile(res.headers.location, filePath).then(resolve).catch(reject);
7273
+ downloadFile(res.headers.location, filePath)
7274
+ .then(resolve)
7275
+ .catch(reject);
7282
7276
  }
7283
7277
  else {
7284
- reject(new Error('重定向但没有location header'));
7278
+ reject(new Error("重定向但没有location header"));
7285
7279
  }
7286
7280
  }
7287
7281
  else {
7288
7282
  reject(new Error(`下载失败,状态码: ${res.statusCode}`));
7289
7283
  }
7290
- }).on('error', reject);
7284
+ })
7285
+ .on("error", reject);
7291
7286
  });
7292
7287
  }
7293
7288
  // 解压ZIP文件
@@ -7300,7 +7295,7 @@ async function extractZip(zipPath, extractPath) {
7300
7295
  zip.extractAllTo(extractPath, true);
7301
7296
  }
7302
7297
  catch (error) {
7303
- throw new Error(`解压失败: ${error instanceof Error ? error.message : '未知错误'}`);
7298
+ throw new Error(`解压失败: ${error instanceof Error ? error.message : "未知错误"}`);
7304
7299
  }
7305
7300
  }
7306
7301
  // 获取目录下所有文件的相对路径列表
@@ -7324,7 +7319,7 @@ async function copyFileIfNotExists(src, dest) {
7324
7319
  try {
7325
7320
  // 检查目标文件是否存在
7326
7321
  if (fs.existsSync(dest)) {
7327
- return { copied: false, reason: '文件已存在' };
7322
+ return { copied: false, reason: "文件已存在" };
7328
7323
  }
7329
7324
  // 创建目标目录
7330
7325
  await fsPromises.mkdir(path.dirname(dest), { recursive: true });
@@ -7333,14 +7328,17 @@ async function copyFileIfNotExists(src, dest) {
7333
7328
  return { copied: true };
7334
7329
  }
7335
7330
  catch (error) {
7336
- return { copied: false, reason: `复制失败: ${error instanceof Error ? error.message : '未知错误'}` };
7331
+ return {
7332
+ copied: false,
7333
+ reason: `复制失败: ${error instanceof Error ? error.message : "未知错误"}`,
7334
+ };
7337
7335
  }
7338
7336
  }
7339
7337
  // 复制文件,支持覆盖模式
7340
7338
  // 判断是否应该跳过 README.md 文件
7341
7339
  function shouldSkipReadme(template, destPath, overwrite) {
7342
- const isReadme = path.basename(destPath).toLowerCase() === 'readme.md';
7343
- const isRulesTemplate = template === 'rules';
7340
+ const isReadme = path.basename(destPath).toLowerCase() === "readme.md";
7341
+ const isRulesTemplate = template === "rules";
7344
7342
  const exists = fs.existsSync(destPath);
7345
7343
  return isReadme && isRulesTemplate && exists && !overwrite;
7346
7344
  }
@@ -7349,11 +7347,15 @@ async function copyFile(src, dest, overwrite = false, template) {
7349
7347
  const destExists = fs.existsSync(dest);
7350
7348
  // 检查是否需要跳过 README.md 文件(仅对 rules 模板)
7351
7349
  if (template && shouldSkipReadme(template, dest, overwrite)) {
7352
- return { copied: false, reason: 'README.md 文件已存在,已保护', action: 'protected' };
7350
+ return {
7351
+ copied: false,
7352
+ reason: "README.md 文件已存在,已保护",
7353
+ action: "protected",
7354
+ };
7353
7355
  }
7354
7356
  // 如果目标文件存在且不允许覆盖
7355
7357
  if (destExists && !overwrite) {
7356
- return { copied: false, reason: '文件已存在', action: 'skipped' };
7358
+ return { copied: false, reason: "文件已存在", action: "skipped" };
7357
7359
  }
7358
7360
  // 创建目标目录
7359
7361
  await fsPromises.mkdir(path.dirname(dest), { recursive: true });
@@ -7361,11 +7363,14 @@ async function copyFile(src, dest, overwrite = false, template) {
7361
7363
  await fsPromises.copyFile(src, dest);
7362
7364
  return {
7363
7365
  copied: true,
7364
- action: destExists ? 'overwritten' : 'created'
7366
+ action: destExists ? "overwritten" : "created",
7365
7367
  };
7366
7368
  }
7367
7369
  catch (error) {
7368
- return { copied: false, reason: `复制失败: ${error instanceof Error ? error.message : '未知错误'}` };
7370
+ return {
7371
+ copied: false,
7372
+ reason: `复制失败: ${error instanceof Error ? error.message : "未知错误"}`,
7373
+ };
7369
7374
  }
7370
7375
  }
7371
7376
  // IDE验证函数
@@ -7373,13 +7378,13 @@ function validateIDE(ide) {
7373
7378
  if (ide === "all") {
7374
7379
  return { valid: true };
7375
7380
  }
7376
- const supportedIDEs = IDE_TYPES.filter(type => type !== "all");
7381
+ const supportedIDEs = IDE_TYPES.filter((type) => type !== "all");
7377
7382
  const isValid = supportedIDEs.includes(ide);
7378
7383
  if (!isValid) {
7379
7384
  return {
7380
7385
  valid: false,
7381
7386
  error: `不支持的IDE类型: ${ide}`,
7382
- supportedIDEs: supportedIDEs
7387
+ supportedIDEs: supportedIDEs,
7383
7388
  };
7384
7389
  }
7385
7390
  return { valid: true };
@@ -7394,9 +7399,9 @@ function filterFilesByIDE(files, ide) {
7394
7399
  return files; // 如果找不到映射,返回所有文件
7395
7400
  }
7396
7401
  // 计算需要排除的IDE文件(除了当前IDE需要的文件)
7397
- const filesToExclude = ALL_IDE_FILES.filter(file => !ideFiles.includes(file));
7402
+ const filesToExclude = ALL_IDE_FILES.filter((file) => !ideFiles.includes(file));
7398
7403
  // 排除不需要的IDE配置文件,保留其他所有文件
7399
- return files.filter(file => !filesToExclude.includes(file));
7404
+ return files.filter((file) => !filesToExclude.includes(file));
7400
7405
  }
7401
7406
  // 创建过滤后的目录结构
7402
7407
  async function createFilteredDirectory(extractDir, filteredFiles, ide) {
@@ -7404,7 +7409,7 @@ async function createFilteredDirectory(extractDir, filteredFiles, ide) {
7404
7409
  return extractDir; // 如果选择所有IDE,直接返回原目录
7405
7410
  }
7406
7411
  // 创建新的过滤后目录
7407
- const filteredDir = path.join(path.dirname(extractDir), 'filtered');
7412
+ const filteredDir = path.join(path.dirname(extractDir), "filtered");
7408
7413
  await fsPromises.mkdir(filteredDir, { recursive: true });
7409
7414
  // 只复制过滤后的文件到新目录
7410
7415
  for (const relativePath of filteredFiles) {
@@ -7423,32 +7428,42 @@ function registerSetupTools(server) {
7423
7428
  title: "下载项目模板",
7424
7429
  description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
7425
7430
 
7426
- **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- 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 ? "2.1.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
7431
+ **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- 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 ? "2.2.0-alpha.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
7427
7432
  inputSchema: {
7428
- template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
7429
- ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
7430
- overwrite: zod_1.z.boolean().optional().describe("是否覆盖已存在的文件,默认为false(不覆盖)")
7433
+ template: zod_1.z
7434
+ .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
7435
+ .describe("要下载的模板类型"),
7436
+ ide: zod_1.z
7437
+ .enum(IDE_TYPES)
7438
+ .optional()
7439
+ .describe("指定要下载的IDE类型。如果未指定,会根据 INTEGRATION_IDE 环境变量自动选择对应的IDE配置;如果环境变量也未设置,则默认下载所有IDE配置"),
7440
+ overwrite: zod_1.z
7441
+ .boolean()
7442
+ .optional()
7443
+ .describe("是否覆盖已存在的文件,默认为false(不覆盖)"),
7431
7444
  },
7432
7445
  annotations: {
7433
7446
  readOnlyHint: false,
7434
7447
  destructiveHint: false,
7435
7448
  idempotentHint: false,
7436
7449
  openWorldHint: true,
7437
- category: "setup"
7438
- }
7439
- }, async ({ template, ide = "all", overwrite = false }) => {
7450
+ category: "setup",
7451
+ },
7452
+ }, async ({ template, ide, overwrite = false, }) => {
7440
7453
  try {
7454
+ // 如果没有传入 ide 参数,根据 INTEGRATION_IDE 环境变量获取默认值
7455
+ const resolvedIDE = ide ?? getDefaultIDEFromEnv();
7441
7456
  // 验证IDE类型
7442
- const ideValidation = validateIDE(ide);
7457
+ const ideValidation = validateIDE(resolvedIDE);
7443
7458
  if (!ideValidation.valid) {
7444
- const supportedIDEs = ideValidation.supportedIDEs?.join(', ') || '';
7459
+ const supportedIDEs = ideValidation.supportedIDEs?.join(", ") || "";
7445
7460
  return {
7446
7461
  content: [
7447
7462
  {
7448
7463
  type: "text",
7449
- text: `❌ ${ideValidation.error}\n\n支持的IDE类型: ${supportedIDEs}`
7450
- }
7451
- ]
7464
+ text: `❌ ${ideValidation.error}\n\n支持的IDE类型: ${supportedIDEs}`,
7465
+ },
7466
+ ],
7452
7467
  };
7453
7468
  }
7454
7469
  const templateConfig = TEMPLATES[template];
@@ -7457,23 +7472,23 @@ function registerSetupTools(server) {
7457
7472
  content: [
7458
7473
  {
7459
7474
  type: "text",
7460
- text: `❌ 不支持的模板类型: ${template}`
7461
- }
7462
- ]
7475
+ text: `❌ 不支持的模板类型: ${template}`,
7476
+ },
7477
+ ],
7463
7478
  };
7464
7479
  }
7465
7480
  // 创建临时目录
7466
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cloudbase-template-'));
7467
- const zipPath = path.join(tempDir, 'template.zip');
7468
- const extractDir = path.join(tempDir, 'extracted');
7481
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "cloudbase-template-"));
7482
+ const zipPath = path.join(tempDir, "template.zip");
7483
+ const extractDir = path.join(tempDir, "extracted");
7469
7484
  // 下载和解压
7470
7485
  await downloadFile(templateConfig.url, zipPath);
7471
7486
  await extractZip(zipPath, extractDir);
7472
7487
  const extractedFiles = await getAllFiles(extractDir);
7473
7488
  // 根据IDE类型过滤文件
7474
- const filteredFiles = filterFilesByIDE(extractedFiles, ide);
7489
+ const filteredFiles = filterFilesByIDE(extractedFiles, resolvedIDE);
7475
7490
  // 创建过滤后的目录结构(当选择特定IDE时)
7476
- const workingDir = await createFilteredDirectory(extractDir, filteredFiles, ide);
7491
+ const workingDir = await createFilteredDirectory(extractDir, filteredFiles, resolvedIDE);
7477
7492
  // 检查是否需要复制到项目目录
7478
7493
  const workspaceFolder = process.env.WORKSPACE_FOLDER_PATHS || process.cwd();
7479
7494
  let finalFiles = [];
@@ -7488,7 +7503,7 @@ function registerSetupTools(server) {
7488
7503
  const destPath = path.join(workspaceFolder, relativePath);
7489
7504
  const copyResult = await copyFile(srcPath, destPath, overwrite, template);
7490
7505
  if (copyResult.copied) {
7491
- if (copyResult.action === 'overwritten') {
7506
+ if (copyResult.action === "overwritten") {
7492
7507
  overwrittenCount++;
7493
7508
  }
7494
7509
  else {
@@ -7497,7 +7512,7 @@ function registerSetupTools(server) {
7497
7512
  finalFiles.push(destPath);
7498
7513
  }
7499
7514
  else {
7500
- if (copyResult.action === 'protected') {
7515
+ if (copyResult.action === "protected") {
7501
7516
  protectedCount++;
7502
7517
  }
7503
7518
  else {
@@ -7507,11 +7522,11 @@ function registerSetupTools(server) {
7507
7522
  }
7508
7523
  }
7509
7524
  // 添加IDE过滤信息
7510
- const ideInfo = IDE_DESCRIPTIONS[ide] || ide;
7525
+ const ideInfo = IDE_DESCRIPTIONS[resolvedIDE] || resolvedIDE;
7511
7526
  results.push(`✅ ${templateConfig.description} (${ideInfo}) 同步完成`);
7512
7527
  results.push(`📁 临时目录: ${workingDir}`);
7513
7528
  results.push(`🔍 文件过滤: ${extractedFiles.length} → ${filteredFiles.length} 个文件`);
7514
- if (ide !== "all") {
7529
+ if (resolvedIDE !== "all") {
7515
7530
  results.push(`✨ 已过滤IDE配置,仅保留 ${ideInfo} 相关文件`);
7516
7531
  }
7517
7532
  const stats = [];
@@ -7524,36 +7539,36 @@ function registerSetupTools(server) {
7524
7539
  if (skippedCount > 0)
7525
7540
  stats.push(`跳过 ${skippedCount} 个已存在文件`);
7526
7541
  if (stats.length > 0) {
7527
- results.push(`📊 ${stats.join('')}`);
7542
+ results.push(`📊 ${stats.join("")}`);
7528
7543
  }
7529
7544
  if (overwrite || overwrittenCount > 0 || skippedCount > 0) {
7530
- results.push(`🔄 覆盖模式: ${overwrite ? '启用' : '禁用'}`);
7545
+ results.push(`🔄 覆盖模式: ${overwrite ? "启用" : "禁用"}`);
7531
7546
  }
7532
7547
  }
7533
7548
  else {
7534
- finalFiles = filteredFiles.map(relativePath => path.join(workingDir, relativePath));
7535
- const ideInfo = IDE_DESCRIPTIONS[ide] || ide;
7549
+ finalFiles = filteredFiles.map((relativePath) => path.join(workingDir, relativePath));
7550
+ const ideInfo = IDE_DESCRIPTIONS[resolvedIDE] || resolvedIDE;
7536
7551
  results.push(`✅ ${templateConfig.description} (${ideInfo}) 下载完成`);
7537
7552
  results.push(`📁 保存在临时目录: ${workingDir}`);
7538
7553
  results.push(`🔍 文件过滤: ${extractedFiles.length} → ${filteredFiles.length} 个文件`);
7539
- if (ide !== "all") {
7554
+ if (resolvedIDE !== "all") {
7540
7555
  results.push(`✨ 已过滤IDE配置,仅保留 ${ideInfo} 相关文件`);
7541
7556
  }
7542
- results.push('💡 如需将模板(包括隐藏文件)复制到项目目录,请确保复制时包含所有隐藏文件。');
7557
+ results.push("💡 如需将模板(包括隐藏文件)复制到项目目录,请确保复制时包含所有隐藏文件。");
7543
7558
  }
7544
7559
  // 文件路径列表
7545
- results.push('');
7546
- results.push('📋 文件列表:');
7547
- finalFiles.forEach(filePath => {
7560
+ results.push("");
7561
+ results.push("📋 文件列表:");
7562
+ finalFiles.forEach((filePath) => {
7548
7563
  results.push(`${filePath}`);
7549
7564
  });
7550
7565
  return {
7551
7566
  content: [
7552
7567
  {
7553
7568
  type: "text",
7554
- text: results.join('\n')
7555
- }
7556
- ]
7569
+ text: results.join("\n"),
7570
+ },
7571
+ ],
7557
7572
  };
7558
7573
  }
7559
7574
  catch (error) {
@@ -7561,9 +7576,9 @@ function registerSetupTools(server) {
7561
7576
  content: [
7562
7577
  {
7563
7578
  type: "text",
7564
- text: `❌ 下载模板失败: ${error instanceof Error ? error.message : '未知错误'}`
7565
- }
7566
- ]
7579
+ text: `❌ 下载模板失败: ${error instanceof Error ? error.message : "未知错误"}`,
7580
+ },
7581
+ ],
7567
7582
  };
7568
7583
  }
7569
7584
  });
@@ -8511,7 +8526,7 @@ class TelemetryReporter {
8511
8526
  const nodeVersion = process.version; // Node.js版本
8512
8527
  const arch = os_1.default.arch(); // 系统架构
8513
8528
  // 从构建时注入的版本号获取MCP版本信息
8514
- const mcpVersion = process.env.npm_package_version || "2.1.0" || 0;
8529
+ const mcpVersion = process.env.npm_package_version || "2.2.0-alpha.0" || 0;
8515
8530
  return {
8516
8531
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
8517
8532
  deviceId: this.deviceId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cloudbase-mcp",
3
- "version": "2.1.0",
3
+ "version": "2.2.0-alpha.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",