@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.cjs
CHANGED
|
@@ -199258,6 +199258,7 @@ exports.getAuthProgressState = getAuthProgressState;
|
|
|
199258
199258
|
exports.resolveAuthOptions = resolveAuthOptions;
|
|
199259
199259
|
exports.getAuthConfigValidationError = getAuthConfigValidationError;
|
|
199260
199260
|
exports.buildAuthConfigSummary = buildAuthConfigSummary;
|
|
199261
|
+
exports.buildDeviceLoginOptions = buildDeviceLoginOptions;
|
|
199261
199262
|
exports.setPendingAuthProgressState = setPendingAuthProgressState;
|
|
199262
199263
|
exports.resolveAuthProgressState = resolveAuthProgressState;
|
|
199263
199264
|
exports.rejectAuthProgressState = rejectAuthProgressState;
|
|
@@ -199476,9 +199477,10 @@ function getAuthConfigValidationError(options) {
|
|
|
199476
199477
|
if (options.oauthCustom && !options.oauthEndpoint) {
|
|
199477
199478
|
return "oauthCustom=true 时必须同时提供 oauthEndpoint。";
|
|
199478
199479
|
}
|
|
199479
|
-
|
|
199480
|
-
|
|
199481
|
-
}
|
|
199480
|
+
// oauthEndpoint + 显式 oauthCustom=false 放行:resolveAuthOptions 对"只配 endpoint
|
|
199481
|
+
// 未配 custom"已默认 custom=true,走到这里的 endpoint+false 只可能是用户显式指定——
|
|
199482
|
+
// 即标准 {code,result} 包装格式的自定义端点(如国际站 tcb-api.tencentcloud.com),
|
|
199483
|
+
// 拦截会导致标准格式端点在工具层永远不可用。
|
|
199482
199484
|
return null;
|
|
199483
199485
|
}
|
|
199484
199486
|
function buildAuthConfigSummary(options) {
|
|
@@ -199490,6 +199492,40 @@ function buildAuthConfigSummary(options) {
|
|
|
199490
199492
|
uses_toolbox_defaults: options.usesToolboxDefaults,
|
|
199491
199493
|
};
|
|
199492
199494
|
}
|
|
199495
|
+
/**
|
|
199496
|
+
* 构造 device flow 的 loginByWebAuth 基础参数(onDeviceCode 由调用方按需注入)。
|
|
199497
|
+
*
|
|
199498
|
+
* 所有 device 登录路径(ensureLogin 与 auth 工具 start_auth 的 device 分支)必须
|
|
199499
|
+
* 共享本函数:TCB_SITE=intl 时的 getOAuthEndpoint 覆写与 getAuthUrl 授权页改写
|
|
199500
|
+
* 只在 ensureLogin 生效,会导致工具层直连路径仍打国内站端点/授权页,国际站账号
|
|
199501
|
+
* 无法完成授权(device-code 注册表国内外隔离,国内授权页对国际站账号无效)。
|
|
199502
|
+
*/
|
|
199503
|
+
function buildDeviceLoginOptions(resolvedAuthOptions, siteHints = {}) {
|
|
199504
|
+
const resolvedSite = (0, site_map_js_1.resolveSite)(siteHints.region, siteHints.site ?? process.env.TCB_SITE);
|
|
199505
|
+
const loginOptions = { flow: "device" };
|
|
199506
|
+
if (resolvedAuthOptions.clientId) {
|
|
199507
|
+
loginOptions.client_id = resolvedAuthOptions.clientId;
|
|
199508
|
+
}
|
|
199509
|
+
if (resolvedAuthOptions.oauthEndpoint) {
|
|
199510
|
+
loginOptions.getOAuthEndpoint = () => resolvedAuthOptions.oauthEndpoint;
|
|
199511
|
+
}
|
|
199512
|
+
else if (resolvedSite === "intl") {
|
|
199513
|
+
// 国际站 OAuth 后端独立部署(2026-09-01 实测 device/code+token 可用,注册表与国内站隔离);
|
|
199514
|
+
// 不覆写时 toolbox 默认打国内站端点,国际站账号无法完成授权
|
|
199515
|
+
loginOptions.getOAuthEndpoint = () => site_map_js_1.SITE_REGION_MAP.intl.oauthEndpoint;
|
|
199516
|
+
}
|
|
199517
|
+
if (resolvedSite === "intl") {
|
|
199518
|
+
// device 模式的 verification_uri 标准模式下由客户端拼接,指向国内站授权页;
|
|
199519
|
+
// 与 web 模式同款 host 改写,把授权页切到国际站
|
|
199520
|
+
loginOptions.getAuthUrl = (url) => url
|
|
199521
|
+
.replace(`${site_map_js_1.SITE_REGION_MAP.domestic.authHost}/dev`, `${site_map_js_1.SITE_REGION_MAP.intl.authHost}/dev`)
|
|
199522
|
+
.replace(site_map_js_1.SITE_REGION_MAP.domestic.authHost, site_map_js_1.SITE_REGION_MAP.intl.authHost);
|
|
199523
|
+
}
|
|
199524
|
+
if (resolvedAuthOptions.oauthCustom) {
|
|
199525
|
+
loginOptions.custom = true;
|
|
199526
|
+
}
|
|
199527
|
+
return loginOptions;
|
|
199528
|
+
}
|
|
199493
199529
|
function setPendingAuthProgressState(challenge, authMode = "device") {
|
|
199494
199530
|
return updateAuthProgressState({
|
|
199495
199531
|
status: "PENDING",
|
|
@@ -199729,27 +199765,11 @@ async function ensureLogin(options) {
|
|
|
199729
199765
|
};
|
|
199730
199766
|
}
|
|
199731
199767
|
else {
|
|
199732
|
-
|
|
199733
|
-
|
|
199734
|
-
|
|
199735
|
-
|
|
199736
|
-
|
|
199737
|
-
}
|
|
199738
|
-
else if (resolvedSite === "intl") {
|
|
199739
|
-
// 国际站 OAuth 后端独立部署(2026-09-01 实测 device/code+token 可用,注册表与国内站隔离);
|
|
199740
|
-
// 不覆写时 toolbox 默认打国内站端点,国际站账号无法完成授权
|
|
199741
|
-
loginOptions.getOAuthEndpoint = () => site_map_js_1.SITE_REGION_MAP.intl.oauthEndpoint;
|
|
199742
|
-
}
|
|
199743
|
-
if (resolvedSite === "intl") {
|
|
199744
|
-
// device 模式的 verification_uri 标准模式下由客户端拼接,指向国内站授权页;
|
|
199745
|
-
// 与 web 模式同款 host 改写,把授权页切到国际站
|
|
199746
|
-
loginOptions.getAuthUrl = (url) => url
|
|
199747
|
-
.replace(`${site_map_js_1.SITE_REGION_MAP.domestic.authHost}/dev`, `${site_map_js_1.SITE_REGION_MAP.intl.authHost}/dev`)
|
|
199748
|
-
.replace(site_map_js_1.SITE_REGION_MAP.domestic.authHost, site_map_js_1.SITE_REGION_MAP.intl.authHost);
|
|
199749
|
-
}
|
|
199750
|
-
if (resolvedAuthOptions.oauthCustom) {
|
|
199751
|
-
loginOptions.custom = true;
|
|
199752
|
-
}
|
|
199768
|
+
// device 模式:与 auth 工具 start_auth device 分支共享 intl 端点覆写与授权页改写
|
|
199769
|
+
Object.assign(loginOptions, buildDeviceLoginOptions(resolvedAuthOptions, {
|
|
199770
|
+
region: options?.region,
|
|
199771
|
+
site: options?.site,
|
|
199772
|
+
}));
|
|
199753
199773
|
if (options?.onDeviceCode) {
|
|
199754
199774
|
loginOptions.onDeviceCode = (info) => {
|
|
199755
199775
|
setPendingAuthProgressState(info, mode);
|
|
@@ -201353,7 +201373,7 @@ async function getInteractiveServerAsync() {
|
|
|
201353
201373
|
"use strict";
|
|
201354
201374
|
|
|
201355
201375
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
201356
|
-
exports.telemetryReporter = exports.reportToolkitLifecycle = exports.reportToolCall = exports.warn = exports.info = exports.error = exports.StdioServerTransport = void 0;
|
|
201376
|
+
exports.normalizeClientName = exports.telemetryReporter = exports.reportToolkitLifecycle = exports.reportToolCall = exports.warn = exports.info = exports.error = exports.StdioServerTransport = void 0;
|
|
201357
201377
|
exports.createCloudBaseMcpServer = createCloudBaseMcpServer;
|
|
201358
201378
|
exports.getDefaultServer = getDefaultServer;
|
|
201359
201379
|
const mcp_js_1 = __webpack_require__(55375);
|
|
@@ -201384,6 +201404,7 @@ const logger_js_1 = __webpack_require__(40781);
|
|
|
201384
201404
|
const site_map_js_1 = __webpack_require__(34533);
|
|
201385
201405
|
const tool_result_js_1 = __webpack_require__(69645);
|
|
201386
201406
|
const tool_wrapper_js_1 = __webpack_require__(93389);
|
|
201407
|
+
const telemetry_js_1 = __webpack_require__(5198);
|
|
201387
201408
|
// 默认插件列表
|
|
201388
201409
|
const DEFAULT_PLUGINS = [
|
|
201389
201410
|
"env",
|
|
@@ -201527,7 +201548,7 @@ function parseEnabledPlugins(pluginsEnabled, pluginsDisabled) {
|
|
|
201527
201548
|
* await server.connect(transport);
|
|
201528
201549
|
*/
|
|
201529
201550
|
async function createCloudBaseMcpServer(options) {
|
|
201530
|
-
const { name = "cloudbase-mcp", version = "1.0.0", enableTelemetry = true, cloudBaseOptions, authOptions, cloudMode = false, ide, logger, pluginsEnabled, pluginsDisabled, pluginOptions, } = options ?? {};
|
|
201551
|
+
const { name = "cloudbase-mcp", version = "1.0.0", enableTelemetry = true, cloudBaseOptions, authOptions, cloudMode = false, ide, client, logger, pluginsEnabled, pluginsDisabled, pluginOptions, } = options ?? {};
|
|
201531
201552
|
// Enable cloud mode if specified
|
|
201532
201553
|
if (cloudMode) {
|
|
201533
201554
|
(0, cloud_mode_js_1.enableCloudMode)();
|
|
@@ -201590,6 +201611,11 @@ async function createCloudBaseMcpServer(options) {
|
|
|
201590
201611
|
if (ide) {
|
|
201591
201612
|
server.ide = ide;
|
|
201592
201613
|
}
|
|
201614
|
+
// Store client in server instance for telemetry (normalized, invalid values dropped)
|
|
201615
|
+
const normalizedClient = (0, telemetry_js_1.normalizeClientName)(client);
|
|
201616
|
+
if (normalizedClient) {
|
|
201617
|
+
server.client = normalizedClient;
|
|
201618
|
+
}
|
|
201593
201619
|
// Store logger in server instance for tools to access
|
|
201594
201620
|
if (logger) {
|
|
201595
201621
|
server.logger = logger;
|
|
@@ -201624,10 +201650,11 @@ var logger_js_2 = __webpack_require__(40781);
|
|
|
201624
201650
|
Object.defineProperty(exports, "error", ({ enumerable: true, get: function () { return logger_js_2.error; } }));
|
|
201625
201651
|
Object.defineProperty(exports, "info", ({ enumerable: true, get: function () { return logger_js_2.info; } }));
|
|
201626
201652
|
Object.defineProperty(exports, "warn", ({ enumerable: true, get: function () { return logger_js_2.warn; } }));
|
|
201627
|
-
var
|
|
201628
|
-
Object.defineProperty(exports, "reportToolCall", ({ enumerable: true, get: function () { return
|
|
201629
|
-
Object.defineProperty(exports, "reportToolkitLifecycle", ({ enumerable: true, get: function () { return
|
|
201630
|
-
Object.defineProperty(exports, "telemetryReporter", ({ enumerable: true, get: function () { return
|
|
201653
|
+
var telemetry_js_2 = __webpack_require__(5198);
|
|
201654
|
+
Object.defineProperty(exports, "reportToolCall", ({ enumerable: true, get: function () { return telemetry_js_2.reportToolCall; } }));
|
|
201655
|
+
Object.defineProperty(exports, "reportToolkitLifecycle", ({ enumerable: true, get: function () { return telemetry_js_2.reportToolkitLifecycle; } }));
|
|
201656
|
+
Object.defineProperty(exports, "telemetryReporter", ({ enumerable: true, get: function () { return telemetry_js_2.telemetryReporter; } }));
|
|
201657
|
+
Object.defineProperty(exports, "normalizeClientName", ({ enumerable: true, get: function () { return telemetry_js_2.normalizeClientName; } }));
|
|
201631
201658
|
|
|
201632
201659
|
|
|
201633
201660
|
/***/ },
|
|
@@ -213937,7 +213964,7 @@ function registerEnvTools(server) {
|
|
|
213937
213964
|
oauthCustom: zod_1.z
|
|
213938
213965
|
.boolean()
|
|
213939
213966
|
.optional()
|
|
213940
|
-
.describe("高级可选:自定义 endpoint 返回格式开关。未配置 endpoint 时默认 false;配置 endpoint 后默认 true
|
|
213967
|
+
.describe("高级可选:自定义 endpoint 返回格式开关。未配置 endpoint 时默认 false;配置 endpoint 后默认 true。标准 {code,result} 包装格式的端点(如国际站 tcb-api.tencentcloud.com)应显式传 false"),
|
|
213941
213968
|
}
|
|
213942
213969
|
: {}),
|
|
213943
213970
|
envId: zod_1.z
|
|
@@ -214182,19 +214209,15 @@ function registerEnvTools(server) {
|
|
|
214182
214209
|
}
|
|
214183
214210
|
};
|
|
214184
214211
|
try {
|
|
214185
|
-
// 启动 Device Flow,全流程由 toolbox 负责轮询和写入 credential
|
|
214212
|
+
// 启动 Device Flow,全流程由 toolbox 负责轮询和写入 credential,这里不等待完成。
|
|
214213
|
+
// 登录参数(含 TCB_SITE=intl 端点覆写与授权页改写)与 ensureLogin 共享同一 helper,
|
|
214214
|
+
// 避免此直连路径绕过国际站改写导致国际站账号拿到的仍是国内站链接
|
|
214186
214215
|
auth
|
|
214187
214216
|
.loginByWebAuth({
|
|
214188
|
-
|
|
214189
|
-
|
|
214190
|
-
|
|
214191
|
-
|
|
214192
|
-
...(resolvedAuthOptions.oauthEndpoint
|
|
214193
|
-
? { getOAuthEndpoint: () => resolvedAuthOptions.oauthEndpoint }
|
|
214194
|
-
: {}),
|
|
214195
|
-
...(resolvedAuthOptions.oauthCustom
|
|
214196
|
-
? { custom: true }
|
|
214197
|
-
: {}),
|
|
214217
|
+
...(0, auth_js_1.buildDeviceLoginOptions)(resolvedAuthOptions, {
|
|
214218
|
+
region,
|
|
214219
|
+
site: server.cloudBaseOptions?.site,
|
|
214220
|
+
}),
|
|
214198
214221
|
onDeviceCode: deviceOnCode,
|
|
214199
214222
|
})
|
|
214200
214223
|
.then(async () => {
|
|
@@ -224094,7 +224117,7 @@ function registerSetupTools(server) {
|
|
|
224094
224117
|
server.registerTool("downloadTemplate", {
|
|
224095
224118
|
title: "下载项目模板",
|
|
224096
224119
|
description: `自动下载并部署CloudBase项目模板。
|
|
224097
|
-
**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.
|
|
224120
|
+
**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)`,
|
|
224098
224121
|
inputSchema: {
|
|
224099
224122
|
template: zod_1.z
|
|
224100
224123
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
@@ -226323,12 +226346,14 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
226323
226346
|
exports.reportToolkitLifecycle = exports.reportToolCall = exports.telemetryReporter = void 0;
|
|
226324
226347
|
exports.extractMcpClientInfo = extractMcpClientInfo;
|
|
226325
226348
|
exports.readMcpClientInfoFromServer = readMcpClientInfoFromServer;
|
|
226349
|
+
exports.normalizeClientName = normalizeClientName;
|
|
226326
226350
|
const crypto_1 = __importDefault(__webpack_require__(55511));
|
|
226327
226351
|
const http_1 = __importDefault(__webpack_require__(81630));
|
|
226328
226352
|
const https_1 = __importDefault(__webpack_require__(55591));
|
|
226329
226353
|
const os_1 = __importDefault(__webpack_require__(21820));
|
|
226330
226354
|
const cloudbase_manager_js_1 = __webpack_require__(33109);
|
|
226331
226355
|
const logger_js_1 = __webpack_require__(40781);
|
|
226356
|
+
const site_map_js_1 = __webpack_require__(34533);
|
|
226332
226357
|
/**
|
|
226333
226358
|
* 数据上报类
|
|
226334
226359
|
* 用于收集 MCP 工具使用情况和错误信息,帮助改进产品
|
|
@@ -226358,6 +226383,12 @@ class TelemetryReporter {
|
|
|
226358
226383
|
this.addAdditionalParams({ ide: process.env.INTEGRATION_IDE });
|
|
226359
226384
|
(0, logger_js_1.debug)('检测到 IDE 集成环境', { ide: process.env.INTEGRATION_IDE });
|
|
226360
226385
|
}
|
|
226386
|
+
// 检查 CLOUDBASE_MCP_CLIENT 环境变量(hosted 场景由上游解析真实 MCP client 后注入)
|
|
226387
|
+
const envClient = normalizeClientName(process.env.CLOUDBASE_MCP_CLIENT);
|
|
226388
|
+
if (envClient) {
|
|
226389
|
+
this.addAdditionalParams({ client: envClient });
|
|
226390
|
+
(0, logger_js_1.debug)('检测到 MCP client 标识', { client: envClient });
|
|
226391
|
+
}
|
|
226361
226392
|
(0, logger_js_1.debug)('report_init', {
|
|
226362
226393
|
enabled: this.enabled,
|
|
226363
226394
|
deviceId: this.deviceId.substring(0, 8) + '...',
|
|
@@ -226375,7 +226406,7 @@ class TelemetryReporter {
|
|
|
226375
226406
|
const arch = os_1.default.arch(); // 系统架构
|
|
226376
226407
|
// Build-time injected version; guard for vitest / non-webpack runtimes.
|
|
226377
226408
|
const mcpVersion = process.env.npm_package_version ||
|
|
226378
|
-
( true ? "2.33.
|
|
226409
|
+
( true ? "2.33.1" : 0);
|
|
226379
226410
|
return {
|
|
226380
226411
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
226381
226412
|
deviceId: this.deviceId,
|
|
@@ -226586,6 +226617,58 @@ function readMcpClientInfoFromServer(server) {
|
|
|
226586
226617
|
return {};
|
|
226587
226618
|
}
|
|
226588
226619
|
}
|
|
226620
|
+
/**
|
|
226621
|
+
* Normalize upstream-provided client identifier into a telemetry-safe token:
|
|
226622
|
+
* trim + lowercase + keep [a-z0-9-_] only + cap at 64 chars.
|
|
226623
|
+
* Canonical mapping (cursor-vscode -> cursor etc.) is the upstream's responsibility;
|
|
226624
|
+
* we only sanitize. Returns undefined when nothing usable remains.
|
|
226625
|
+
*/
|
|
226626
|
+
function normalizeClientName(value) {
|
|
226627
|
+
if (typeof value !== "string") {
|
|
226628
|
+
return undefined;
|
|
226629
|
+
}
|
|
226630
|
+
const cleaned = value
|
|
226631
|
+
.trim()
|
|
226632
|
+
.toLowerCase()
|
|
226633
|
+
.replace(/[^a-z0-9_-]/g, "")
|
|
226634
|
+
.slice(0, 64);
|
|
226635
|
+
return cleaned || undefined;
|
|
226636
|
+
}
|
|
226637
|
+
// 进程内缓存 site/region 解析结果(resolveSiteAndRegion 会读项目配置文件,避免每次工具调用都走 IO)
|
|
226638
|
+
let cachedSiteRegion = null;
|
|
226639
|
+
/**
|
|
226640
|
+
* Resolve region/site for telemetry.
|
|
226641
|
+
* Priority: cloudBaseOptions(会话实际使用值)> resolveSiteAndRegion(env/项目配置解析,进程内缓存)。
|
|
226642
|
+
* 失败时降级 unknown,绝不影响工具调用主链路。
|
|
226643
|
+
*/
|
|
226644
|
+
function resolveTelemetrySiteRegion(cloudBaseOptions) {
|
|
226645
|
+
const explicitRegion = cloudBaseOptions?.region;
|
|
226646
|
+
const explicitSite = (0, site_map_js_1.normalizeSite)(cloudBaseOptions?.site);
|
|
226647
|
+
try {
|
|
226648
|
+
if (!cachedSiteRegion) {
|
|
226649
|
+
const resolved = (0, site_map_js_1.resolveSiteAndRegion)();
|
|
226650
|
+
cachedSiteRegion = { site: resolved.site, region: resolved.region };
|
|
226651
|
+
}
|
|
226652
|
+
return {
|
|
226653
|
+
region: explicitRegion || cachedSiteRegion.region,
|
|
226654
|
+
site: explicitSite || cachedSiteRegion.site,
|
|
226655
|
+
};
|
|
226656
|
+
}
|
|
226657
|
+
catch (err) {
|
|
226658
|
+
(0, logger_js_1.debug)('解析 site/region 失败,遥测使用 unknown', err instanceof Error ? err : new Error(String(err)));
|
|
226659
|
+
return {
|
|
226660
|
+
region: explicitRegion || 'unknown',
|
|
226661
|
+
site: explicitSite || 'unknown',
|
|
226662
|
+
};
|
|
226663
|
+
}
|
|
226664
|
+
}
|
|
226665
|
+
/**
|
|
226666
|
+
* Resolve MCP client identifier for a single report:
|
|
226667
|
+
* explicit param (server.client) > CLOUDBASE_MCP_CLIENT env (hosted upstream injection).
|
|
226668
|
+
*/
|
|
226669
|
+
function resolveClientName(explicit) {
|
|
226670
|
+
return normalizeClientName(explicit || process.env.CLOUDBASE_MCP_CLIENT);
|
|
226671
|
+
}
|
|
226589
226672
|
function appendMcpClientInfoFields(eventData, clientInfo) {
|
|
226590
226673
|
if (!clientInfo) {
|
|
226591
226674
|
return;
|
|
@@ -226605,6 +226688,7 @@ const reportToolCall = async (params) => {
|
|
|
226605
226688
|
const { nodeVersion, osType, osRelease, arch, mcpVersion } = exports.telemetryReporter.getUserAgent();
|
|
226606
226689
|
// 安全获取环境ID,优先使用传入的配置
|
|
226607
226690
|
const { envId, envIdSource } = resolveEnvId(params.cloudBaseOptions);
|
|
226691
|
+
const siteRegion = resolveTelemetrySiteRegion(params.cloudBaseOptions);
|
|
226608
226692
|
(0, logger_js_1.debug)('[telemetry] 工具调用 envId 获取结果', {
|
|
226609
226693
|
toolName: params.toolName,
|
|
226610
226694
|
envId,
|
|
@@ -226620,6 +226704,8 @@ const reportToolCall = async (params) => {
|
|
|
226620
226704
|
duration: params.duration !== undefined ? String(params.duration) : undefined,
|
|
226621
226705
|
error: params.error ? params.error.substring(0, 200) : undefined, // 限制错误信息长度
|
|
226622
226706
|
envId: envId || 'unknown',
|
|
226707
|
+
region: siteRegion.region,
|
|
226708
|
+
site: siteRegion.site,
|
|
226623
226709
|
nodeVersion,
|
|
226624
226710
|
osType,
|
|
226625
226711
|
osRelease,
|
|
@@ -226644,6 +226730,11 @@ const reportToolCall = async (params) => {
|
|
|
226644
226730
|
if (params.ide) {
|
|
226645
226731
|
eventData.ide = params.ide;
|
|
226646
226732
|
}
|
|
226733
|
+
// 添加 MCP client 标识(如果提供)
|
|
226734
|
+
const client = resolveClientName(params.client);
|
|
226735
|
+
if (client) {
|
|
226736
|
+
eventData.client = client;
|
|
226737
|
+
}
|
|
226647
226738
|
appendMcpClientInfoFields(eventData, params.mcpClientInfo);
|
|
226648
226739
|
// Debug: 打印最终上报参数
|
|
226649
226740
|
(0, logger_js_1.debug)('[telemetry] 工具调用上报参数', {
|
|
@@ -226663,6 +226754,7 @@ const reportToolkitLifecycle = async (params) => {
|
|
|
226663
226754
|
const { nodeVersion, osType, osRelease, arch, mcpVersion } = exports.telemetryReporter.getUserAgent();
|
|
226664
226755
|
// 安全获取环境ID,优先使用传入的配置
|
|
226665
226756
|
const { envId, envIdSource } = resolveEnvId(params.cloudBaseOptions);
|
|
226757
|
+
const siteRegion = resolveTelemetrySiteRegion(params.cloudBaseOptions);
|
|
226666
226758
|
(0, logger_js_1.debug)('[telemetry] 生命周期事件 envId 获取结果', {
|
|
226667
226759
|
event: params.event,
|
|
226668
226760
|
envId,
|
|
@@ -226677,6 +226769,8 @@ const reportToolkitLifecycle = async (params) => {
|
|
|
226677
226769
|
exitCode: params.exitCode !== undefined ? String(params.exitCode) : undefined,
|
|
226678
226770
|
error: params.error ? params.error.substring(0, 200) : undefined, // 限制错误信息长度
|
|
226679
226771
|
envId: envId || 'unknown',
|
|
226772
|
+
region: siteRegion.region,
|
|
226773
|
+
site: siteRegion.site,
|
|
226680
226774
|
nodeVersion,
|
|
226681
226775
|
osType,
|
|
226682
226776
|
osRelease,
|
|
@@ -226687,6 +226781,11 @@ const reportToolkitLifecycle = async (params) => {
|
|
|
226687
226781
|
if (params.ide) {
|
|
226688
226782
|
eventData.ide = params.ide;
|
|
226689
226783
|
}
|
|
226784
|
+
// 添加 MCP client 标识(如果提供)
|
|
226785
|
+
const lifecycleClient = resolveClientName(params.client);
|
|
226786
|
+
if (lifecycleClient) {
|
|
226787
|
+
eventData.client = lifecycleClient;
|
|
226788
|
+
}
|
|
226690
226789
|
appendMcpClientInfoFields(eventData, params.mcpClientInfo);
|
|
226691
226790
|
// Debug: 打印最终上报参数
|
|
226692
226791
|
(0, logger_js_1.debug)('[telemetry] 生命周期事件上报参数', {
|
|
@@ -226900,7 +226999,7 @@ ${envIdSection}
|
|
|
226900
226999
|
## 环境信息
|
|
226901
227000
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
226902
227001
|
- Node.js版本: ${process.version}
|
|
226903
|
-
- MCP 版本:${process.env.npm_package_version || ( true ? "2.33.
|
|
227002
|
+
- MCP 版本:${process.env.npm_package_version || ( true ? "2.33.1" : 0)}
|
|
226904
227003
|
- 系统架构: ${os_1.default.arch()}
|
|
226905
227004
|
- 时间: ${new Date().toISOString()}
|
|
226906
227005
|
- 请求ID: ${requestId}
|
|
@@ -226989,7 +227088,7 @@ function createWrappedHandler(name, handler, server) {
|
|
|
226989
227088
|
requestId,
|
|
226990
227089
|
ide: server.ide || process.env.INTEGRATION_IDE || ''
|
|
226991
227090
|
});
|
|
226992
|
-
const mcpVersion = true ? "2.33.
|
|
227091
|
+
const mcpVersion = true ? "2.33.1" : 0;
|
|
226993
227092
|
const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
|
|
226994
227093
|
const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
|
|
226995
227094
|
// 创建新的错误对象,保持原有的错误类型但更新消息
|
|
@@ -227027,6 +227126,7 @@ function createWrappedHandler(name, handler, server) {
|
|
|
227027
227126
|
inputParams: sanitizeArgs(args), // 添加入参上报
|
|
227028
227127
|
cloudBaseOptions: cloudBaseOptions, // 传递 CloudBase 配置(可能已更新)
|
|
227029
227128
|
ide: server.ide || process.env.INTEGRATION_IDE, // 传递集成IDE信息
|
|
227129
|
+
client: server.client || process.env.CLOUDBASE_MCP_CLIENT, // 传递 MCP client 来源标识
|
|
227030
227130
|
mcpClientInfo: (0, telemetry_js_1.readMcpClientInfoFromServer)(server),
|
|
227031
227131
|
}).catch(err => {
|
|
227032
227132
|
// 静默处理上报错误,不影响主要功能
|
package/dist/index.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ export declare function createCloudBaseMcpServer(options?: {
|
|
|
98
98
|
authOptions?: AuthOptions;
|
|
99
99
|
cloudMode?: boolean;
|
|
100
100
|
ide?: string;
|
|
101
|
+
client?: string;
|
|
101
102
|
logger?: Logger;
|
|
102
103
|
pluginsEnabled?: string[];
|
|
103
104
|
pluginsDisabled?: string[];
|
|
@@ -190,6 +191,8 @@ export declare interface ExtendedMcpServer extends McpServer {
|
|
|
190
191
|
cloudBaseOptions?: CloudBaseOptions;
|
|
191
192
|
authOptions?: AuthOptions;
|
|
192
193
|
ide?: string;
|
|
194
|
+
/** MCP client 来源标识(hosted 场景由上游解析注入,如 cursor / claude-code) */
|
|
195
|
+
client?: string;
|
|
193
196
|
logger?: Logger;
|
|
194
197
|
enabledPlugins?: string[];
|
|
195
198
|
pluginOptions?: PluginOptions;
|
|
@@ -452,6 +455,7 @@ export declare const reportToolCall: (params: {
|
|
|
452
455
|
inputParams?: any;
|
|
453
456
|
cloudBaseOptions?: CloudBaseOptions;
|
|
454
457
|
ide?: string;
|
|
458
|
+
client?: string;
|
|
455
459
|
mcpClientInfo?: McpClientInfo;
|
|
456
460
|
}) => Promise<void>;
|
|
457
461
|
|
|
@@ -462,6 +466,7 @@ export declare const reportToolkitLifecycle: (params: {
|
|
|
462
466
|
error?: string;
|
|
463
467
|
cloudBaseOptions?: CloudBaseOptions;
|
|
464
468
|
ide?: string;
|
|
469
|
+
client?: string;
|
|
465
470
|
mcpClientInfo?: McpClientInfo;
|
|
466
471
|
}) => Promise<void>;
|
|
467
472
|
|