@cloudbase/cloudbase-mcp 2.23.5 → 2.23.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 +2 -2
- package/dist/index.cjs +60 -41
- package/dist/index.js +60 -41
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2322,7 +2322,7 @@ async function enrichEnvInfoWithBilling(params) {
|
|
|
2322
2322
|
* for new code, including an explicit `MysqlNotAvailable` line when
|
|
2323
2323
|
* MySQL is absent — that one IS a hard "do not use" signal.
|
|
2324
2324
|
*/
|
|
2325
|
-
function enrichEnvInfoWithRuntimeMode(result) {
|
|
2325
|
+
async function enrichEnvInfoWithRuntimeMode(result, manager) {
|
|
2326
2326
|
const envInfo = result?.EnvInfo;
|
|
2327
2327
|
if (!envInfo || typeof envInfo !== "object") {
|
|
2328
2328
|
return result;
|
|
@@ -2352,7 +2352,29 @@ function enrichEnvInfoWithRuntimeMode(result) {
|
|
|
2352
2352
|
}
|
|
2353
2353
|
return [];
|
|
2354
2354
|
})();
|
|
2355
|
-
|
|
2355
|
+
let hasMysql = mysqlList.length > 0;
|
|
2356
|
+
// Fallback: if MySQL not detected from DescribeEnvInfo fields, probe via
|
|
2357
|
+
// DescribeMySQLClusterDetail (dedicated MySQL API). This covers cases where
|
|
2358
|
+
// the SDK strips MySQL fields from the DescribeEnvInfo response.
|
|
2359
|
+
if (!hasMysql && manager?.commonService) {
|
|
2360
|
+
try {
|
|
2361
|
+
const probeResult = await manager
|
|
2362
|
+
.commonService("tcb", "2018-06-08")
|
|
2363
|
+
.call({
|
|
2364
|
+
Action: "DescribeMySQLClusterDetail",
|
|
2365
|
+
Param: { EnvId: envInfo.EnvId },
|
|
2366
|
+
});
|
|
2367
|
+
const clusterId = probeResult?.DbClusterId ||
|
|
2368
|
+
probeResult?.Response?.DbClusterId ||
|
|
2369
|
+
probeResult?.Data?.DbClusterId;
|
|
2370
|
+
if (clusterId) {
|
|
2371
|
+
hasMysql = true;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
catch {
|
|
2375
|
+
// Probe failure means MySQL is not provisioned — keep hasMysql = false
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2356
2378
|
// Primary mode: prefer PG when it is provisioned, otherwise fall back to
|
|
2357
2379
|
// legacy NoSQL labeling. This drives "what skill to read first / what API
|
|
2358
2380
|
// to reach for when starting new business code".
|
|
@@ -2370,7 +2392,7 @@ function enrichEnvInfoWithRuntimeMode(result) {
|
|
|
2370
2392
|
: "No legacy NoSQL Database/Storage observed in this env.",
|
|
2371
2393
|
MysqlNotAvailable: hasMysql
|
|
2372
2394
|
? "MySQL instance(s) detected — see EnvInfo.MysqlInstances."
|
|
2373
|
-
: "No MySQL instance is provisioned for this env. Do NOT use `
|
|
2395
|
+
: "No MySQL instance is provisioned for this env. Do NOT use `manageMysqlDatabase` / `queryMysqlDatabase` (those are MySQL-specific) and do NOT read the `relational-database-tool` skill — that family targets MySQL, not CloudBase PG.",
|
|
2374
2396
|
RecommendedSkills: "Read `postgresql-development` first for new PG code. `no-sql-web-sdk` is still applicable for existing NoSQL collections in this env. Skip `relational-database-tool` (MySQL-only) entirely.",
|
|
2375
2397
|
}
|
|
2376
2398
|
: {
|
|
@@ -2380,7 +2402,7 @@ function enrichEnvInfoWithRuntimeMode(result) {
|
|
|
2380
2402
|
Storage: "Browser uploads use `app.uploadFile()` against the bucket exposed in `EnvInfo.Storages[].Bucket`.",
|
|
2381
2403
|
MysqlNotAvailable: hasMysql
|
|
2382
2404
|
? "MySQL instance(s) detected — see EnvInfo.MysqlInstances."
|
|
2383
|
-
: "No MySQL instance in this env. `
|
|
2405
|
+
: "No MySQL instance in this env. `manageMysqlDatabase` / `queryMysqlDatabase` and the `relational-database-tool` skill are not applicable.",
|
|
2384
2406
|
RecommendedSkills: "Read `no-sql-web-sdk` (and `cloud-storage-web` for uploads). `postgresql-development` and `relational-database-tool` are not applicable to this env.",
|
|
2385
2407
|
};
|
|
2386
2408
|
return {
|
|
@@ -3144,7 +3166,7 @@ function registerEnvTools(server) {
|
|
|
3144
3166
|
if (envId) {
|
|
3145
3167
|
result = await enrichEnvInfoWithMissingFields(cloudbaseInfo, result, envId);
|
|
3146
3168
|
}
|
|
3147
|
-
result = enrichEnvInfoWithRuntimeMode(result);
|
|
3169
|
+
result = await enrichEnvInfoWithRuntimeMode(result, cloudbaseInfo);
|
|
3148
3170
|
break;
|
|
3149
3171
|
case "domains":
|
|
3150
3172
|
const cloudbaseDomains = await getManager();
|
|
@@ -3212,7 +3234,7 @@ function registerEnvTools(server) {
|
|
|
3212
3234
|
// Register primary tool name (queryEnv)
|
|
3213
3235
|
const queryEnvToolSchema = {
|
|
3214
3236
|
title: "CloudBase 环境查询",
|
|
3215
|
-
description: "查询 CloudBase 环境相关信息,支持查询环境列表、指定环境详情和安全域名。(曾用名:envQuery、listEnvs、getEnvInfo、getEnvAuthDomains)当 action=list 时,会按 DescribeEnvs 语义做列表/筛选,标准返回字段为 EnvId、Alias、Status、EnvType、Region、PackageId、PackageName、IsDefault,并支持通过 fields 白名单裁剪这些字段;aliasExact=true 时会按别名精确筛选,避免把前缀相近的环境误当作候选;即使传入 envId,action=list 也只返回摘要,不会返回完整资源明细或 expiry。如需查询某个已知 EnvId 对应环境的详细信息(包括资源字段和计费信息),必须使用 action=info 并传入目标环境的 envId 参数。action=info 会在可用时补充 BillingInfo(如 ExpireTime、PayMode、IsAutoRenew 等计费字段)。\n\n🔍 action=info 还会派生三个用于后端选型的字段:\n- `EnvInfo.RuntimeMode`:'postgresql' 或 'nosql',表示新业务建议默认使用的后端(PG 已开通时为 postgresql,否则为 nosql)。\n- `EnvInfo.RuntimeBackends`:`{postgresql, nosql, mysql}` 三个布尔值,描述当前环境实际并存的后端。\n- `EnvInfo.RuntimeModeHints`:每个后端对应的 API/工具/skill 提示。\n\nAI 在写业务/权限/存储代码前必须先看这三项:PG 模式下新业务推荐 `app.rdb()` + RLS(`managePgDatabase action=execute` 跑 `CREATE POLICY`)+ pgstore;已存在的 NoSQL 集合 / 旧 storage / `managePermissions(resourceType=\"noSqlDatabase\")` 在 PG 环境下仍然有效。真正不适用的是 MySQL:当 `RuntimeBackends.mysql === false` 时,`
|
|
3237
|
+
description: "查询 CloudBase 环境相关信息,支持查询环境列表、指定环境详情和安全域名。(曾用名:envQuery、listEnvs、getEnvInfo、getEnvAuthDomains)当 action=list 时,会按 DescribeEnvs 语义做列表/筛选,标准返回字段为 EnvId、Alias、Status、EnvType、Region、PackageId、PackageName、IsDefault,并支持通过 fields 白名单裁剪这些字段;aliasExact=true 时会按别名精确筛选,避免把前缀相近的环境误当作候选;即使传入 envId,action=list 也只返回摘要,不会返回完整资源明细或 expiry。如需查询某个已知 EnvId 对应环境的详细信息(包括资源字段和计费信息),必须使用 action=info 并传入目标环境的 envId 参数。action=info 会在可用时补充 BillingInfo(如 ExpireTime、PayMode、IsAutoRenew 等计费字段)。\n\n🔍 action=info 还会派生三个用于后端选型的字段:\n- `EnvInfo.RuntimeMode`:'postgresql' 或 'nosql',表示新业务建议默认使用的后端(PG 已开通时为 postgresql,否则为 nosql)。\n- `EnvInfo.RuntimeBackends`:`{postgresql, nosql, mysql}` 三个布尔值,描述当前环境实际并存的后端。\n- `EnvInfo.RuntimeModeHints`:每个后端对应的 API/工具/skill 提示。\n\nAI 在写业务/权限/存储代码前必须先看这三项:PG 模式下新业务推荐 `app.rdb()` + RLS(`managePgDatabase action=execute` 跑 `CREATE POLICY`)+ pgstore;已存在的 NoSQL 集合 / 旧 storage / `managePermissions(resourceType=\"noSqlDatabase\")` 在 PG 环境下仍然有效。真正不适用的是 MySQL:当 `RuntimeBackends.mysql === false` 时,`manageMysqlDatabase` / `queryMysqlDatabase` / `relational-database-tool` skill 都不该使用。",
|
|
3216
3238
|
inputSchema: {
|
|
3217
3239
|
action: zod_1.z
|
|
3218
3240
|
.enum(["list", "info", "domains"])
|
|
@@ -40629,7 +40651,7 @@ async function checkMysqlGate(server) {
|
|
|
40629
40651
|
success: false,
|
|
40630
40652
|
errorCode: "MYSQL_NOT_AVAILABLE",
|
|
40631
40653
|
message: `This environment (${envId}) does not have MySQL. Use managePgDatabase / queryPgDatabase instead.`,
|
|
40632
|
-
nextActions: [{ tool: "managePgDatabase", params: { action: "execute" }, description: "Use managePgDatabase" }],
|
|
40654
|
+
nextActions: [{ tool: "managePgDatabase", params: { action: "execute" }, description: "Use managePgDatabase for PostgreSQL operations" }],
|
|
40633
40655
|
});
|
|
40634
40656
|
}
|
|
40635
40657
|
try {
|
|
@@ -40641,7 +40663,7 @@ async function checkMysqlGate(server) {
|
|
|
40641
40663
|
return (0, tool_result_js_1.buildJsonToolResult)({
|
|
40642
40664
|
success: false,
|
|
40643
40665
|
errorCode: "MYSQL_NOT_AVAILABLE",
|
|
40644
|
-
message: `This environment (${envId}) has PostgreSQL enabled but MySQL is NOT available. Use managePgDatabase / queryPgDatabase instead of
|
|
40666
|
+
message: `This environment (${envId}) has PostgreSQL enabled but MySQL is NOT available. Use managePgDatabase / queryPgDatabase instead of manageMysqlDatabase / queryMysqlDatabase.`,
|
|
40645
40667
|
nextActions: [{ tool: "managePgDatabase", params: { action: "execute" }, description: "Use managePgDatabase for PostgreSQL operations" }],
|
|
40646
40668
|
});
|
|
40647
40669
|
}
|
|
@@ -40650,8 +40672,8 @@ async function checkMysqlGate(server) {
|
|
|
40650
40672
|
MYSQL_GATE_CACHE.set(envId, true);
|
|
40651
40673
|
return null;
|
|
40652
40674
|
}
|
|
40653
|
-
const
|
|
40654
|
-
const
|
|
40675
|
+
const QUERY_MYSQL_DATABASE = "queryMysqlDatabase";
|
|
40676
|
+
const MANAGE_MYSQL_DATABASE = "manageMysqlDatabase";
|
|
40655
40677
|
const QUERY_PERMISSIONS = "queryPermissions";
|
|
40656
40678
|
const MANAGE_PERMISSIONS = "managePermissions";
|
|
40657
40679
|
const QUERY_ACTIONS = [
|
|
@@ -40943,14 +40965,14 @@ async function getSqlInstanceInfo({ getManager, cloudBaseOptions, server, }) {
|
|
|
40943
40965
|
function buildProvisionNextActions(status, request) {
|
|
40944
40966
|
if (status === "READY") {
|
|
40945
40967
|
return [
|
|
40946
|
-
buildNextAction(
|
|
40968
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "initializeSchema", "MySQL is ready. Initialize tables and indexes next."),
|
|
40947
40969
|
];
|
|
40948
40970
|
}
|
|
40949
40971
|
if (status === "FAILED") {
|
|
40950
40972
|
return [];
|
|
40951
40973
|
}
|
|
40952
40974
|
return [
|
|
40953
|
-
buildNextAction(
|
|
40975
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "describeCreateResult", "MySQL provisioning is still running. Check the create result again before initializing schema.", request
|
|
40954
40976
|
? { action: "describeCreateResult", request }
|
|
40955
40977
|
: { action: "describeCreateResult" }),
|
|
40956
40978
|
];
|
|
@@ -40969,15 +40991,15 @@ function buildTaskStatusNextActions(status, request) {
|
|
|
40969
40991
|
if (status === "READY") {
|
|
40970
40992
|
if (inferTaskKind(request) === "destroy") {
|
|
40971
40993
|
return [
|
|
40972
|
-
buildNextAction(
|
|
40994
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "getInstanceInfo", "The destroy task completed. Confirm whether the MySQL instance no longer exists."),
|
|
40973
40995
|
];
|
|
40974
40996
|
}
|
|
40975
40997
|
return [
|
|
40976
|
-
buildNextAction(
|
|
40998
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "initializeSchema", "MySQL is ready. Initialize tables and indexes next."),
|
|
40977
40999
|
];
|
|
40978
41000
|
}
|
|
40979
41001
|
return [
|
|
40980
|
-
buildNextAction(
|
|
41002
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "describeTaskStatus", "MySQL task is still running. Check task status again before continuing.", request ? { action: "describeTaskStatus", request } : { action: "describeTaskStatus" }),
|
|
40981
41003
|
];
|
|
40982
41004
|
}
|
|
40983
41005
|
async function handleRunQuery(args, context) {
|
|
@@ -40987,7 +41009,7 @@ async function handleRunQuery(args, context) {
|
|
|
40987
41009
|
errorCode: "SQL_REQUIRED",
|
|
40988
41010
|
message: "`sql` is required when action is `runQuery`.",
|
|
40989
41011
|
nextActions: [
|
|
40990
|
-
buildNextAction(
|
|
41012
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "runQuery", "Provide a read-only SQL statement such as SELECT/SHOW/DESCRIBE."),
|
|
40991
41013
|
],
|
|
40992
41014
|
});
|
|
40993
41015
|
}
|
|
@@ -40995,9 +41017,9 @@ async function handleRunQuery(args, context) {
|
|
|
40995
41017
|
return buildSqlToolResult({
|
|
40996
41018
|
success: false,
|
|
40997
41019
|
errorCode: "READ_ONLY_SQL_REQUIRED",
|
|
40998
|
-
message: "`
|
|
41020
|
+
message: "`queryMysqlDatabase(action=runQuery)` only accepts read-only SQL statements.",
|
|
40999
41021
|
nextActions: [
|
|
41000
|
-
buildNextAction(
|
|
41022
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "runStatement", "Use the manage tool for INSERT/UPDATE/DELETE/DDL statements."),
|
|
41001
41023
|
],
|
|
41002
41024
|
});
|
|
41003
41025
|
}
|
|
@@ -41025,7 +41047,7 @@ async function handleRunQuery(args, context) {
|
|
|
41025
41047
|
errorCode: "MYSQL_NOT_CREATED",
|
|
41026
41048
|
message: "MySQL is not provisioned yet or not found. Please provision MySQL before running queries.",
|
|
41027
41049
|
nextActions: [
|
|
41028
|
-
buildNextAction(
|
|
41050
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before querying data.", { action: "provisionMySQL", confirm: true }),
|
|
41029
41051
|
],
|
|
41030
41052
|
});
|
|
41031
41053
|
}
|
|
@@ -41124,7 +41146,7 @@ async function handleGetInstanceInfo(context) {
|
|
|
41124
41146
|
nextActions: instanceInfo.exists
|
|
41125
41147
|
? undefined
|
|
41126
41148
|
: [
|
|
41127
|
-
buildNextAction(
|
|
41149
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before running SQL statements or schema initialization.", { action: "provisionMySQL", confirm: true }),
|
|
41128
41150
|
],
|
|
41129
41151
|
});
|
|
41130
41152
|
}
|
|
@@ -41135,7 +41157,7 @@ async function handleProvisionMySQL(args, context) {
|
|
|
41135
41157
|
errorCode: "CONFIRM_REQUIRED",
|
|
41136
41158
|
message: "Provisioning MySQL creates billable resources. Re-run with `confirm: true` to continue.",
|
|
41137
41159
|
nextActions: [
|
|
41138
|
-
buildNextAction(
|
|
41160
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Explicit confirmation is required before provisioning MySQL.", { action: "provisionMySQL", confirm: true }),
|
|
41139
41161
|
],
|
|
41140
41162
|
});
|
|
41141
41163
|
}
|
|
@@ -41149,7 +41171,7 @@ async function handleProvisionMySQL(args, context) {
|
|
|
41149
41171
|
message: "A SQL database instance already exists for the current environment.",
|
|
41150
41172
|
nextActions: existing.status === "READY"
|
|
41151
41173
|
? [
|
|
41152
|
-
buildNextAction(
|
|
41174
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "initializeSchema", "The instance already exists. You can initialize schema next if needed."),
|
|
41153
41175
|
]
|
|
41154
41176
|
: undefined,
|
|
41155
41177
|
});
|
|
@@ -41195,7 +41217,7 @@ async function handleDestroyMySQL(args, context) {
|
|
|
41195
41217
|
errorCode: "CONFIRM_REQUIRED",
|
|
41196
41218
|
message: "Destroying MySQL removes database resources. Re-run with `confirm: true` to continue.",
|
|
41197
41219
|
nextActions: [
|
|
41198
|
-
buildNextAction(
|
|
41220
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "destroyMySQL", "Explicit confirmation is required before destroying MySQL.", { action: "destroyMySQL", confirm: true }),
|
|
41199
41221
|
],
|
|
41200
41222
|
});
|
|
41201
41223
|
}
|
|
@@ -41242,7 +41264,7 @@ async function handleDestroyMySQL(args, context) {
|
|
|
41242
41264
|
: "MySQL destroy request was rejected.",
|
|
41243
41265
|
nextActions: isSuccess
|
|
41244
41266
|
? [
|
|
41245
|
-
buildNextAction(
|
|
41267
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "describeTaskStatus", "Check the MySQL destroy task status before assuming the instance is gone.", {
|
|
41246
41268
|
action: "describeTaskStatus",
|
|
41247
41269
|
request: taskRequest,
|
|
41248
41270
|
}),
|
|
@@ -41265,7 +41287,7 @@ async function handleRunStatement(args, context) {
|
|
|
41265
41287
|
errorCode: "MYSQL_NOT_CREATED",
|
|
41266
41288
|
message: "MySQL is not provisioned for the current environment yet.",
|
|
41267
41289
|
nextActions: [
|
|
41268
|
-
buildNextAction(
|
|
41290
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before executing write statements or DDL.", { action: "provisionMySQL", confirm: true }),
|
|
41269
41291
|
],
|
|
41270
41292
|
});
|
|
41271
41293
|
}
|
|
@@ -41275,7 +41297,7 @@ async function handleRunStatement(args, context) {
|
|
|
41275
41297
|
errorCode: "MYSQL_NOT_READY",
|
|
41276
41298
|
message: `MySQL is not ready yet (current status: ${instanceInfo.status}).`,
|
|
41277
41299
|
nextActions: [
|
|
41278
|
-
buildNextAction(
|
|
41300
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "getInstanceInfo", "Check current instance status before retrying the statement."),
|
|
41279
41301
|
],
|
|
41280
41302
|
});
|
|
41281
41303
|
}
|
|
@@ -41302,7 +41324,7 @@ async function handleRunStatement(args, context) {
|
|
|
41302
41324
|
errorCode: "MYSQL_NOT_CREATED",
|
|
41303
41325
|
message: "MySQL is not provisioned yet or not found. Please provision MySQL before running statements.",
|
|
41304
41326
|
nextActions: [
|
|
41305
|
-
buildNextAction(
|
|
41327
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before executing statements.", { action: "provisionMySQL", confirm: true }),
|
|
41306
41328
|
],
|
|
41307
41329
|
});
|
|
41308
41330
|
}
|
|
@@ -41331,7 +41353,7 @@ async function resolveInitializationReadiness(args, context) {
|
|
|
41331
41353
|
errorCode: "MYSQL_NOT_CREATED",
|
|
41332
41354
|
message: "MySQL is not provisioned yet. Initialize schema only after provisioning completes.",
|
|
41333
41355
|
nextActions: [
|
|
41334
|
-
buildNextAction(
|
|
41356
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before schema initialization.", { action: "provisionMySQL", confirm: true }),
|
|
41335
41357
|
],
|
|
41336
41358
|
}),
|
|
41337
41359
|
};
|
|
@@ -41371,7 +41393,7 @@ async function resolveInitializationReadiness(args, context) {
|
|
|
41371
41393
|
rawStatus,
|
|
41372
41394
|
},
|
|
41373
41395
|
nextActions: [
|
|
41374
|
-
buildNextAction(
|
|
41396
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "describeTaskStatus", "Check MySQL task status until the instance becomes ready.", args.statusContext?.taskStatusRequest
|
|
41375
41397
|
? {
|
|
41376
41398
|
action: "describeTaskStatus",
|
|
41377
41399
|
request: args.statusContext.taskStatusRequest,
|
|
@@ -41428,7 +41450,7 @@ async function handleInitializeSchema(args, context) {
|
|
|
41428
41450
|
errorCode: "MYSQL_NOT_CREATED",
|
|
41429
41451
|
message: "MySQL is not provisioned yet or not found. Please provision MySQL before initializing schema.",
|
|
41430
41452
|
nextActions: [
|
|
41431
|
-
buildNextAction(
|
|
41453
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before executing statements.", { action: "provisionMySQL", confirm: true }),
|
|
41432
41454
|
],
|
|
41433
41455
|
});
|
|
41434
41456
|
}
|
|
@@ -41476,7 +41498,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
41476
41498
|
cloudBaseOptions,
|
|
41477
41499
|
server,
|
|
41478
41500
|
};
|
|
41479
|
-
server.registerTool?.(
|
|
41501
|
+
server.registerTool?.(QUERY_MYSQL_DATABASE, {
|
|
41480
41502
|
title: "查询 CloudBase MySQL 数据库状态或执行只读 SQL",
|
|
41481
41503
|
description: "查询 CloudBase MySQL 数据库信息。支持执行只读 SQL、查询 MySQL 开通结果、查询 MySQL 任务状态,以及获取当前实例上下文信息。",
|
|
41482
41504
|
inputSchema: {
|
|
@@ -41522,7 +41544,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
41522
41544
|
throw new Error(`Unsupported SQL query action: ${args.action}`);
|
|
41523
41545
|
}
|
|
41524
41546
|
});
|
|
41525
|
-
server.registerTool?.(
|
|
41547
|
+
server.registerTool?.(MANAGE_MYSQL_DATABASE, {
|
|
41526
41548
|
title: "管理 CloudBase MySQL 数据库生命周期或执行写入 SQL",
|
|
41527
41549
|
description: "管理 CloudBase MySQL 数据库资源。支持开通 MySQL、销毁 MySQL、执行写入 SQL/DDL,以及初始化数据库 Schema。注意:必须先开通 MySQL(action=provisionMySQL,confirm=true)才能执行 runStatement 或 initializeSchema。若 MySQL 尚未开通,工具会返回 MYSQL_NOT_CREATED 并给出开通的 nextAction 提示。",
|
|
41528
41550
|
inputSchema: {
|
|
@@ -103269,6 +103291,7 @@ const DEFAULT_PLUGINS = [
|
|
|
103269
103291
|
"database",
|
|
103270
103292
|
"pg_database",
|
|
103271
103293
|
"pg_storage",
|
|
103294
|
+
"mysql_database",
|
|
103272
103295
|
"functions",
|
|
103273
103296
|
"hosting",
|
|
103274
103297
|
"storage",
|
|
@@ -103291,10 +103314,6 @@ function registerDatabase(server) {
|
|
|
103291
103314
|
if (!(0, tencent_cloud_js_1.isInternationalRegion)(region)) {
|
|
103292
103315
|
(0, databaseNoSQL_js_1.registerDatabaseTools)(server);
|
|
103293
103316
|
}
|
|
103294
|
-
const pgPluginEnabled = server.enabledPlugins?.some((pluginName) => pluginName === "pg_database" || pluginName === "pg_storage");
|
|
103295
|
-
if (!pgPluginEnabled) {
|
|
103296
|
-
(0, databaseSQL_js_1.registerSQLDatabaseTools)(server);
|
|
103297
|
-
}
|
|
103298
103317
|
(0, dataModel_js_1.registerDataModelTools)(server);
|
|
103299
103318
|
}
|
|
103300
103319
|
function registerMysqlDatabase(server) {
|
|
@@ -136672,7 +136691,7 @@ class TelemetryReporter {
|
|
|
136672
136691
|
const nodeVersion = process.version; // Node.js版本
|
|
136673
136692
|
const arch = os_1.default.arch(); // 系统架构
|
|
136674
136693
|
// 从构建时注入的版本号获取MCP版本信息
|
|
136675
|
-
const mcpVersion = process.env.npm_package_version || "2.23.
|
|
136694
|
+
const mcpVersion = process.env.npm_package_version || "2.23.6" || 0;
|
|
136676
136695
|
return {
|
|
136677
136696
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
136678
136697
|
deviceId: this.deviceId,
|
|
@@ -196457,7 +196476,7 @@ ${envIdSection}
|
|
|
196457
196476
|
## 环境信息
|
|
196458
196477
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
196459
196478
|
- Node.js版本: ${process.version}
|
|
196460
|
-
- MCP 版本:${process.env.npm_package_version || "2.23.
|
|
196479
|
+
- MCP 版本:${process.env.npm_package_version || "2.23.6" || 0}
|
|
196461
196480
|
- 系统架构: ${os_1.default.arch()}
|
|
196462
196481
|
- 时间: ${new Date().toISOString()}
|
|
196463
196482
|
- 请求ID: ${requestId}
|
|
@@ -196538,7 +196557,7 @@ function createWrappedHandler(name, handler, server) {
|
|
|
196538
196557
|
requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
|
|
196539
196558
|
ide: server.ide || process.env.INTEGRATION_IDE || ''
|
|
196540
196559
|
});
|
|
196541
|
-
const mcpVersion = true ? "2.23.
|
|
196560
|
+
const mcpVersion = true ? "2.23.6" : 0;
|
|
196542
196561
|
const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
|
|
196543
196562
|
const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
|
|
196544
196563
|
// 创建新的错误对象,保持原有的错误类型但更新消息
|
|
@@ -211744,7 +211763,7 @@ function registerPermissionTools(server) {
|
|
|
211744
211763
|
}));
|
|
211745
211764
|
server.registerTool?.("managePermissions", {
|
|
211746
211765
|
title: "管理 CloudBase 权限与用户配置",
|
|
211747
|
-
description: "管理 CloudBase 权限与用户配置,支持修改资源权限(数据库/云函数/存储桶等)、角色管理、成员与策略增删、应用用户 CRUD。\n\n示例:\n- 设置存储桶为私有:`action=\"updateResourcePermission\", resourceType=\"storage\", resourceId=\"bucket-name\", permission=\"PRIVATE\"`\n- 创建角色:`action=\"createRole\", roleName=\"admin\", roleIdentity=\"admin\"`\n\n注意:`createUser` / `updateUser` 是环境侧应用用户管理能力,适合测试账号、管理员或预置用户,不应替代浏览器里的 Web SDK 注册表单;前端用户名密码注册应使用 `auth.signUp({ username, password })`,登录应使用 `auth.signInWithPassword({ username, password })`。直接在浏览器里用 `auth.signUp` 创建用户名密码用户取决于 SDK/provider 支持,使用前必须验证;不支持时应走后端或管理端边界,不能在浏览器暴露密钥。`securityRule` 的详细语义取决于 `resourceType`:`doc._openid`、`auth.openid`、查询条件子集校验,以及 `create` / `update` / `delete` JSON 模板仅适用于 `resourceType=\"noSqlDatabase\"` 的文档数据库安全规则;配置 `function` 或 `storage` 时,请参考各自官方安全规则文档,而不是复用 NoSQL 模板。\n\n📌 跨后端边界提示:调用前先用 `envQuery(action=\"info\", envId=...)` 看 `EnvInfo.RuntimeBackends`:\n- `resourceType=\"noSqlDatabase\"` 仅作用于 CloudBase NoSQL 文档数据库的集合;CloudBase PostgreSQL(PG)表的行级权限**不**受它控制——PG 表请改用 RLS:`managePgDatabase(action=\"execute\", confirm=true)` 跑 `ALTER TABLE ... ENABLE ROW LEVEL SECURITY` 与 `CREATE POLICY ...`。同一个 PG 环境里如果还有 NoSQL 集合在用,对那些**集合**继续使用 `noSqlDatabase` 规则是正确的——不是\"PG 环境就禁用本工具\"。\n- `resourceType=\"storage\"` 控制的是 NoSQL/COS 存储桶 ACL;PG 的 `pgstore` bucket 不在此 `resourceType` 覆盖范围内。\n- 本工具不涉及 MySQL;MySQL 数据库权限请走 MySQL 自身的 GRANT/REVOKE 语句(通过 `
|
|
211766
|
+
description: "管理 CloudBase 权限与用户配置,支持修改资源权限(数据库/云函数/存储桶等)、角色管理、成员与策略增删、应用用户 CRUD。\n\n示例:\n- 设置存储桶为私有:`action=\"updateResourcePermission\", resourceType=\"storage\", resourceId=\"bucket-name\", permission=\"PRIVATE\"`\n- 创建角色:`action=\"createRole\", roleName=\"admin\", roleIdentity=\"admin\"`\n\n注意:`createUser` / `updateUser` 是环境侧应用用户管理能力,适合测试账号、管理员或预置用户,不应替代浏览器里的 Web SDK 注册表单;前端用户名密码注册应使用 `auth.signUp({ username, password })`,登录应使用 `auth.signInWithPassword({ username, password })`。直接在浏览器里用 `auth.signUp` 创建用户名密码用户取决于 SDK/provider 支持,使用前必须验证;不支持时应走后端或管理端边界,不能在浏览器暴露密钥。`securityRule` 的详细语义取决于 `resourceType`:`doc._openid`、`auth.openid`、查询条件子集校验,以及 `create` / `update` / `delete` JSON 模板仅适用于 `resourceType=\"noSqlDatabase\"` 的文档数据库安全规则;配置 `function` 或 `storage` 时,请参考各自官方安全规则文档,而不是复用 NoSQL 模板。\n\n📌 跨后端边界提示:调用前先用 `envQuery(action=\"info\", envId=...)` 看 `EnvInfo.RuntimeBackends`:\n- `resourceType=\"noSqlDatabase\"` 仅作用于 CloudBase NoSQL 文档数据库的集合;CloudBase PostgreSQL(PG)表的行级权限**不**受它控制——PG 表请改用 RLS:`managePgDatabase(action=\"execute\", confirm=true)` 跑 `ALTER TABLE ... ENABLE ROW LEVEL SECURITY` 与 `CREATE POLICY ...`。同一个 PG 环境里如果还有 NoSQL 集合在用,对那些**集合**继续使用 `noSqlDatabase` 规则是正确的——不是\"PG 环境就禁用本工具\"。\n- `resourceType=\"storage\"` 控制的是 NoSQL/COS 存储桶 ACL;PG 的 `pgstore` bucket 不在此 `resourceType` 覆盖范围内。\n- 本工具不涉及 MySQL;MySQL 数据库权限请走 MySQL 自身的 GRANT/REVOKE 语句(通过 `manageMysqlDatabase`)。",
|
|
211748
211767
|
inputSchema: {
|
|
211749
211768
|
action: zod_1.z.enum(MANAGE_PERMISSION_ACTIONS),
|
|
211750
211769
|
resourceType: zod_1.z
|
|
@@ -212552,7 +212571,7 @@ function registerSetupTools(server) {
|
|
|
212552
212571
|
server.registerTool("downloadTemplate", {
|
|
212553
212572
|
title: "下载项目模板",
|
|
212554
212573
|
description: `自动下载并部署CloudBase项目模板。
|
|
212555
|
-
**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.23.
|
|
212574
|
+
**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.23.6" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
212556
212575
|
inputSchema: {
|
|
212557
212576
|
template: zod_1.z
|
|
212558
212577
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|