@cloudbase/cloudbase-mcp 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/cli.cjs +3 -3
- package/dist/index.cjs +130 -52
- package/dist/index.js +129 -52
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -142,7 +142,7 @@ function registerEnvTools(server) {
|
|
|
142
142
|
// Get CLAUDE.md prompt content (skip for CodeBuddy IDE)
|
|
143
143
|
let promptContent = "";
|
|
144
144
|
const currentIde = server.ide || process.env.INTEGRATION_IDE;
|
|
145
|
-
if (currentIde !== "CodeBuddy") {
|
|
145
|
+
if (currentIde !== "CodeBuddy" && process.env.CLOUDBASE_GUIDE_PROMPT !== "false") {
|
|
146
146
|
try {
|
|
147
147
|
promptContent = await (0, rag_js_1.getClaudePrompt)();
|
|
148
148
|
}
|
|
@@ -245,7 +245,7 @@ function registerEnvTools(server) {
|
|
|
245
245
|
});
|
|
246
246
|
// Use commonService to call DescribeEnvs with filter parameters
|
|
247
247
|
// Filter parameters match the reference conditions provided by user
|
|
248
|
-
result = await cloudbaseList.commonService("tcb").call({
|
|
248
|
+
result = await cloudbaseList.commonService("tcb", "2018-06-08").call({
|
|
249
249
|
Action: "DescribeEnvs",
|
|
250
250
|
Param: {
|
|
251
251
|
EnvTypes: ["weda", "baas"], // Include weda and baas (normal) environments
|
|
@@ -328,7 +328,7 @@ function registerEnvTools(server) {
|
|
|
328
328
|
let responseText = JSON.stringify(result, null, 2);
|
|
329
329
|
// For info action, append CLAUDE.md prompt content (skip for CodeBuddy IDE)
|
|
330
330
|
const currentIde = server.ide || process.env.INTEGRATION_IDE;
|
|
331
|
-
if (action === "info" && currentIde !== "CodeBuddy") {
|
|
331
|
+
if (action === "info" && currentIde !== "CodeBuddy" && process.env.CLOUDBASE_GUIDE_PROMPT !== "false") {
|
|
332
332
|
try {
|
|
333
333
|
const promptContent = await (0, rag_js_1.getClaudePrompt)();
|
|
334
334
|
if (promptContent) {
|
|
@@ -431,7 +431,6 @@ const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
|
431
431
|
const CATEGORY = "cloud-api";
|
|
432
432
|
const ALLOWED_SERVICES = [
|
|
433
433
|
"tcb",
|
|
434
|
-
"flexdb",
|
|
435
434
|
"scf",
|
|
436
435
|
"sts",
|
|
437
436
|
"cam",
|
|
@@ -454,7 +453,7 @@ function registerCapiTools(server) {
|
|
|
454
453
|
inputSchema: {
|
|
455
454
|
service: zod_1.z
|
|
456
455
|
.enum(ALLOWED_SERVICES)
|
|
457
|
-
.describe("选择要访问的服务,必须先查看规则/技能确认是否可用。可选:tcb、
|
|
456
|
+
.describe("选择要访问的服务,必须先查看规则/技能确认是否可用。可选:tcb、scf、sts、cam、lowcode、cdn、vpc。"),
|
|
458
457
|
action: zod_1.z
|
|
459
458
|
.string()
|
|
460
459
|
.min(1)
|
|
@@ -563,7 +562,7 @@ ${envIdSection}
|
|
|
563
562
|
## 环境信息
|
|
564
563
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
565
564
|
- Node.js版本: ${process.version}
|
|
566
|
-
- MCP 版本:${process.env.npm_package_version || "2.
|
|
565
|
+
- MCP 版本:${process.env.npm_package_version || "2.9.0" || 0}
|
|
567
566
|
- 系统架构: ${os_1.default.arch()}
|
|
568
567
|
- 时间: ${new Date().toISOString()}
|
|
569
568
|
- 请求ID: ${requestId}
|
|
@@ -773,6 +772,7 @@ const invite_code_js_1 = __webpack_require__(4760);
|
|
|
773
772
|
const security_rule_js_1 = __webpack_require__(7862);
|
|
774
773
|
const cloud_mode_js_1 = __webpack_require__(9684);
|
|
775
774
|
const logger_js_1 = __webpack_require__(3039);
|
|
775
|
+
const tencet_cloud_js_1 = __webpack_require__(5018);
|
|
776
776
|
const tool_wrapper_js_1 = __webpack_require__(1363);
|
|
777
777
|
// 默认插件列表
|
|
778
778
|
const DEFAULT_PLUGINS = [
|
|
@@ -792,7 +792,11 @@ const DEFAULT_PLUGINS = [
|
|
|
792
792
|
"capi",
|
|
793
793
|
];
|
|
794
794
|
function registerDatabase(server) {
|
|
795
|
-
|
|
795
|
+
// Skip NoSQL database tools for international region (Singapore) as it doesn't support NoSQL DB
|
|
796
|
+
const region = server.cloudBaseOptions?.region || process.env.TCB_REGION;
|
|
797
|
+
if (!(0, tencet_cloud_js_1.isInternationalRegion)(region)) {
|
|
798
|
+
(0, databaseNoSQL_js_1.registerDatabaseTools)(server);
|
|
799
|
+
}
|
|
796
800
|
(0, databaseSQL_js_1.registerSQLDatabaseTools)(server);
|
|
797
801
|
(0, dataModel_js_1.registerDataModelTools)(server);
|
|
798
802
|
}
|
|
@@ -1197,7 +1201,7 @@ class InteractiveServer {
|
|
|
1197
1201
|
IsVisible: false,
|
|
1198
1202
|
Channels: ["dcloud", "iotenable", "tem", "scene_module"],
|
|
1199
1203
|
};
|
|
1200
|
-
envResult = await sessionData.manager.commonService("tcb").call({
|
|
1204
|
+
envResult = await sessionData.manager.commonService("tcb", "2018-06-08").call({
|
|
1201
1205
|
Action: "DescribeEnvs",
|
|
1202
1206
|
Param: queryParams,
|
|
1203
1207
|
});
|
|
@@ -4227,7 +4231,10 @@ async function getCloudBaseManager(options = {}) {
|
|
|
4227
4231
|
return createCloudBaseManagerWithOptions(cloudBaseOptions);
|
|
4228
4232
|
}
|
|
4229
4233
|
try {
|
|
4230
|
-
|
|
4234
|
+
// Get region from environment variable for auth URL
|
|
4235
|
+
// Note: At this point, cloudBaseOptions is undefined (checked above), so only use env var
|
|
4236
|
+
const region = process.env.TCB_REGION;
|
|
4237
|
+
const loginState = await (0, auth_js_1.getLoginState)({ region });
|
|
4231
4238
|
const { envId: loginEnvId, secretId, secretKey, token } = loginState;
|
|
4232
4239
|
let finalEnvId;
|
|
4233
4240
|
if (requireEnvId) {
|
|
@@ -4252,12 +4259,17 @@ async function getCloudBaseManager(options = {}) {
|
|
|
4252
4259
|
}
|
|
4253
4260
|
// envId priority: envManager.cachedEnvId > envManager.getEnvId() > loginState.envId > undefined
|
|
4254
4261
|
// Note: envManager.cachedEnvId has highest priority as it reflects user's latest environment switch
|
|
4262
|
+
// Region priority: process.env.TCB_REGION > undefined (use SDK default)
|
|
4263
|
+
// At this point, cloudBaseOptions is undefined (checked above), so only use env var if present
|
|
4264
|
+
// Reuse region variable declared above (line 259) for CloudBase initialization
|
|
4255
4265
|
const manager = new manager_node_1.default({
|
|
4256
4266
|
secretId,
|
|
4257
4267
|
secretKey,
|
|
4258
4268
|
envId: finalEnvId || loginEnvId,
|
|
4259
4269
|
token,
|
|
4260
4270
|
proxy: process.env.http_proxy,
|
|
4271
|
+
region,
|
|
4272
|
+
// REGION 国际站需要指定 region
|
|
4261
4273
|
});
|
|
4262
4274
|
return manager;
|
|
4263
4275
|
}
|
|
@@ -4267,15 +4279,18 @@ async function getCloudBaseManager(options = {}) {
|
|
|
4267
4279
|
}
|
|
4268
4280
|
}
|
|
4269
4281
|
/**
|
|
4270
|
-
*
|
|
4271
|
-
* @param cloudBaseOptions
|
|
4272
|
-
* @returns CloudBase manager
|
|
4282
|
+
* Create a manager with the provided CloudBase options, without using cache
|
|
4283
|
+
* @param cloudBaseOptions Provided CloudBase options
|
|
4284
|
+
* @returns CloudBase manager instance
|
|
4273
4285
|
*/
|
|
4274
4286
|
function createCloudBaseManagerWithOptions(cloudBaseOptions) {
|
|
4275
|
-
(0, logger_js_1.debug)('
|
|
4287
|
+
(0, logger_js_1.debug)('Create manager with provided CloudBase options:', cloudBaseOptions);
|
|
4288
|
+
// Region priority: cloudBaseOptions.region > process.env.TCB_REGION > undefined (use SDK default)
|
|
4289
|
+
const region = cloudBaseOptions.region ?? process.env.TCB_REGION ?? undefined;
|
|
4276
4290
|
const manager = new manager_node_1.default({
|
|
4277
4291
|
...cloudBaseOptions,
|
|
4278
4292
|
proxy: cloudBaseOptions.proxy || process.env.http_proxy,
|
|
4293
|
+
region
|
|
4279
4294
|
});
|
|
4280
4295
|
return manager;
|
|
4281
4296
|
}
|
|
@@ -4484,9 +4499,14 @@ async function _promptAndSetEnvironmentId(autoSelectSingle, options) {
|
|
|
4484
4499
|
}
|
|
4485
4500
|
// 1. 确保用户已登录
|
|
4486
4501
|
(0, logger_js_1.debug)("[interactive] Step 1: Checking login state...");
|
|
4502
|
+
// Get region from server options or environment variable for auth URL
|
|
4503
|
+
// Note: serverCloudBaseOptions will be declared later (line 282), so we get it here first
|
|
4504
|
+
const serverCloudBaseOptionsForAuth = server?.cloudBaseOptions;
|
|
4505
|
+
const region = serverCloudBaseOptionsForAuth?.region || process.env.TCB_REGION;
|
|
4487
4506
|
const loginState = await (0, auth_js_1.getLoginState)({
|
|
4488
4507
|
fromCloudBaseLoginPage: options?.loginFromCloudBaseLoginPage,
|
|
4489
4508
|
ignoreEnvVars: options?.ignoreEnvVars,
|
|
4509
|
+
region,
|
|
4490
4510
|
});
|
|
4491
4511
|
(0, logger_js_1.debug)("[interactive] Login state:", {
|
|
4492
4512
|
hasLoginState: !!loginState,
|
|
@@ -4518,6 +4538,14 @@ async function _promptAndSetEnvironmentId(autoSelectSingle, options) {
|
|
|
4518
4538
|
cloudBaseOptions: serverCloudBaseOptions,
|
|
4519
4539
|
});
|
|
4520
4540
|
(0, logger_js_1.debug)("[interactive] CloudBase manager obtained");
|
|
4541
|
+
// If envId is already set, return directly
|
|
4542
|
+
const envId = serverCloudBaseOptions?.envId || process.env.CLOUDBASE_ENV_ID;
|
|
4543
|
+
if (envId) {
|
|
4544
|
+
return {
|
|
4545
|
+
selectedEnvId: envId,
|
|
4546
|
+
cancelled: false,
|
|
4547
|
+
};
|
|
4548
|
+
}
|
|
4521
4549
|
// Step 2.1: Check and initialize TCB service if needed
|
|
4522
4550
|
// Check if retry is requested (from interactive server session data)
|
|
4523
4551
|
// Ensure server is resolved if it's a Promise (CLI mode)
|
|
@@ -4591,7 +4619,7 @@ async function _promptAndSetEnvironmentId(autoSelectSingle, options) {
|
|
|
4591
4619
|
let queryEnvSuccess = false;
|
|
4592
4620
|
let queryEnvError;
|
|
4593
4621
|
try {
|
|
4594
|
-
// Use
|
|
4622
|
+
// Use Service to call DescribeEnvs with filter parameters
|
|
4595
4623
|
// Filter parameters match the reference conditions provided by user
|
|
4596
4624
|
const queryParams = {
|
|
4597
4625
|
EnvTypes: ["weda", "baas"], // Include weda and baas (normal) environments
|
|
@@ -4599,7 +4627,7 @@ async function _promptAndSetEnvironmentId(autoSelectSingle, options) {
|
|
|
4599
4627
|
Channels: ["dcloud", "iotenable", "tem", "scene_module"], // Filter special channels
|
|
4600
4628
|
};
|
|
4601
4629
|
(0, logger_js_1.debug)("[interactive] DescribeEnvs params:", queryParams);
|
|
4602
|
-
envResult = await cloudbase.commonService("tcb").call({
|
|
4630
|
+
envResult = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
4603
4631
|
Action: "DescribeEnvs",
|
|
4604
4632
|
Param: queryParams,
|
|
4605
4633
|
});
|
|
@@ -4727,7 +4755,7 @@ async function _promptAndSetEnvironmentId(autoSelectSingle, options) {
|
|
|
4727
4755
|
// Sometimes creation is async and env might not be immediately available
|
|
4728
4756
|
(0, logger_js_1.debug)("[interactive] Verifying created environment exists in list...");
|
|
4729
4757
|
try {
|
|
4730
|
-
const verifyResult = await cloudbase.commonService("tcb").call({
|
|
4758
|
+
const verifyResult = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
4731
4759
|
Action: "DescribeEnvs",
|
|
4732
4760
|
Param: {
|
|
4733
4761
|
EnvTypes: ["weda", "baas"],
|
|
@@ -4912,6 +4940,15 @@ async function _promptAndSetEnvironmentId(autoSelectSingle, options) {
|
|
|
4912
4940
|
accountInfo.uin = String(loginState.uin);
|
|
4913
4941
|
(0, logger_js_1.debug)("[interactive] Using UIN from loginState:", { uin: accountInfo.uin });
|
|
4914
4942
|
}
|
|
4943
|
+
// Attach region from server options or environment variable fallback
|
|
4944
|
+
// Reuse serverCloudBaseOptions declared earlier (line 278)
|
|
4945
|
+
const currentServerCloudBaseOptions = server?.cloudBaseOptions;
|
|
4946
|
+
if (currentServerCloudBaseOptions?.region) {
|
|
4947
|
+
accountInfo.region = currentServerCloudBaseOptions.region;
|
|
4948
|
+
}
|
|
4949
|
+
else if (process.env.TCB_REGION) {
|
|
4950
|
+
accountInfo.region = process.env.TCB_REGION;
|
|
4951
|
+
}
|
|
4915
4952
|
// Report display_env_selection event
|
|
4916
4953
|
await telemetry_js_1.telemetryReporter.report('toolkit_env_setup', {
|
|
4917
4954
|
step: 'display_env_selection',
|
|
@@ -5354,8 +5391,8 @@ updateCollection: 更新集合`),
|
|
|
5354
5391
|
const instanceId = await getDatabaseInstanceId(getManager);
|
|
5355
5392
|
// 兼容对象和字符串
|
|
5356
5393
|
const toJSONString = (v) => typeof v === "object" && v !== null ? JSON.stringify(v) : v;
|
|
5357
|
-
const result = await cloudbase.commonService("
|
|
5358
|
-
Action: "
|
|
5394
|
+
const result = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
5395
|
+
Action: "QueryRecords",
|
|
5359
5396
|
Param: {
|
|
5360
5397
|
TableName: collectionName,
|
|
5361
5398
|
MgoQuery: toJSONString(query),
|
|
@@ -5509,7 +5546,7 @@ async function insertDocuments({ collectionName, documents, getManager, logger,
|
|
|
5509
5546
|
const instanceId = await getDatabaseInstanceId(getManager);
|
|
5510
5547
|
// 将对象数组序列化为字符串数组
|
|
5511
5548
|
const docsAsStrings = documents.map((doc) => JSON.stringify(doc));
|
|
5512
|
-
const result = await cloudbase.commonService("
|
|
5549
|
+
const result = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
5513
5550
|
Action: "PutItem",
|
|
5514
5551
|
Param: {
|
|
5515
5552
|
TableName: collectionName,
|
|
@@ -5538,7 +5575,7 @@ async function updateDocuments({ collectionName, query, update, isMulti, upsert,
|
|
|
5538
5575
|
const cloudbase = await getManager();
|
|
5539
5576
|
const instanceId = await getDatabaseInstanceId(getManager);
|
|
5540
5577
|
const toJSONString = (v) => typeof v === "object" && v !== null ? JSON.stringify(v) : v;
|
|
5541
|
-
const result = await cloudbase.commonService("
|
|
5578
|
+
const result = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
5542
5579
|
Action: "UpdateItem",
|
|
5543
5580
|
Param: {
|
|
5544
5581
|
TableName: collectionName,
|
|
@@ -5572,7 +5609,7 @@ async function deleteDocuments({ collectionName, query, isMulti, getManager, log
|
|
|
5572
5609
|
const cloudbase = await getManager();
|
|
5573
5610
|
const instanceId = await getDatabaseInstanceId(getManager);
|
|
5574
5611
|
const toJSONString = (v) => typeof v === "object" && v !== null ? JSON.stringify(v) : v;
|
|
5575
|
-
const result = await cloudbase.commonService("
|
|
5612
|
+
const result = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
5576
5613
|
Action: "DeleteItem",
|
|
5577
5614
|
Param: {
|
|
5578
5615
|
TableName: collectionName,
|
|
@@ -6148,12 +6185,12 @@ function registerDataModelTools(server) {
|
|
|
6148
6185
|
// 数据模型查询工具
|
|
6149
6186
|
server.registerTool?.("manageDataModel", {
|
|
6150
6187
|
title: "数据模型管理",
|
|
6151
|
-
description: "
|
|
6188
|
+
description: "数据模型查询工具,支持查询和列表数据模型(只读操作)。通过 action 参数区分操作类型:list=获取模型列表(不含Schema,可选 names 参数过滤),get=查询单个模型详情(含Schema字段列表、格式、关联关系等,需要提供 name 参数),docs=生成SDK使用文档(需要提供 name 参数)",
|
|
6152
6189
|
inputSchema: {
|
|
6153
6190
|
action: zod_1.z
|
|
6154
6191
|
.enum(["get", "list", "docs"])
|
|
6155
|
-
.describe("操作类型:get=查询单个模型(含Schema
|
|
6156
|
-
name: zod_1.z.string().optional().describe("
|
|
6192
|
+
.describe("操作类型:get=查询单个模型(含Schema字段列表、格式、关联关系,需要提供 name 参数),list=获取模型列表(不含Schema,可选 names 参数过滤),docs=生成SDK使用文档(需要提供 name 参数)"),
|
|
6193
|
+
name: zod_1.z.string().optional().describe("要查询的数据模型名称。当 action='get' 或 action='docs' 时,此参数为必填项,必须提供已存在的数据模型名称。可通过 action='list' 操作获取可用的模型名称列表"),
|
|
6157
6194
|
names: zod_1.z
|
|
6158
6195
|
.array(zod_1.z.string())
|
|
6159
6196
|
.optional()
|
|
@@ -7786,6 +7823,26 @@ function registerStorageTools(server) {
|
|
|
7786
7823
|
}
|
|
7787
7824
|
|
|
7788
7825
|
|
|
7826
|
+
/***/ }),
|
|
7827
|
+
|
|
7828
|
+
/***/ 5018:
|
|
7829
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
7830
|
+
|
|
7831
|
+
|
|
7832
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7833
|
+
exports.isInternationalRegion = void 0;
|
|
7834
|
+
exports.isValidRegion = isValidRegion;
|
|
7835
|
+
const REGION = {
|
|
7836
|
+
SHANGHAI: 'ap-shanghai',
|
|
7837
|
+
SINGAPORE: 'ap-singapore',
|
|
7838
|
+
};
|
|
7839
|
+
const isInternationalRegion = (region) => region === REGION.SINGAPORE;
|
|
7840
|
+
exports.isInternationalRegion = isInternationalRegion;
|
|
7841
|
+
function isValidRegion(region) {
|
|
7842
|
+
return Object.values(REGION).includes(region);
|
|
7843
|
+
}
|
|
7844
|
+
|
|
7845
|
+
|
|
7789
7846
|
/***/ }),
|
|
7790
7847
|
|
|
7791
7848
|
/***/ 5023:
|
|
@@ -8713,7 +8770,7 @@ class TelemetryReporter {
|
|
|
8713
8770
|
const nodeVersion = process.version; // Node.js版本
|
|
8714
8771
|
const arch = os_1.default.arch(); // 系统架构
|
|
8715
8772
|
// 从构建时注入的版本号获取MCP版本信息
|
|
8716
|
-
const mcpVersion = process.env.npm_package_version || "2.
|
|
8773
|
+
const mcpVersion = process.env.npm_package_version || "2.9.0" || 0;
|
|
8717
8774
|
return {
|
|
8718
8775
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
8719
8776
|
deviceId: this.deviceId,
|
|
@@ -9083,12 +9140,12 @@ function registerFunctionTools(server) {
|
|
|
9083
9140
|
// getFunctionList - 获取云函数列表或详情(推荐)
|
|
9084
9141
|
server.registerTool?.("getFunctionList", {
|
|
9085
9142
|
title: "查询云函数列表或详情",
|
|
9086
|
-
description: "
|
|
9143
|
+
description: "获取云函数列表或单个函数详情。通过 action 参数区分操作类型:list=获取函数列表(默认,无需额外参数),detail=获取函数详情(需要提供 name 参数指定函数名称)",
|
|
9087
9144
|
inputSchema: {
|
|
9088
|
-
action: zod_1.z.enum(["list", "detail"]).optional().describe("操作类型:list
|
|
9145
|
+
action: zod_1.z.enum(["list", "detail"]).optional().describe("操作类型:list=获取函数列表(默认,无需额外参数),detail=获取函数详情(需要提供 name 参数)"),
|
|
9089
9146
|
limit: zod_1.z.number().optional().describe("范围(list 操作时使用)"),
|
|
9090
9147
|
offset: zod_1.z.number().optional().describe("偏移(list 操作时使用)"),
|
|
9091
|
-
name: zod_1.z.string().optional().describe("
|
|
9148
|
+
name: zod_1.z.string().optional().describe("要查询的函数名称。当 action='detail' 时,此参数为必填项,必须提供已存在的函数名称。可通过 action='list' 操作获取可用的函数名称列表"),
|
|
9092
9149
|
codeSecret: zod_1.z.string().optional().describe("代码保护密钥(detail 操作时使用)")
|
|
9093
9150
|
},
|
|
9094
9151
|
annotations: {
|
|
@@ -9328,17 +9385,30 @@ function registerFunctionTools(server) {
|
|
|
9328
9385
|
}
|
|
9329
9386
|
}, async ({ name, params }) => {
|
|
9330
9387
|
// 使用闭包中的 cloudBaseOptions
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9388
|
+
try {
|
|
9389
|
+
const cloudbase = await getManager();
|
|
9390
|
+
const result = await cloudbase.functions.invokeFunction(name, params);
|
|
9391
|
+
(0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
|
|
9392
|
+
return {
|
|
9393
|
+
content: [
|
|
9394
|
+
{
|
|
9395
|
+
type: "text",
|
|
9396
|
+
text: JSON.stringify(result, null, 2)
|
|
9397
|
+
}
|
|
9398
|
+
]
|
|
9399
|
+
};
|
|
9400
|
+
}
|
|
9401
|
+
catch (error) {
|
|
9402
|
+
const errorMessage = (error instanceof Error ? error.message : String(error));
|
|
9403
|
+
if (errorMessage.includes("Function not found") ||
|
|
9404
|
+
errorMessage.includes("函数不存在")) {
|
|
9405
|
+
throw new Error(`${errorMessage}\n\n` +
|
|
9406
|
+
`Tip: "invokeFunction" can only call deployed cloud functions. ` +
|
|
9407
|
+
`For database operations (such as creating collections), ` +
|
|
9408
|
+
`please use the appropriate database tools instead.`);
|
|
9409
|
+
}
|
|
9410
|
+
throw error;
|
|
9411
|
+
}
|
|
9342
9412
|
});
|
|
9343
9413
|
// getFunctionLogs - 获取云函数日志(新版,参数直接展开)
|
|
9344
9414
|
server.registerTool?.("getFunctionLogs", {
|
|
@@ -10133,15 +10203,14 @@ function registerSetupTools(server) {
|
|
|
10133
10203
|
title: "下载项目模板",
|
|
10134
10204
|
description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
|
|
10135
10205
|
|
|
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.
|
|
10206
|
+
**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.9.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
10137
10207
|
inputSchema: {
|
|
10138
10208
|
template: zod_1.z
|
|
10139
10209
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
10140
10210
|
.describe("要下载的模板类型"),
|
|
10141
10211
|
ide: zod_1.z
|
|
10142
10212
|
.enum(IDE_TYPES)
|
|
10143
|
-
.
|
|
10144
|
-
.describe("指定要下载的IDE类型。如果未指定,会根据 INTEGRATION_IDE 环境变量自动选择对应的IDE配置;如果环境变量也未设置,则必须传入此参数"),
|
|
10213
|
+
.describe("指定要下载的IDE类型。"),
|
|
10145
10214
|
overwrite: zod_1.z
|
|
10146
10215
|
.boolean()
|
|
10147
10216
|
.optional()
|
|
@@ -10156,7 +10225,7 @@ function registerSetupTools(server) {
|
|
|
10156
10225
|
},
|
|
10157
10226
|
}, async ({ template, ide, overwrite = false, }) => {
|
|
10158
10227
|
try {
|
|
10159
|
-
const ideResolution = resolveDownloadTemplateIDE(ide,
|
|
10228
|
+
const ideResolution = resolveDownloadTemplateIDE(ide, undefined);
|
|
10160
10229
|
if (!ideResolution.ok) {
|
|
10161
10230
|
const supportedIDEs = ideResolution.supportedIDEs.join(", ");
|
|
10162
10231
|
if (ideResolution.reason === "unmapped_integration_ide") {
|
|
@@ -11152,7 +11221,7 @@ async function checkAndInitTcbService(cloudbase, context) {
|
|
|
11152
11221
|
uin: newContext.uin,
|
|
11153
11222
|
tcbServiceChecked: newContext.tcbServiceChecked
|
|
11154
11223
|
});
|
|
11155
|
-
const checkResult = await cloudbase.commonService("tcb").call({
|
|
11224
|
+
const checkResult = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
11156
11225
|
Action: "CheckTcbService",
|
|
11157
11226
|
Param: {}
|
|
11158
11227
|
});
|
|
@@ -11173,7 +11242,7 @@ async function checkAndInitTcbService(cloudbase, context) {
|
|
|
11173
11242
|
(0, logger_js_1.debug)('[env-setup] TCB service not initialized, attempting to initialize...');
|
|
11174
11243
|
(0, logger_js_1.debug)('[env-setup] InitTcb params:', { Source: "qcloud", Channel: "mcp" });
|
|
11175
11244
|
try {
|
|
11176
|
-
const initResult = await cloudbase.commonService("tcb").call({
|
|
11245
|
+
const initResult = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
11177
11246
|
Action: "InitTcb",
|
|
11178
11247
|
Param: {
|
|
11179
11248
|
Source: "qcloud",
|
|
@@ -11261,7 +11330,7 @@ async function checkAndCreateFreeEnv(cloudbase, context) {
|
|
|
11261
11330
|
(0, logger_js_1.debug)('[env-setup] DescribeUserPromotionalActivity params:', {
|
|
11262
11331
|
Names: ["NewUser", "ReturningUser", "BaasFree"]
|
|
11263
11332
|
});
|
|
11264
|
-
const activityResult = await cloudbase.commonService("tcb").call({
|
|
11333
|
+
const activityResult = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
11265
11334
|
Action: "DescribeUserPromotionalActivity",
|
|
11266
11335
|
Param: {
|
|
11267
11336
|
Names: ["NewUser", "ReturningUser", "BaasFree"]
|
|
@@ -11312,7 +11381,7 @@ async function checkAndCreateFreeEnv(cloudbase, context) {
|
|
|
11312
11381
|
Source: "qcloud"
|
|
11313
11382
|
};
|
|
11314
11383
|
(0, logger_js_1.debug)('[env-setup] CreateFreeEnvByActivity params:', createParams);
|
|
11315
|
-
const createResult = await cloudbase.commonService("tcb").call({
|
|
11384
|
+
const createResult = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
11316
11385
|
Action: "CreateFreeEnvByActivity",
|
|
11317
11386
|
Param: createParams
|
|
11318
11387
|
});
|
|
@@ -11457,7 +11526,9 @@ async function checkAndCreateFreeEnv(cloudbase, context) {
|
|
|
11457
11526
|
*/
|
|
11458
11527
|
async function getUinForTelemetry() {
|
|
11459
11528
|
try {
|
|
11460
|
-
|
|
11529
|
+
// Get region from environment variable for auth URL
|
|
11530
|
+
const region = process.env.TCB_REGION;
|
|
11531
|
+
const loginState = await (0, auth_js_1.getLoginState)({ region });
|
|
11461
11532
|
// Try to extract UIN from loginState
|
|
11462
11533
|
// Note: actual field name may vary, adjust based on actual response
|
|
11463
11534
|
return loginState.uin || undefined;
|
|
@@ -12023,6 +12094,7 @@ exports.getLoginState = getLoginState;
|
|
|
12023
12094
|
exports.logout = logout;
|
|
12024
12095
|
const toolbox_1 = __webpack_require__(2090);
|
|
12025
12096
|
const logger_js_1 = __webpack_require__(3039);
|
|
12097
|
+
const tencet_cloud_js_1 = __webpack_require__(5018);
|
|
12026
12098
|
const auth = toolbox_1.AuthSupevisor.getInstance({});
|
|
12027
12099
|
async function getLoginState(options) {
|
|
12028
12100
|
const { TENCENTCLOUD_SECRETID, TENCENTCLOUD_SECRETKEY, TENCENTCLOUD_SESSIONTOKEN, } = process.env;
|
|
@@ -12040,9 +12112,10 @@ async function getLoginState(options) {
|
|
|
12040
12112
|
}
|
|
12041
12113
|
const loginState = await auth.getLoginState();
|
|
12042
12114
|
if (!loginState) {
|
|
12043
|
-
await auth.loginByWebAuth(options?.fromCloudBaseLoginPage
|
|
12115
|
+
await auth.loginByWebAuth((options?.fromCloudBaseLoginPage && !(0, tencet_cloud_js_1.isInternationalRegion)(options?.region))
|
|
12044
12116
|
? {
|
|
12045
12117
|
getAuthUrl: (url) => {
|
|
12118
|
+
// 国际站
|
|
12046
12119
|
const separator = url.includes('?') ? '&' : '?';
|
|
12047
12120
|
const urlWithParam = `${url}${separator}allowNoEnv=true`;
|
|
12048
12121
|
return `https://tcb.cloud.tencent.com/login?_redirect_uri=${encodeURIComponent(urlWithParam)}`;
|
|
@@ -12050,6 +12123,9 @@ async function getLoginState(options) {
|
|
|
12050
12123
|
}
|
|
12051
12124
|
: {
|
|
12052
12125
|
getAuthUrl: (url) => {
|
|
12126
|
+
if ((0, tencet_cloud_js_1.isInternationalRegion)(options?.region)) {
|
|
12127
|
+
url = url.replace('cloud.tencent.com', 'tencentcloud.com');
|
|
12128
|
+
}
|
|
12053
12129
|
const separator = url.includes('?') ? '&' : '?';
|
|
12054
12130
|
return `${url}${separator}allowNoEnv=true`;
|
|
12055
12131
|
},
|
|
@@ -12097,7 +12173,7 @@ function renderHeader(accountInfo, ide) {
|
|
|
12097
12173
|
<img class="logo" src="https://7463-tcb-advanced-a656fc-1257967285.tcb.qcloud.la/mcp/cloudbase-logo.svg" alt="CloudBase Logo" />
|
|
12098
12174
|
<span class="title">CloudBase</span>
|
|
12099
12175
|
</div>
|
|
12100
|
-
${hasAccount ? `
|
|
12176
|
+
${(hasAccount && accountInfo.region !== 'ap-singapore') ? /** 国际站不支持切 */ `
|
|
12101
12177
|
<div class="header-right">
|
|
12102
12178
|
<div class="account-section">
|
|
12103
12179
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
@@ -12105,6 +12181,7 @@ function renderHeader(accountInfo, ide) {
|
|
|
12105
12181
|
<circle cx="12" cy="7" r="4"/>
|
|
12106
12182
|
</svg>
|
|
12107
12183
|
<span class="account-uin">${accountInfo.uin}</span>
|
|
12184
|
+
${accountInfo.region ? `<span class="account-region">${accountInfo.region}</span>` : ''}
|
|
12108
12185
|
${!isCodeBuddy ? `
|
|
12109
12186
|
<button class="btn-switch" onclick="switchAccount()" title="切换账号">
|
|
12110
12187
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
@@ -13611,7 +13688,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
13611
13688
|
// TODO: 考虑是否有支持指定其他 instance、schema 的需求
|
|
13612
13689
|
const schemaId = envId;
|
|
13613
13690
|
const instanceId = "default";
|
|
13614
|
-
const result = await cloudbase.commonService("tcb").call({
|
|
13691
|
+
const result = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
13615
13692
|
Action: "RunSql",
|
|
13616
13693
|
Param: {
|
|
13617
13694
|
EnvId: envId,
|
|
@@ -13675,7 +13752,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
13675
13752
|
// TODO: 考虑是否有支持指定其他 instance、schema 的需求
|
|
13676
13753
|
const schemaId = envId;
|
|
13677
13754
|
const instanceId = "default";
|
|
13678
|
-
const result = await cloudbase.commonService("tcb").call({
|
|
13755
|
+
const result = await cloudbase.commonService("tcb", "2018-06-08").call({
|
|
13679
13756
|
Action: "RunSql",
|
|
13680
13757
|
Param: {
|
|
13681
13758
|
EnvId: envId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cloudbase-mcp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.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",
|