@cloudbase/cloudbase-mcp 2.7.3 → 2.7.6
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 +1 -1
- package/dist/index.cjs +103 -40
- package/dist/index.js +103 -40
- package/package.json +9 -5
package/dist/index.cjs
CHANGED
|
@@ -137058,7 +137058,7 @@ class TelemetryReporter {
|
|
|
137058
137058
|
const nodeVersion = process.version; // Node.js版本
|
|
137059
137059
|
const arch = os_1.default.arch(); // 系统架构
|
|
137060
137060
|
// 从构建时注入的版本号获取MCP版本信息
|
|
137061
|
-
const mcpVersion = process.env.npm_package_version || "2.7.
|
|
137061
|
+
const mcpVersion = process.env.npm_package_version || "2.7.6" || 0;
|
|
137062
137062
|
return {
|
|
137063
137063
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
137064
137064
|
deviceId: this.deviceId,
|
|
@@ -203593,20 +203593,27 @@ const telemetry_js_1 = __webpack_require__(45880);
|
|
|
203593
203593
|
async function generateGitHubIssueLink(toolName, errorMessage, args, cloudBaseOptions, payload) {
|
|
203594
203594
|
const { requestId, ide } = payload || {};
|
|
203595
203595
|
const baseUrl = 'https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/issues/new';
|
|
203596
|
-
|
|
203596
|
+
const isTestEnvironment = false || process.env.VITEST === "true";
|
|
203597
|
+
// 尝试获取环境ID(测试环境跳过,避免交互/阻塞)
|
|
203597
203598
|
let envIdSection = '';
|
|
203598
|
-
|
|
203599
|
-
|
|
203600
|
-
|
|
203601
|
-
|
|
203599
|
+
if (!isTestEnvironment) {
|
|
203600
|
+
try {
|
|
203601
|
+
// Avoid blocking forever on envId lookup
|
|
203602
|
+
const envId = await Promise.race([
|
|
203603
|
+
(0, cloudbase_manager_js_1.getEnvId)(cloudBaseOptions),
|
|
203604
|
+
new Promise((resolve) => setTimeout(() => resolve(''), 2000)),
|
|
203605
|
+
]);
|
|
203606
|
+
if (envId) {
|
|
203607
|
+
envIdSection = `
|
|
203602
203608
|
## 环境ID
|
|
203603
203609
|
${envId}
|
|
203604
203610
|
`;
|
|
203611
|
+
}
|
|
203612
|
+
}
|
|
203613
|
+
catch (error) {
|
|
203614
|
+
// 如果获取 envId 失败,不添加环境ID部分
|
|
203615
|
+
(0, logger_js_1.debug)('无法获取环境ID:', error instanceof Error ? error : new Error(String(error)));
|
|
203605
203616
|
}
|
|
203606
|
-
}
|
|
203607
|
-
catch (error) {
|
|
203608
|
-
// 如果获取 envId 失败,不添加环境ID部分
|
|
203609
|
-
(0, logger_js_1.debug)('无法获取环境ID:', error instanceof Error ? error : new Error(String(error)));
|
|
203610
203617
|
}
|
|
203611
203618
|
// 构建标题
|
|
203612
203619
|
const title = `MCP工具错误: ${toolName}`;
|
|
@@ -203622,7 +203629,7 @@ ${envIdSection}
|
|
|
203622
203629
|
## 环境信息
|
|
203623
203630
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
203624
203631
|
- Node.js版本: ${process.version}
|
|
203625
|
-
- MCP 版本:${process.env.npm_package_version || "2.7.
|
|
203632
|
+
- MCP 版本:${process.env.npm_package_version || "2.7.6" || 0}
|
|
203626
203633
|
- 系统架构: ${os_1.default.arch()}
|
|
203627
203634
|
- 时间: ${new Date().toISOString()}
|
|
203628
203635
|
- 请求ID: ${requestId}
|
|
@@ -203660,13 +203667,19 @@ function createWrappedHandler(name, handler, server) {
|
|
|
203660
203667
|
let requestId;
|
|
203661
203668
|
try {
|
|
203662
203669
|
(0, logger_js_1.debug)(`开始执行工具: ${name}`, { args: sanitizeArgs(args) });
|
|
203663
|
-
|
|
203670
|
+
// In test environment, skip logger to avoid potential blocking
|
|
203671
|
+
const isTestEnvironment = false || process.env.VITEST === "true";
|
|
203672
|
+
if (!isTestEnvironment) {
|
|
203673
|
+
server.logger?.({ type: 'beforeToolCall', toolName: name, args: sanitizeArgs(args) });
|
|
203674
|
+
}
|
|
203664
203675
|
// 执行原始处理函数
|
|
203665
203676
|
const result = await handler(args);
|
|
203666
203677
|
success = true;
|
|
203667
203678
|
const duration = Date.now() - startTime;
|
|
203668
203679
|
(0, logger_js_1.debug)(`工具执行成功: ${name}`, { duration });
|
|
203669
|
-
|
|
203680
|
+
if (!isTestEnvironment) {
|
|
203681
|
+
server.logger?.({ type: 'afterToolCall', toolName: name, args: sanitizeArgs(args), result: result, duration });
|
|
203682
|
+
}
|
|
203670
203683
|
return result;
|
|
203671
203684
|
}
|
|
203672
203685
|
catch (error) {
|
|
@@ -203677,7 +203690,14 @@ function createWrappedHandler(name, handler, server) {
|
|
|
203677
203690
|
error: errorMessage,
|
|
203678
203691
|
duration: Date.now() - startTime
|
|
203679
203692
|
});
|
|
203680
|
-
|
|
203693
|
+
const isTestEnvironment = false || process.env.VITEST === "true";
|
|
203694
|
+
if (!isTestEnvironment) {
|
|
203695
|
+
server.logger?.({ type: 'errorToolCall', toolName: name, args: sanitizeArgs(args), message: errorMessage, duration: Date.now() - startTime });
|
|
203696
|
+
}
|
|
203697
|
+
// In tests, avoid any extra work that may block (envId lookup, issue link generation, etc.)
|
|
203698
|
+
if (isTestEnvironment) {
|
|
203699
|
+
throw error instanceof Error ? error : new Error(String(error));
|
|
203700
|
+
}
|
|
203681
203701
|
// 生成 GitHub Issue 创建链接
|
|
203682
203702
|
const issueLink = await generateGitHubIssueLink(name, errorMessage, args, server.cloudBaseOptions, {
|
|
203683
203703
|
requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
|
|
@@ -203697,25 +203717,32 @@ function createWrappedHandler(name, handler, server) {
|
|
|
203697
203717
|
throw enhancedError;
|
|
203698
203718
|
}
|
|
203699
203719
|
finally {
|
|
203700
|
-
//
|
|
203701
|
-
const
|
|
203702
|
-
|
|
203703
|
-
|
|
203704
|
-
|
|
203705
|
-
|
|
203706
|
-
if (
|
|
203707
|
-
|
|
203720
|
+
// 上报工具调用数据(测试环境中跳过,避免阻塞)
|
|
203721
|
+
const isTestEnvironment = false || process.env.VITEST === "true";
|
|
203722
|
+
if (!isTestEnvironment) {
|
|
203723
|
+
const duration = Date.now() - startTime;
|
|
203724
|
+
// 如果 server.cloudBaseOptions 为空或没有 envId,尝试从缓存获取并更新
|
|
203725
|
+
let cloudBaseOptions = server.cloudBaseOptions;
|
|
203726
|
+
if (!cloudBaseOptions?.envId) {
|
|
203727
|
+
const cachedEnvId = (0, cloudbase_manager_js_1.getCachedEnvId)();
|
|
203728
|
+
if (cachedEnvId) {
|
|
203729
|
+
cloudBaseOptions = { ...cloudBaseOptions, envId: cachedEnvId };
|
|
203730
|
+
}
|
|
203708
203731
|
}
|
|
203732
|
+
// 异步上报,不阻塞工具返回
|
|
203733
|
+
(0, telemetry_js_1.reportToolCall)({
|
|
203734
|
+
toolName: name,
|
|
203735
|
+
success,
|
|
203736
|
+
duration,
|
|
203737
|
+
error: errorMessage,
|
|
203738
|
+
inputParams: sanitizeArgs(args), // 添加入参上报
|
|
203739
|
+
cloudBaseOptions: cloudBaseOptions, // 传递 CloudBase 配置(可能已更新)
|
|
203740
|
+
ide: server.ide || process.env.INTEGRATION_IDE // 传递集成IDE信息
|
|
203741
|
+
}).catch(err => {
|
|
203742
|
+
// 静默处理上报错误,不影响主要功能
|
|
203743
|
+
(0, logger_js_1.debug)('遥测上报失败', { toolName: name, error: err instanceof Error ? err.message : String(err) });
|
|
203744
|
+
});
|
|
203709
203745
|
}
|
|
203710
|
-
(0, telemetry_js_1.reportToolCall)({
|
|
203711
|
-
toolName: name,
|
|
203712
|
-
success,
|
|
203713
|
-
duration,
|
|
203714
|
-
error: errorMessage,
|
|
203715
|
-
inputParams: sanitizeArgs(args), // 添加入参上报
|
|
203716
|
-
cloudBaseOptions: cloudBaseOptions, // 传递 CloudBase 配置(可能已更新)
|
|
203717
|
-
ide: server.ide || process.env.INTEGRATION_IDE // 传递集成IDE信息
|
|
203718
|
-
});
|
|
203719
203746
|
}
|
|
203720
203747
|
};
|
|
203721
203748
|
}
|
|
@@ -217939,6 +217966,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
217939
217966
|
};
|
|
217940
217967
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
217941
217968
|
exports.RAW_IDE_FILE_MAPPINGS = void 0;
|
|
217969
|
+
exports.resolveDownloadTemplateIDE = resolveDownloadTemplateIDE;
|
|
217970
|
+
exports.validateIDE = validateIDE;
|
|
217942
217971
|
exports.registerSetupTools = registerSetupTools;
|
|
217943
217972
|
const adm_zip_1 = __importDefault(__webpack_require__(30283));
|
|
217944
217973
|
const fs = __importStar(__webpack_require__(29021));
|
|
@@ -218116,17 +218145,30 @@ const INTEGRATION_IDE_MAPPING = {
|
|
|
218116
218145
|
Kiro: "kiro",
|
|
218117
218146
|
iFlow: "iflow-cli",
|
|
218118
218147
|
};
|
|
218119
|
-
//
|
|
218120
|
-
function
|
|
218121
|
-
|
|
218148
|
+
// Resolve IDE for downloadTemplate without side effects (unit-test friendly).
|
|
218149
|
+
function resolveDownloadTemplateIDE(ide, integrationIDE) {
|
|
218150
|
+
if (ide) {
|
|
218151
|
+
return { ok: true, resolvedIDE: ide };
|
|
218152
|
+
}
|
|
218122
218153
|
if (integrationIDE) {
|
|
218123
218154
|
const mappedIDE = INTEGRATION_IDE_MAPPING[integrationIDE];
|
|
218124
218155
|
if (mappedIDE) {
|
|
218125
|
-
return mappedIDE;
|
|
218156
|
+
return { ok: true, resolvedIDE: mappedIDE };
|
|
218126
218157
|
}
|
|
218158
|
+
return {
|
|
218159
|
+
ok: false,
|
|
218160
|
+
reason: "unmapped_integration_ide",
|
|
218161
|
+
integrationIDE,
|
|
218162
|
+
supportedIDEs: IDE_TYPES.filter((t) => t !== "all"),
|
|
218163
|
+
};
|
|
218127
218164
|
}
|
|
218128
|
-
return
|
|
218165
|
+
return {
|
|
218166
|
+
ok: false,
|
|
218167
|
+
reason: "missing_ide",
|
|
218168
|
+
supportedIDEs: IDE_TYPES.filter((t) => t !== "all"),
|
|
218169
|
+
};
|
|
218129
218170
|
}
|
|
218171
|
+
// 根据 INTEGRATION_IDE 环境变量获取默认 IDE 类型
|
|
218130
218172
|
// 下载文件到临时目录
|
|
218131
218173
|
async function downloadFile(url, filePath) {
|
|
218132
218174
|
return new Promise((resolve, reject) => {
|
|
@@ -218343,7 +218385,7 @@ function registerSetupTools(server) {
|
|
|
218343
218385
|
title: "下载项目模板",
|
|
218344
218386
|
description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
|
|
218345
218387
|
|
|
218346
|
-
**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
|
|
218388
|
+
**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.7.6" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
218347
218389
|
inputSchema: {
|
|
218348
218390
|
template: zod_1.z
|
|
218349
218391
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
@@ -218351,7 +218393,7 @@ function registerSetupTools(server) {
|
|
|
218351
218393
|
ide: zod_1.z
|
|
218352
218394
|
.enum(IDE_TYPES)
|
|
218353
218395
|
.optional()
|
|
218354
|
-
.describe("指定要下载的IDE类型。如果未指定,会根据 INTEGRATION_IDE 环境变量自动选择对应的IDE
|
|
218396
|
+
.describe("指定要下载的IDE类型。如果未指定,会根据 INTEGRATION_IDE 环境变量自动选择对应的IDE配置;如果环境变量也未设置,则必须传入此参数"),
|
|
218355
218397
|
overwrite: zod_1.z
|
|
218356
218398
|
.boolean()
|
|
218357
218399
|
.optional()
|
|
@@ -218366,8 +218408,29 @@ function registerSetupTools(server) {
|
|
|
218366
218408
|
},
|
|
218367
218409
|
}, async ({ template, ide, overwrite = false, }) => {
|
|
218368
218410
|
try {
|
|
218369
|
-
|
|
218370
|
-
|
|
218411
|
+
const ideResolution = resolveDownloadTemplateIDE(ide, process.env.INTEGRATION_IDE);
|
|
218412
|
+
if (!ideResolution.ok) {
|
|
218413
|
+
const supportedIDEs = ideResolution.supportedIDEs.join(", ");
|
|
218414
|
+
if (ideResolution.reason === "unmapped_integration_ide") {
|
|
218415
|
+
return {
|
|
218416
|
+
content: [
|
|
218417
|
+
{
|
|
218418
|
+
type: "text",
|
|
218419
|
+
text: `❌ 无法识别当前 IDE 环境\n\n检测到 INTEGRATION_IDE="${ideResolution.integrationIDE}",但无法映射到支持的 IDE 类型。\n\n请显式传入 \`ide\` 参数来指定要下载的 IDE 配置。\n\n支持的 IDE 类型: ${supportedIDEs}\n\n示例: \`ide: "cursor"\` 或 \`ide: "all"\`(下载所有 IDE 配置)`,
|
|
218420
|
+
},
|
|
218421
|
+
],
|
|
218422
|
+
};
|
|
218423
|
+
}
|
|
218424
|
+
return {
|
|
218425
|
+
content: [
|
|
218426
|
+
{
|
|
218427
|
+
type: "text",
|
|
218428
|
+
text: `❌ 必须指定 IDE 参数\n\n请传入 \`ide\` 参数来指定要下载的 IDE 配置。\n\n支持的 IDE 类型: ${supportedIDEs}\n\n示例: \`ide: "cursor"\` 或 \`ide: "all"\`(下载所有 IDE 配置)`,
|
|
218429
|
+
},
|
|
218430
|
+
],
|
|
218431
|
+
};
|
|
218432
|
+
}
|
|
218433
|
+
const resolvedIDE = ideResolution.resolvedIDE;
|
|
218371
218434
|
// 验证IDE类型
|
|
218372
218435
|
const ideValidation = validateIDE(resolvedIDE);
|
|
218373
218436
|
if (!ideValidation.valid) {
|
package/dist/index.js
CHANGED
|
@@ -527,20 +527,27 @@ const telemetry_js_1 = __webpack_require__(5880);
|
|
|
527
527
|
async function generateGitHubIssueLink(toolName, errorMessage, args, cloudBaseOptions, payload) {
|
|
528
528
|
const { requestId, ide } = payload || {};
|
|
529
529
|
const baseUrl = 'https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/issues/new';
|
|
530
|
-
|
|
530
|
+
const isTestEnvironment = false || process.env.VITEST === "true";
|
|
531
|
+
// 尝试获取环境ID(测试环境跳过,避免交互/阻塞)
|
|
531
532
|
let envIdSection = '';
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
533
|
+
if (!isTestEnvironment) {
|
|
534
|
+
try {
|
|
535
|
+
// Avoid blocking forever on envId lookup
|
|
536
|
+
const envId = await Promise.race([
|
|
537
|
+
(0, cloudbase_manager_js_1.getEnvId)(cloudBaseOptions),
|
|
538
|
+
new Promise((resolve) => setTimeout(() => resolve(''), 2000)),
|
|
539
|
+
]);
|
|
540
|
+
if (envId) {
|
|
541
|
+
envIdSection = `
|
|
536
542
|
## 环境ID
|
|
537
543
|
${envId}
|
|
538
544
|
`;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
catch (error) {
|
|
548
|
+
// 如果获取 envId 失败,不添加环境ID部分
|
|
549
|
+
(0, logger_js_1.debug)('无法获取环境ID:', error instanceof Error ? error : new Error(String(error)));
|
|
539
550
|
}
|
|
540
|
-
}
|
|
541
|
-
catch (error) {
|
|
542
|
-
// 如果获取 envId 失败,不添加环境ID部分
|
|
543
|
-
(0, logger_js_1.debug)('无法获取环境ID:', error instanceof Error ? error : new Error(String(error)));
|
|
544
551
|
}
|
|
545
552
|
// 构建标题
|
|
546
553
|
const title = `MCP工具错误: ${toolName}`;
|
|
@@ -556,7 +563,7 @@ ${envIdSection}
|
|
|
556
563
|
## 环境信息
|
|
557
564
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
558
565
|
- Node.js版本: ${process.version}
|
|
559
|
-
- MCP 版本:${process.env.npm_package_version || "2.7.
|
|
566
|
+
- MCP 版本:${process.env.npm_package_version || "2.7.6" || 0}
|
|
560
567
|
- 系统架构: ${os_1.default.arch()}
|
|
561
568
|
- 时间: ${new Date().toISOString()}
|
|
562
569
|
- 请求ID: ${requestId}
|
|
@@ -594,13 +601,19 @@ function createWrappedHandler(name, handler, server) {
|
|
|
594
601
|
let requestId;
|
|
595
602
|
try {
|
|
596
603
|
(0, logger_js_1.debug)(`开始执行工具: ${name}`, { args: sanitizeArgs(args) });
|
|
597
|
-
|
|
604
|
+
// In test environment, skip logger to avoid potential blocking
|
|
605
|
+
const isTestEnvironment = false || process.env.VITEST === "true";
|
|
606
|
+
if (!isTestEnvironment) {
|
|
607
|
+
server.logger?.({ type: 'beforeToolCall', toolName: name, args: sanitizeArgs(args) });
|
|
608
|
+
}
|
|
598
609
|
// 执行原始处理函数
|
|
599
610
|
const result = await handler(args);
|
|
600
611
|
success = true;
|
|
601
612
|
const duration = Date.now() - startTime;
|
|
602
613
|
(0, logger_js_1.debug)(`工具执行成功: ${name}`, { duration });
|
|
603
|
-
|
|
614
|
+
if (!isTestEnvironment) {
|
|
615
|
+
server.logger?.({ type: 'afterToolCall', toolName: name, args: sanitizeArgs(args), result: result, duration });
|
|
616
|
+
}
|
|
604
617
|
return result;
|
|
605
618
|
}
|
|
606
619
|
catch (error) {
|
|
@@ -611,7 +624,14 @@ function createWrappedHandler(name, handler, server) {
|
|
|
611
624
|
error: errorMessage,
|
|
612
625
|
duration: Date.now() - startTime
|
|
613
626
|
});
|
|
614
|
-
|
|
627
|
+
const isTestEnvironment = false || process.env.VITEST === "true";
|
|
628
|
+
if (!isTestEnvironment) {
|
|
629
|
+
server.logger?.({ type: 'errorToolCall', toolName: name, args: sanitizeArgs(args), message: errorMessage, duration: Date.now() - startTime });
|
|
630
|
+
}
|
|
631
|
+
// In tests, avoid any extra work that may block (envId lookup, issue link generation, etc.)
|
|
632
|
+
if (isTestEnvironment) {
|
|
633
|
+
throw error instanceof Error ? error : new Error(String(error));
|
|
634
|
+
}
|
|
615
635
|
// 生成 GitHub Issue 创建链接
|
|
616
636
|
const issueLink = await generateGitHubIssueLink(name, errorMessage, args, server.cloudBaseOptions, {
|
|
617
637
|
requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
|
|
@@ -631,25 +651,32 @@ function createWrappedHandler(name, handler, server) {
|
|
|
631
651
|
throw enhancedError;
|
|
632
652
|
}
|
|
633
653
|
finally {
|
|
634
|
-
//
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
if (
|
|
641
|
-
|
|
654
|
+
// 上报工具调用数据(测试环境中跳过,避免阻塞)
|
|
655
|
+
const isTestEnvironment = false || process.env.VITEST === "true";
|
|
656
|
+
if (!isTestEnvironment) {
|
|
657
|
+
const duration = Date.now() - startTime;
|
|
658
|
+
// 如果 server.cloudBaseOptions 为空或没有 envId,尝试从缓存获取并更新
|
|
659
|
+
let cloudBaseOptions = server.cloudBaseOptions;
|
|
660
|
+
if (!cloudBaseOptions?.envId) {
|
|
661
|
+
const cachedEnvId = (0, cloudbase_manager_js_1.getCachedEnvId)();
|
|
662
|
+
if (cachedEnvId) {
|
|
663
|
+
cloudBaseOptions = { ...cloudBaseOptions, envId: cachedEnvId };
|
|
664
|
+
}
|
|
642
665
|
}
|
|
666
|
+
// 异步上报,不阻塞工具返回
|
|
667
|
+
(0, telemetry_js_1.reportToolCall)({
|
|
668
|
+
toolName: name,
|
|
669
|
+
success,
|
|
670
|
+
duration,
|
|
671
|
+
error: errorMessage,
|
|
672
|
+
inputParams: sanitizeArgs(args), // 添加入参上报
|
|
673
|
+
cloudBaseOptions: cloudBaseOptions, // 传递 CloudBase 配置(可能已更新)
|
|
674
|
+
ide: server.ide || process.env.INTEGRATION_IDE // 传递集成IDE信息
|
|
675
|
+
}).catch(err => {
|
|
676
|
+
// 静默处理上报错误,不影响主要功能
|
|
677
|
+
(0, logger_js_1.debug)('遥测上报失败', { toolName: name, error: err instanceof Error ? err.message : String(err) });
|
|
678
|
+
});
|
|
643
679
|
}
|
|
644
|
-
(0, telemetry_js_1.reportToolCall)({
|
|
645
|
-
toolName: name,
|
|
646
|
-
success,
|
|
647
|
-
duration,
|
|
648
|
-
error: errorMessage,
|
|
649
|
-
inputParams: sanitizeArgs(args), // 添加入参上报
|
|
650
|
-
cloudBaseOptions: cloudBaseOptions, // 传递 CloudBase 配置(可能已更新)
|
|
651
|
-
ide: server.ide || process.env.INTEGRATION_IDE // 传递集成IDE信息
|
|
652
|
-
});
|
|
653
680
|
}
|
|
654
681
|
};
|
|
655
682
|
}
|
|
@@ -8686,7 +8713,7 @@ class TelemetryReporter {
|
|
|
8686
8713
|
const nodeVersion = process.version; // Node.js版本
|
|
8687
8714
|
const arch = os_1.default.arch(); // 系统架构
|
|
8688
8715
|
// 从构建时注入的版本号获取MCP版本信息
|
|
8689
|
-
const mcpVersion = process.env.npm_package_version || "2.7.
|
|
8716
|
+
const mcpVersion = process.env.npm_package_version || "2.7.6" || 0;
|
|
8690
8717
|
return {
|
|
8691
8718
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
8692
8719
|
deviceId: this.deviceId,
|
|
@@ -9687,6 +9714,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9687
9714
|
};
|
|
9688
9715
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9689
9716
|
exports.RAW_IDE_FILE_MAPPINGS = void 0;
|
|
9717
|
+
exports.resolveDownloadTemplateIDE = resolveDownloadTemplateIDE;
|
|
9718
|
+
exports.validateIDE = validateIDE;
|
|
9690
9719
|
exports.registerSetupTools = registerSetupTools;
|
|
9691
9720
|
const adm_zip_1 = __importDefault(__webpack_require__(2872));
|
|
9692
9721
|
const fs = __importStar(__webpack_require__(4421));
|
|
@@ -9864,17 +9893,30 @@ const INTEGRATION_IDE_MAPPING = {
|
|
|
9864
9893
|
Kiro: "kiro",
|
|
9865
9894
|
iFlow: "iflow-cli",
|
|
9866
9895
|
};
|
|
9867
|
-
//
|
|
9868
|
-
function
|
|
9869
|
-
|
|
9896
|
+
// Resolve IDE for downloadTemplate without side effects (unit-test friendly).
|
|
9897
|
+
function resolveDownloadTemplateIDE(ide, integrationIDE) {
|
|
9898
|
+
if (ide) {
|
|
9899
|
+
return { ok: true, resolvedIDE: ide };
|
|
9900
|
+
}
|
|
9870
9901
|
if (integrationIDE) {
|
|
9871
9902
|
const mappedIDE = INTEGRATION_IDE_MAPPING[integrationIDE];
|
|
9872
9903
|
if (mappedIDE) {
|
|
9873
|
-
return mappedIDE;
|
|
9904
|
+
return { ok: true, resolvedIDE: mappedIDE };
|
|
9874
9905
|
}
|
|
9906
|
+
return {
|
|
9907
|
+
ok: false,
|
|
9908
|
+
reason: "unmapped_integration_ide",
|
|
9909
|
+
integrationIDE,
|
|
9910
|
+
supportedIDEs: IDE_TYPES.filter((t) => t !== "all"),
|
|
9911
|
+
};
|
|
9875
9912
|
}
|
|
9876
|
-
return
|
|
9913
|
+
return {
|
|
9914
|
+
ok: false,
|
|
9915
|
+
reason: "missing_ide",
|
|
9916
|
+
supportedIDEs: IDE_TYPES.filter((t) => t !== "all"),
|
|
9917
|
+
};
|
|
9877
9918
|
}
|
|
9919
|
+
// 根据 INTEGRATION_IDE 环境变量获取默认 IDE 类型
|
|
9878
9920
|
// 下载文件到临时目录
|
|
9879
9921
|
async function downloadFile(url, filePath) {
|
|
9880
9922
|
return new Promise((resolve, reject) => {
|
|
@@ -10091,7 +10133,7 @@ function registerSetupTools(server) {
|
|
|
10091
10133
|
title: "下载项目模板",
|
|
10092
10134
|
description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
|
|
10093
10135
|
|
|
10094
|
-
**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
|
|
10136
|
+
**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.7.6" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
10095
10137
|
inputSchema: {
|
|
10096
10138
|
template: zod_1.z
|
|
10097
10139
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
@@ -10099,7 +10141,7 @@ function registerSetupTools(server) {
|
|
|
10099
10141
|
ide: zod_1.z
|
|
10100
10142
|
.enum(IDE_TYPES)
|
|
10101
10143
|
.optional()
|
|
10102
|
-
.describe("指定要下载的IDE类型。如果未指定,会根据 INTEGRATION_IDE 环境变量自动选择对应的IDE
|
|
10144
|
+
.describe("指定要下载的IDE类型。如果未指定,会根据 INTEGRATION_IDE 环境变量自动选择对应的IDE配置;如果环境变量也未设置,则必须传入此参数"),
|
|
10103
10145
|
overwrite: zod_1.z
|
|
10104
10146
|
.boolean()
|
|
10105
10147
|
.optional()
|
|
@@ -10114,8 +10156,29 @@ function registerSetupTools(server) {
|
|
|
10114
10156
|
},
|
|
10115
10157
|
}, async ({ template, ide, overwrite = false, }) => {
|
|
10116
10158
|
try {
|
|
10117
|
-
|
|
10118
|
-
|
|
10159
|
+
const ideResolution = resolveDownloadTemplateIDE(ide, process.env.INTEGRATION_IDE);
|
|
10160
|
+
if (!ideResolution.ok) {
|
|
10161
|
+
const supportedIDEs = ideResolution.supportedIDEs.join(", ");
|
|
10162
|
+
if (ideResolution.reason === "unmapped_integration_ide") {
|
|
10163
|
+
return {
|
|
10164
|
+
content: [
|
|
10165
|
+
{
|
|
10166
|
+
type: "text",
|
|
10167
|
+
text: `❌ 无法识别当前 IDE 环境\n\n检测到 INTEGRATION_IDE="${ideResolution.integrationIDE}",但无法映射到支持的 IDE 类型。\n\n请显式传入 \`ide\` 参数来指定要下载的 IDE 配置。\n\n支持的 IDE 类型: ${supportedIDEs}\n\n示例: \`ide: "cursor"\` 或 \`ide: "all"\`(下载所有 IDE 配置)`,
|
|
10168
|
+
},
|
|
10169
|
+
],
|
|
10170
|
+
};
|
|
10171
|
+
}
|
|
10172
|
+
return {
|
|
10173
|
+
content: [
|
|
10174
|
+
{
|
|
10175
|
+
type: "text",
|
|
10176
|
+
text: `❌ 必须指定 IDE 参数\n\n请传入 \`ide\` 参数来指定要下载的 IDE 配置。\n\n支持的 IDE 类型: ${supportedIDEs}\n\n示例: \`ide: "cursor"\` 或 \`ide: "all"\`(下载所有 IDE 配置)`,
|
|
10177
|
+
},
|
|
10178
|
+
],
|
|
10179
|
+
};
|
|
10180
|
+
}
|
|
10181
|
+
const resolvedIDE = ideResolution.resolvedIDE;
|
|
10119
10182
|
// 验证IDE类型
|
|
10120
10183
|
const ideValidation = validateIDE(resolvedIDE);
|
|
10121
10184
|
if (!ideValidation.valid) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cloudbase-mcp",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.6",
|
|
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",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"bin": {
|
|
10
|
-
"cloudbase-mcp": "
|
|
10
|
+
"cloudbase-mcp": "dist/cli.cjs"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"provenance": true
|
|
11
15
|
},
|
|
12
16
|
"exports": {
|
|
13
17
|
".": {
|
|
@@ -22,14 +26,14 @@
|
|
|
22
26
|
"default": "./dist/index.js"
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
|
-
"homepage": "https://github.com/TencentCloudBase/CloudBase-
|
|
29
|
+
"homepage": "https://github.com/TencentCloudBase/CloudBase-MCP",
|
|
26
30
|
"bugs": {
|
|
27
|
-
"url": "https://github.com/TencentCloudBase/CloudBase-
|
|
31
|
+
"url": "https://github.com/TencentCloudBase/CloudBase-MCP/issues",
|
|
28
32
|
"email": "bookerzhao@tencent.com"
|
|
29
33
|
},
|
|
30
34
|
"repository": {
|
|
31
35
|
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/TencentCloudBase/CloudBase-
|
|
36
|
+
"url": "git+https://github.com/TencentCloudBase/CloudBase-MCP.git"
|
|
33
37
|
},
|
|
34
38
|
"scripts": {
|
|
35
39
|
"clean": "rm -rf dist",
|