@cloudbase/cloudbase-mcp 2.33.0 → 2.33.1
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 +146 -46
- package/dist/index.d.ts +5 -0
- package/dist/index.js +146 -46
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ exports.getAuthProgressState = getAuthProgressState;
|
|
|
38
38
|
exports.resolveAuthOptions = resolveAuthOptions;
|
|
39
39
|
exports.getAuthConfigValidationError = getAuthConfigValidationError;
|
|
40
40
|
exports.buildAuthConfigSummary = buildAuthConfigSummary;
|
|
41
|
+
exports.buildDeviceLoginOptions = buildDeviceLoginOptions;
|
|
41
42
|
exports.setPendingAuthProgressState = setPendingAuthProgressState;
|
|
42
43
|
exports.resolveAuthProgressState = resolveAuthProgressState;
|
|
43
44
|
exports.rejectAuthProgressState = rejectAuthProgressState;
|
|
@@ -256,9 +257,10 @@ function getAuthConfigValidationError(options) {
|
|
|
256
257
|
if (options.oauthCustom && !options.oauthEndpoint) {
|
|
257
258
|
return "oauthCustom=true 时必须同时提供 oauthEndpoint。";
|
|
258
259
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
260
|
+
// oauthEndpoint + 显式 oauthCustom=false 放行:resolveAuthOptions 对"只配 endpoint
|
|
261
|
+
// 未配 custom"已默认 custom=true,走到这里的 endpoint+false 只可能是用户显式指定——
|
|
262
|
+
// 即标准 {code,result} 包装格式的自定义端点(如国际站 tcb-api.tencentcloud.com),
|
|
263
|
+
// 拦截会导致标准格式端点在工具层永远不可用。
|
|
262
264
|
return null;
|
|
263
265
|
}
|
|
264
266
|
function buildAuthConfigSummary(options) {
|
|
@@ -270,6 +272,40 @@ function buildAuthConfigSummary(options) {
|
|
|
270
272
|
uses_toolbox_defaults: options.usesToolboxDefaults,
|
|
271
273
|
};
|
|
272
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* 构造 device flow 的 loginByWebAuth 基础参数(onDeviceCode 由调用方按需注入)。
|
|
277
|
+
*
|
|
278
|
+
* 所有 device 登录路径(ensureLogin 与 auth 工具 start_auth 的 device 分支)必须
|
|
279
|
+
* 共享本函数:TCB_SITE=intl 时的 getOAuthEndpoint 覆写与 getAuthUrl 授权页改写
|
|
280
|
+
* 只在 ensureLogin 生效,会导致工具层直连路径仍打国内站端点/授权页,国际站账号
|
|
281
|
+
* 无法完成授权(device-code 注册表国内外隔离,国内授权页对国际站账号无效)。
|
|
282
|
+
*/
|
|
283
|
+
function buildDeviceLoginOptions(resolvedAuthOptions, siteHints = {}) {
|
|
284
|
+
const resolvedSite = (0, site_map_js_1.resolveSite)(siteHints.region, siteHints.site ?? process.env.TCB_SITE);
|
|
285
|
+
const loginOptions = { flow: "device" };
|
|
286
|
+
if (resolvedAuthOptions.clientId) {
|
|
287
|
+
loginOptions.client_id = resolvedAuthOptions.clientId;
|
|
288
|
+
}
|
|
289
|
+
if (resolvedAuthOptions.oauthEndpoint) {
|
|
290
|
+
loginOptions.getOAuthEndpoint = () => resolvedAuthOptions.oauthEndpoint;
|
|
291
|
+
}
|
|
292
|
+
else if (resolvedSite === "intl") {
|
|
293
|
+
// 国际站 OAuth 后端独立部署(2026-09-01 实测 device/code+token 可用,注册表与国内站隔离);
|
|
294
|
+
// 不覆写时 toolbox 默认打国内站端点,国际站账号无法完成授权
|
|
295
|
+
loginOptions.getOAuthEndpoint = () => site_map_js_1.SITE_REGION_MAP.intl.oauthEndpoint;
|
|
296
|
+
}
|
|
297
|
+
if (resolvedSite === "intl") {
|
|
298
|
+
// device 模式的 verification_uri 标准模式下由客户端拼接,指向国内站授权页;
|
|
299
|
+
// 与 web 模式同款 host 改写,把授权页切到国际站
|
|
300
|
+
loginOptions.getAuthUrl = (url) => url
|
|
301
|
+
.replace(`${site_map_js_1.SITE_REGION_MAP.domestic.authHost}/dev`, `${site_map_js_1.SITE_REGION_MAP.intl.authHost}/dev`)
|
|
302
|
+
.replace(site_map_js_1.SITE_REGION_MAP.domestic.authHost, site_map_js_1.SITE_REGION_MAP.intl.authHost);
|
|
303
|
+
}
|
|
304
|
+
if (resolvedAuthOptions.oauthCustom) {
|
|
305
|
+
loginOptions.custom = true;
|
|
306
|
+
}
|
|
307
|
+
return loginOptions;
|
|
308
|
+
}
|
|
273
309
|
function setPendingAuthProgressState(challenge, authMode = "device") {
|
|
274
310
|
return updateAuthProgressState({
|
|
275
311
|
status: "PENDING",
|
|
@@ -509,27 +545,11 @@ async function ensureLogin(options) {
|
|
|
509
545
|
};
|
|
510
546
|
}
|
|
511
547
|
else {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
else if (resolvedSite === "intl") {
|
|
519
|
-
// 国际站 OAuth 后端独立部署(2026-09-01 实测 device/code+token 可用,注册表与国内站隔离);
|
|
520
|
-
// 不覆写时 toolbox 默认打国内站端点,国际站账号无法完成授权
|
|
521
|
-
loginOptions.getOAuthEndpoint = () => site_map_js_1.SITE_REGION_MAP.intl.oauthEndpoint;
|
|
522
|
-
}
|
|
523
|
-
if (resolvedSite === "intl") {
|
|
524
|
-
// device 模式的 verification_uri 标准模式下由客户端拼接,指向国内站授权页;
|
|
525
|
-
// 与 web 模式同款 host 改写,把授权页切到国际站
|
|
526
|
-
loginOptions.getAuthUrl = (url) => url
|
|
527
|
-
.replace(`${site_map_js_1.SITE_REGION_MAP.domestic.authHost}/dev`, `${site_map_js_1.SITE_REGION_MAP.intl.authHost}/dev`)
|
|
528
|
-
.replace(site_map_js_1.SITE_REGION_MAP.domestic.authHost, site_map_js_1.SITE_REGION_MAP.intl.authHost);
|
|
529
|
-
}
|
|
530
|
-
if (resolvedAuthOptions.oauthCustom) {
|
|
531
|
-
loginOptions.custom = true;
|
|
532
|
-
}
|
|
548
|
+
// device 模式:与 auth 工具 start_auth device 分支共享 intl 端点覆写与授权页改写
|
|
549
|
+
Object.assign(loginOptions, buildDeviceLoginOptions(resolvedAuthOptions, {
|
|
550
|
+
region: options?.region,
|
|
551
|
+
site: options?.site,
|
|
552
|
+
}));
|
|
533
553
|
if (options?.onDeviceCode) {
|
|
534
554
|
loginOptions.onDeviceCode = (info) => {
|
|
535
555
|
setPendingAuthProgressState(info, mode);
|
|
@@ -2071,7 +2091,7 @@ __webpack_unused_export__ = Object.values(exports.TCB_ACTION_INDEX_MAP);
|
|
|
2071
2091
|
|
|
2072
2092
|
|
|
2073
2093
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2074
|
-
exports.telemetryReporter = exports.reportToolkitLifecycle = exports.reportToolCall = exports.warn = exports.info = exports.error = exports.StdioServerTransport = void 0;
|
|
2094
|
+
exports.normalizeClientName = exports.telemetryReporter = exports.reportToolkitLifecycle = exports.reportToolCall = exports.warn = exports.info = exports.error = exports.StdioServerTransport = void 0;
|
|
2075
2095
|
exports.createCloudBaseMcpServer = createCloudBaseMcpServer;
|
|
2076
2096
|
exports.getDefaultServer = getDefaultServer;
|
|
2077
2097
|
const mcp_js_1 = __webpack_require__(4619);
|
|
@@ -2102,6 +2122,7 @@ const logger_js_1 = __webpack_require__(781);
|
|
|
2102
2122
|
const site_map_js_1 = __webpack_require__(4533);
|
|
2103
2123
|
const tool_result_js_1 = __webpack_require__(9645);
|
|
2104
2124
|
const tool_wrapper_js_1 = __webpack_require__(3389);
|
|
2125
|
+
const telemetry_js_1 = __webpack_require__(5198);
|
|
2105
2126
|
// 默认插件列表
|
|
2106
2127
|
const DEFAULT_PLUGINS = [
|
|
2107
2128
|
"env",
|
|
@@ -2245,7 +2266,7 @@ function parseEnabledPlugins(pluginsEnabled, pluginsDisabled) {
|
|
|
2245
2266
|
* await server.connect(transport);
|
|
2246
2267
|
*/
|
|
2247
2268
|
async function createCloudBaseMcpServer(options) {
|
|
2248
|
-
const { name = "cloudbase-mcp", version = "1.0.0", enableTelemetry = true, cloudBaseOptions, authOptions, cloudMode = false, ide, logger, pluginsEnabled, pluginsDisabled, pluginOptions, } = options ?? {};
|
|
2269
|
+
const { name = "cloudbase-mcp", version = "1.0.0", enableTelemetry = true, cloudBaseOptions, authOptions, cloudMode = false, ide, client, logger, pluginsEnabled, pluginsDisabled, pluginOptions, } = options ?? {};
|
|
2249
2270
|
// Enable cloud mode if specified
|
|
2250
2271
|
if (cloudMode) {
|
|
2251
2272
|
(0, cloud_mode_js_1.enableCloudMode)();
|
|
@@ -2308,6 +2329,11 @@ async function createCloudBaseMcpServer(options) {
|
|
|
2308
2329
|
if (ide) {
|
|
2309
2330
|
server.ide = ide;
|
|
2310
2331
|
}
|
|
2332
|
+
// Store client in server instance for telemetry (normalized, invalid values dropped)
|
|
2333
|
+
const normalizedClient = (0, telemetry_js_1.normalizeClientName)(client);
|
|
2334
|
+
if (normalizedClient) {
|
|
2335
|
+
server.client = normalizedClient;
|
|
2336
|
+
}
|
|
2311
2337
|
// Store logger in server instance for tools to access
|
|
2312
2338
|
if (logger) {
|
|
2313
2339
|
server.logger = logger;
|
|
@@ -2342,10 +2368,11 @@ var logger_js_2 = __webpack_require__(781);
|
|
|
2342
2368
|
Object.defineProperty(exports, "error", ({ enumerable: true, get: function () { return logger_js_2.error; } }));
|
|
2343
2369
|
Object.defineProperty(exports, "info", ({ enumerable: true, get: function () { return logger_js_2.info; } }));
|
|
2344
2370
|
Object.defineProperty(exports, "warn", ({ enumerable: true, get: function () { return logger_js_2.warn; } }));
|
|
2345
|
-
var
|
|
2346
|
-
Object.defineProperty(exports, "reportToolCall", ({ enumerable: true, get: function () { return
|
|
2347
|
-
Object.defineProperty(exports, "reportToolkitLifecycle", ({ enumerable: true, get: function () { return
|
|
2348
|
-
Object.defineProperty(exports, "telemetryReporter", ({ enumerable: true, get: function () { return
|
|
2371
|
+
var telemetry_js_2 = __webpack_require__(5198);
|
|
2372
|
+
Object.defineProperty(exports, "reportToolCall", ({ enumerable: true, get: function () { return telemetry_js_2.reportToolCall; } }));
|
|
2373
|
+
Object.defineProperty(exports, "reportToolkitLifecycle", ({ enumerable: true, get: function () { return telemetry_js_2.reportToolkitLifecycle; } }));
|
|
2374
|
+
Object.defineProperty(exports, "telemetryReporter", ({ enumerable: true, get: function () { return telemetry_js_2.telemetryReporter; } }));
|
|
2375
|
+
Object.defineProperty(exports, "normalizeClientName", ({ enumerable: true, get: function () { return telemetry_js_2.normalizeClientName; } }));
|
|
2349
2376
|
|
|
2350
2377
|
|
|
2351
2378
|
/***/ },
|
|
@@ -14652,7 +14679,7 @@ function registerEnvTools(server) {
|
|
|
14652
14679
|
oauthCustom: zod_1.z
|
|
14653
14680
|
.boolean()
|
|
14654
14681
|
.optional()
|
|
14655
|
-
.describe("高级可选:自定义 endpoint 返回格式开关。未配置 endpoint 时默认 false;配置 endpoint 后默认 true
|
|
14682
|
+
.describe("高级可选:自定义 endpoint 返回格式开关。未配置 endpoint 时默认 false;配置 endpoint 后默认 true。标准 {code,result} 包装格式的端点(如国际站 tcb-api.tencentcloud.com)应显式传 false"),
|
|
14656
14683
|
}
|
|
14657
14684
|
: {}),
|
|
14658
14685
|
envId: zod_1.z
|
|
@@ -14897,19 +14924,15 @@ function registerEnvTools(server) {
|
|
|
14897
14924
|
}
|
|
14898
14925
|
};
|
|
14899
14926
|
try {
|
|
14900
|
-
// 启动 Device Flow,全流程由 toolbox 负责轮询和写入 credential
|
|
14927
|
+
// 启动 Device Flow,全流程由 toolbox 负责轮询和写入 credential,这里不等待完成。
|
|
14928
|
+
// 登录参数(含 TCB_SITE=intl 端点覆写与授权页改写)与 ensureLogin 共享同一 helper,
|
|
14929
|
+
// 避免此直连路径绕过国际站改写导致国际站账号拿到的仍是国内站链接
|
|
14901
14930
|
auth
|
|
14902
14931
|
.loginByWebAuth({
|
|
14903
|
-
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
|
|
14907
|
-
...(resolvedAuthOptions.oauthEndpoint
|
|
14908
|
-
? { getOAuthEndpoint: () => resolvedAuthOptions.oauthEndpoint }
|
|
14909
|
-
: {}),
|
|
14910
|
-
...(resolvedAuthOptions.oauthCustom
|
|
14911
|
-
? { custom: true }
|
|
14912
|
-
: {}),
|
|
14932
|
+
...(0, auth_js_1.buildDeviceLoginOptions)(resolvedAuthOptions, {
|
|
14933
|
+
region,
|
|
14934
|
+
site: server.cloudBaseOptions?.site,
|
|
14935
|
+
}),
|
|
14913
14936
|
onDeviceCode: deviceOnCode,
|
|
14914
14937
|
})
|
|
14915
14938
|
.then(async () => {
|
|
@@ -24802,7 +24825,7 @@ function registerSetupTools(server) {
|
|
|
24802
24825
|
server.registerTool("downloadTemplate", {
|
|
24803
24826
|
title: "下载项目模板",
|
|
24804
24827
|
description: `自动下载并部署CloudBase项目模板。
|
|
24805
|
-
**Note**: Call this tool when the user requests to create a new project using a CloudBase template.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置\n- cursor: Cursor AI编辑器\n- 其他IDE类型见下方列表\n\n注意:如果未传入 ide 参数且无法从环境变量检测到 IDE,将提示错误并要求传入 ide 参数\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- qoder: Qoder AI编辑器\n- antigravity: Google Antigravity AI编辑器\n- vscode: Visual Studio Code\n- kiro: Kiro AI编辑器\n- aider: Aider AI编辑器\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.33.
|
|
24828
|
+
**Note**: Call this tool when the user requests to create a new project using a CloudBase template.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置\n- cursor: Cursor AI编辑器\n- 其他IDE类型见下方列表\n\n注意:如果未传入 ide 参数且无法从环境变量检测到 IDE,将提示错误并要求传入 ide 参数\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- qoder: Qoder AI编辑器\n- antigravity: Google Antigravity AI编辑器\n- vscode: Visual Studio Code\n- kiro: Kiro AI编辑器\n- aider: Aider AI编辑器\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.33.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
24806
24829
|
inputSchema: {
|
|
24807
24830
|
template: zod_1.z
|
|
24808
24831
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
@@ -27026,12 +27049,14 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
27026
27049
|
exports.reportToolkitLifecycle = exports.reportToolCall = exports.telemetryReporter = void 0;
|
|
27027
27050
|
exports.extractMcpClientInfo = extractMcpClientInfo;
|
|
27028
27051
|
exports.readMcpClientInfoFromServer = readMcpClientInfoFromServer;
|
|
27052
|
+
exports.normalizeClientName = normalizeClientName;
|
|
27029
27053
|
const crypto_1 = __importDefault(__webpack_require__(7823));
|
|
27030
27054
|
const http_1 = __importDefault(__webpack_require__(3782));
|
|
27031
27055
|
const https_1 = __importDefault(__webpack_require__(3871));
|
|
27032
27056
|
const os_1 = __importDefault(__webpack_require__(8116));
|
|
27033
27057
|
const cloudbase_manager_js_1 = __webpack_require__(3109);
|
|
27034
27058
|
const logger_js_1 = __webpack_require__(781);
|
|
27059
|
+
const site_map_js_1 = __webpack_require__(4533);
|
|
27035
27060
|
/**
|
|
27036
27061
|
* 数据上报类
|
|
27037
27062
|
* 用于收集 MCP 工具使用情况和错误信息,帮助改进产品
|
|
@@ -27061,6 +27086,12 @@ class TelemetryReporter {
|
|
|
27061
27086
|
this.addAdditionalParams({ ide: process.env.INTEGRATION_IDE });
|
|
27062
27087
|
(0, logger_js_1.debug)('检测到 IDE 集成环境', { ide: process.env.INTEGRATION_IDE });
|
|
27063
27088
|
}
|
|
27089
|
+
// 检查 CLOUDBASE_MCP_CLIENT 环境变量(hosted 场景由上游解析真实 MCP client 后注入)
|
|
27090
|
+
const envClient = normalizeClientName(process.env.CLOUDBASE_MCP_CLIENT);
|
|
27091
|
+
if (envClient) {
|
|
27092
|
+
this.addAdditionalParams({ client: envClient });
|
|
27093
|
+
(0, logger_js_1.debug)('检测到 MCP client 标识', { client: envClient });
|
|
27094
|
+
}
|
|
27064
27095
|
(0, logger_js_1.debug)('report_init', {
|
|
27065
27096
|
enabled: this.enabled,
|
|
27066
27097
|
deviceId: this.deviceId.substring(0, 8) + '...',
|
|
@@ -27078,7 +27109,7 @@ class TelemetryReporter {
|
|
|
27078
27109
|
const arch = os_1.default.arch(); // 系统架构
|
|
27079
27110
|
// Build-time injected version; guard for vitest / non-webpack runtimes.
|
|
27080
27111
|
const mcpVersion = process.env.npm_package_version ||
|
|
27081
|
-
( true ? "2.33.
|
|
27112
|
+
( true ? "2.33.1" : 0);
|
|
27082
27113
|
return {
|
|
27083
27114
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
27084
27115
|
deviceId: this.deviceId,
|
|
@@ -27289,6 +27320,58 @@ function readMcpClientInfoFromServer(server) {
|
|
|
27289
27320
|
return {};
|
|
27290
27321
|
}
|
|
27291
27322
|
}
|
|
27323
|
+
/**
|
|
27324
|
+
* Normalize upstream-provided client identifier into a telemetry-safe token:
|
|
27325
|
+
* trim + lowercase + keep [a-z0-9-_] only + cap at 64 chars.
|
|
27326
|
+
* Canonical mapping (cursor-vscode -> cursor etc.) is the upstream's responsibility;
|
|
27327
|
+
* we only sanitize. Returns undefined when nothing usable remains.
|
|
27328
|
+
*/
|
|
27329
|
+
function normalizeClientName(value) {
|
|
27330
|
+
if (typeof value !== "string") {
|
|
27331
|
+
return undefined;
|
|
27332
|
+
}
|
|
27333
|
+
const cleaned = value
|
|
27334
|
+
.trim()
|
|
27335
|
+
.toLowerCase()
|
|
27336
|
+
.replace(/[^a-z0-9_-]/g, "")
|
|
27337
|
+
.slice(0, 64);
|
|
27338
|
+
return cleaned || undefined;
|
|
27339
|
+
}
|
|
27340
|
+
// 进程内缓存 site/region 解析结果(resolveSiteAndRegion 会读项目配置文件,避免每次工具调用都走 IO)
|
|
27341
|
+
let cachedSiteRegion = null;
|
|
27342
|
+
/**
|
|
27343
|
+
* Resolve region/site for telemetry.
|
|
27344
|
+
* Priority: cloudBaseOptions(会话实际使用值)> resolveSiteAndRegion(env/项目配置解析,进程内缓存)。
|
|
27345
|
+
* 失败时降级 unknown,绝不影响工具调用主链路。
|
|
27346
|
+
*/
|
|
27347
|
+
function resolveTelemetrySiteRegion(cloudBaseOptions) {
|
|
27348
|
+
const explicitRegion = cloudBaseOptions?.region;
|
|
27349
|
+
const explicitSite = (0, site_map_js_1.normalizeSite)(cloudBaseOptions?.site);
|
|
27350
|
+
try {
|
|
27351
|
+
if (!cachedSiteRegion) {
|
|
27352
|
+
const resolved = (0, site_map_js_1.resolveSiteAndRegion)();
|
|
27353
|
+
cachedSiteRegion = { site: resolved.site, region: resolved.region };
|
|
27354
|
+
}
|
|
27355
|
+
return {
|
|
27356
|
+
region: explicitRegion || cachedSiteRegion.region,
|
|
27357
|
+
site: explicitSite || cachedSiteRegion.site,
|
|
27358
|
+
};
|
|
27359
|
+
}
|
|
27360
|
+
catch (err) {
|
|
27361
|
+
(0, logger_js_1.debug)('解析 site/region 失败,遥测使用 unknown', err instanceof Error ? err : new Error(String(err)));
|
|
27362
|
+
return {
|
|
27363
|
+
region: explicitRegion || 'unknown',
|
|
27364
|
+
site: explicitSite || 'unknown',
|
|
27365
|
+
};
|
|
27366
|
+
}
|
|
27367
|
+
}
|
|
27368
|
+
/**
|
|
27369
|
+
* Resolve MCP client identifier for a single report:
|
|
27370
|
+
* explicit param (server.client) > CLOUDBASE_MCP_CLIENT env (hosted upstream injection).
|
|
27371
|
+
*/
|
|
27372
|
+
function resolveClientName(explicit) {
|
|
27373
|
+
return normalizeClientName(explicit || process.env.CLOUDBASE_MCP_CLIENT);
|
|
27374
|
+
}
|
|
27292
27375
|
function appendMcpClientInfoFields(eventData, clientInfo) {
|
|
27293
27376
|
if (!clientInfo) {
|
|
27294
27377
|
return;
|
|
@@ -27308,6 +27391,7 @@ const reportToolCall = async (params) => {
|
|
|
27308
27391
|
const { nodeVersion, osType, osRelease, arch, mcpVersion } = exports.telemetryReporter.getUserAgent();
|
|
27309
27392
|
// 安全获取环境ID,优先使用传入的配置
|
|
27310
27393
|
const { envId, envIdSource } = resolveEnvId(params.cloudBaseOptions);
|
|
27394
|
+
const siteRegion = resolveTelemetrySiteRegion(params.cloudBaseOptions);
|
|
27311
27395
|
(0, logger_js_1.debug)('[telemetry] 工具调用 envId 获取结果', {
|
|
27312
27396
|
toolName: params.toolName,
|
|
27313
27397
|
envId,
|
|
@@ -27323,6 +27407,8 @@ const reportToolCall = async (params) => {
|
|
|
27323
27407
|
duration: params.duration !== undefined ? String(params.duration) : undefined,
|
|
27324
27408
|
error: params.error ? params.error.substring(0, 200) : undefined, // 限制错误信息长度
|
|
27325
27409
|
envId: envId || 'unknown',
|
|
27410
|
+
region: siteRegion.region,
|
|
27411
|
+
site: siteRegion.site,
|
|
27326
27412
|
nodeVersion,
|
|
27327
27413
|
osType,
|
|
27328
27414
|
osRelease,
|
|
@@ -27347,6 +27433,11 @@ const reportToolCall = async (params) => {
|
|
|
27347
27433
|
if (params.ide) {
|
|
27348
27434
|
eventData.ide = params.ide;
|
|
27349
27435
|
}
|
|
27436
|
+
// 添加 MCP client 标识(如果提供)
|
|
27437
|
+
const client = resolveClientName(params.client);
|
|
27438
|
+
if (client) {
|
|
27439
|
+
eventData.client = client;
|
|
27440
|
+
}
|
|
27350
27441
|
appendMcpClientInfoFields(eventData, params.mcpClientInfo);
|
|
27351
27442
|
// Debug: 打印最终上报参数
|
|
27352
27443
|
(0, logger_js_1.debug)('[telemetry] 工具调用上报参数', {
|
|
@@ -27366,6 +27457,7 @@ const reportToolkitLifecycle = async (params) => {
|
|
|
27366
27457
|
const { nodeVersion, osType, osRelease, arch, mcpVersion } = exports.telemetryReporter.getUserAgent();
|
|
27367
27458
|
// 安全获取环境ID,优先使用传入的配置
|
|
27368
27459
|
const { envId, envIdSource } = resolveEnvId(params.cloudBaseOptions);
|
|
27460
|
+
const siteRegion = resolveTelemetrySiteRegion(params.cloudBaseOptions);
|
|
27369
27461
|
(0, logger_js_1.debug)('[telemetry] 生命周期事件 envId 获取结果', {
|
|
27370
27462
|
event: params.event,
|
|
27371
27463
|
envId,
|
|
@@ -27380,6 +27472,8 @@ const reportToolkitLifecycle = async (params) => {
|
|
|
27380
27472
|
exitCode: params.exitCode !== undefined ? String(params.exitCode) : undefined,
|
|
27381
27473
|
error: params.error ? params.error.substring(0, 200) : undefined, // 限制错误信息长度
|
|
27382
27474
|
envId: envId || 'unknown',
|
|
27475
|
+
region: siteRegion.region,
|
|
27476
|
+
site: siteRegion.site,
|
|
27383
27477
|
nodeVersion,
|
|
27384
27478
|
osType,
|
|
27385
27479
|
osRelease,
|
|
@@ -27390,6 +27484,11 @@ const reportToolkitLifecycle = async (params) => {
|
|
|
27390
27484
|
if (params.ide) {
|
|
27391
27485
|
eventData.ide = params.ide;
|
|
27392
27486
|
}
|
|
27487
|
+
// 添加 MCP client 标识(如果提供)
|
|
27488
|
+
const lifecycleClient = resolveClientName(params.client);
|
|
27489
|
+
if (lifecycleClient) {
|
|
27490
|
+
eventData.client = lifecycleClient;
|
|
27491
|
+
}
|
|
27393
27492
|
appendMcpClientInfoFields(eventData, params.mcpClientInfo);
|
|
27394
27493
|
// Debug: 打印最终上报参数
|
|
27395
27494
|
(0, logger_js_1.debug)('[telemetry] 生命周期事件上报参数', {
|
|
@@ -27602,7 +27701,7 @@ ${envIdSection}
|
|
|
27602
27701
|
## 环境信息
|
|
27603
27702
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
27604
27703
|
- Node.js版本: ${process.version}
|
|
27605
|
-
- MCP 版本:${process.env.npm_package_version || ( true ? "2.33.
|
|
27704
|
+
- MCP 版本:${process.env.npm_package_version || ( true ? "2.33.1" : 0)}
|
|
27606
27705
|
- 系统架构: ${os_1.default.arch()}
|
|
27607
27706
|
- 时间: ${new Date().toISOString()}
|
|
27608
27707
|
- 请求ID: ${requestId}
|
|
@@ -27691,7 +27790,7 @@ function createWrappedHandler(name, handler, server) {
|
|
|
27691
27790
|
requestId,
|
|
27692
27791
|
ide: server.ide || process.env.INTEGRATION_IDE || ''
|
|
27693
27792
|
});
|
|
27694
|
-
const mcpVersion = true ? "2.33.
|
|
27793
|
+
const mcpVersion = true ? "2.33.1" : 0;
|
|
27695
27794
|
const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
|
|
27696
27795
|
const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
|
|
27697
27796
|
// 创建新的错误对象,保持原有的错误类型但更新消息
|
|
@@ -27729,6 +27828,7 @@ function createWrappedHandler(name, handler, server) {
|
|
|
27729
27828
|
inputParams: sanitizeArgs(args), // 添加入参上报
|
|
27730
27829
|
cloudBaseOptions: cloudBaseOptions, // 传递 CloudBase 配置(可能已更新)
|
|
27731
27830
|
ide: server.ide || process.env.INTEGRATION_IDE, // 传递集成IDE信息
|
|
27831
|
+
client: server.client || process.env.CLOUDBASE_MCP_CLIENT, // 传递 MCP client 来源标识
|
|
27732
27832
|
mcpClientInfo: (0, telemetry_js_1.readMcpClientInfoFromServer)(server),
|
|
27733
27833
|
}).catch(err => {
|
|
27734
27834
|
// 静默处理上报错误,不影响主要功能
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cloudbase-mcp",
|
|
3
|
-
"version": "2.33.
|
|
3
|
+
"version": "2.33.1",
|
|
4
4
|
"mcpName": "io.github.TencentCloudBase/cloudbase-mcp",
|
|
5
5
|
"packageManager": "pnpm@10.8.0",
|
|
6
6
|
"description": "CloudBase MCP Server — operate Tencent CloudBase (database, auth, functions, storage, hosting) from AI coding tools via the Model Context Protocol. Part of CloudBase AI Toolkit.",
|