@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.js
CHANGED
|
@@ -593,7 +593,7 @@ async function enrichEnvInfoWithBilling(params) {
|
|
|
593
593
|
* for new code, including an explicit `MysqlNotAvailable` line when
|
|
594
594
|
* MySQL is absent — that one IS a hard "do not use" signal.
|
|
595
595
|
*/
|
|
596
|
-
function enrichEnvInfoWithRuntimeMode(result) {
|
|
596
|
+
async function enrichEnvInfoWithRuntimeMode(result, manager) {
|
|
597
597
|
const envInfo = result?.EnvInfo;
|
|
598
598
|
if (!envInfo || typeof envInfo !== "object") {
|
|
599
599
|
return result;
|
|
@@ -623,7 +623,29 @@ function enrichEnvInfoWithRuntimeMode(result) {
|
|
|
623
623
|
}
|
|
624
624
|
return [];
|
|
625
625
|
})();
|
|
626
|
-
|
|
626
|
+
let hasMysql = mysqlList.length > 0;
|
|
627
|
+
// Fallback: if MySQL not detected from DescribeEnvInfo fields, probe via
|
|
628
|
+
// DescribeMySQLClusterDetail (dedicated MySQL API). This covers cases where
|
|
629
|
+
// the SDK strips MySQL fields from the DescribeEnvInfo response.
|
|
630
|
+
if (!hasMysql && manager?.commonService) {
|
|
631
|
+
try {
|
|
632
|
+
const probeResult = await manager
|
|
633
|
+
.commonService("tcb", "2018-06-08")
|
|
634
|
+
.call({
|
|
635
|
+
Action: "DescribeMySQLClusterDetail",
|
|
636
|
+
Param: { EnvId: envInfo.EnvId },
|
|
637
|
+
});
|
|
638
|
+
const clusterId = probeResult?.DbClusterId ||
|
|
639
|
+
probeResult?.Response?.DbClusterId ||
|
|
640
|
+
probeResult?.Data?.DbClusterId;
|
|
641
|
+
if (clusterId) {
|
|
642
|
+
hasMysql = true;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
catch {
|
|
646
|
+
// Probe failure means MySQL is not provisioned — keep hasMysql = false
|
|
647
|
+
}
|
|
648
|
+
}
|
|
627
649
|
// Primary mode: prefer PG when it is provisioned, otherwise fall back to
|
|
628
650
|
// legacy NoSQL labeling. This drives "what skill to read first / what API
|
|
629
651
|
// to reach for when starting new business code".
|
|
@@ -641,7 +663,7 @@ function enrichEnvInfoWithRuntimeMode(result) {
|
|
|
641
663
|
: "No legacy NoSQL Database/Storage observed in this env.",
|
|
642
664
|
MysqlNotAvailable: hasMysql
|
|
643
665
|
? "MySQL instance(s) detected — see EnvInfo.MysqlInstances."
|
|
644
|
-
: "No MySQL instance is provisioned for this env. Do NOT use `
|
|
666
|
+
: "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.",
|
|
645
667
|
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.",
|
|
646
668
|
}
|
|
647
669
|
: {
|
|
@@ -651,7 +673,7 @@ function enrichEnvInfoWithRuntimeMode(result) {
|
|
|
651
673
|
Storage: "Browser uploads use `app.uploadFile()` against the bucket exposed in `EnvInfo.Storages[].Bucket`.",
|
|
652
674
|
MysqlNotAvailable: hasMysql
|
|
653
675
|
? "MySQL instance(s) detected — see EnvInfo.MysqlInstances."
|
|
654
|
-
: "No MySQL instance in this env. `
|
|
676
|
+
: "No MySQL instance in this env. `manageMysqlDatabase` / `queryMysqlDatabase` and the `relational-database-tool` skill are not applicable.",
|
|
655
677
|
RecommendedSkills: "Read `no-sql-web-sdk` (and `cloud-storage-web` for uploads). `postgresql-development` and `relational-database-tool` are not applicable to this env.",
|
|
656
678
|
};
|
|
657
679
|
return {
|
|
@@ -1415,7 +1437,7 @@ function registerEnvTools(server) {
|
|
|
1415
1437
|
if (envId) {
|
|
1416
1438
|
result = await enrichEnvInfoWithMissingFields(cloudbaseInfo, result, envId);
|
|
1417
1439
|
}
|
|
1418
|
-
result = enrichEnvInfoWithRuntimeMode(result);
|
|
1440
|
+
result = await enrichEnvInfoWithRuntimeMode(result, cloudbaseInfo);
|
|
1419
1441
|
break;
|
|
1420
1442
|
case "domains":
|
|
1421
1443
|
const cloudbaseDomains = await getManager();
|
|
@@ -1483,7 +1505,7 @@ function registerEnvTools(server) {
|
|
|
1483
1505
|
// Register primary tool name (queryEnv)
|
|
1484
1506
|
const queryEnvToolSchema = {
|
|
1485
1507
|
title: "CloudBase 环境查询",
|
|
1486
|
-
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` 时,`
|
|
1508
|
+
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 都不该使用。",
|
|
1487
1509
|
inputSchema: {
|
|
1488
1510
|
action: zod_1.z
|
|
1489
1511
|
.enum(["list", "info", "domains"])
|
|
@@ -2095,7 +2117,7 @@ ${envIdSection}
|
|
|
2095
2117
|
## 环境信息
|
|
2096
2118
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
2097
2119
|
- Node.js版本: ${process.version}
|
|
2098
|
-
- MCP 版本:${process.env.npm_package_version || "2.23.
|
|
2120
|
+
- MCP 版本:${process.env.npm_package_version || "2.23.6" || 0}
|
|
2099
2121
|
- 系统架构: ${os_1.default.arch()}
|
|
2100
2122
|
- 时间: ${new Date().toISOString()}
|
|
2101
2123
|
- 请求ID: ${requestId}
|
|
@@ -2176,7 +2198,7 @@ function createWrappedHandler(name, handler, server) {
|
|
|
2176
2198
|
requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
|
|
2177
2199
|
ide: server.ide || process.env.INTEGRATION_IDE || ''
|
|
2178
2200
|
});
|
|
2179
|
-
const mcpVersion = true ? "2.23.
|
|
2201
|
+
const mcpVersion = true ? "2.23.6" : 0;
|
|
2180
2202
|
const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
|
|
2181
2203
|
const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
|
|
2182
2204
|
// 创建新的错误对象,保持原有的错误类型但更新消息
|
|
@@ -2361,6 +2383,7 @@ const DEFAULT_PLUGINS = [
|
|
|
2361
2383
|
"database",
|
|
2362
2384
|
"pg_database",
|
|
2363
2385
|
"pg_storage",
|
|
2386
|
+
"mysql_database",
|
|
2364
2387
|
"functions",
|
|
2365
2388
|
"hosting",
|
|
2366
2389
|
"storage",
|
|
@@ -2383,10 +2406,6 @@ function registerDatabase(server) {
|
|
|
2383
2406
|
if (!(0, tencent_cloud_js_1.isInternationalRegion)(region)) {
|
|
2384
2407
|
(0, databaseNoSQL_js_1.registerDatabaseTools)(server);
|
|
2385
2408
|
}
|
|
2386
|
-
const pgPluginEnabled = server.enabledPlugins?.some((pluginName) => pluginName === "pg_database" || pluginName === "pg_storage");
|
|
2387
|
-
if (!pgPluginEnabled) {
|
|
2388
|
-
(0, databaseSQL_js_1.registerSQLDatabaseTools)(server);
|
|
2389
|
-
}
|
|
2390
2409
|
(0, dataModel_js_1.registerDataModelTools)(server);
|
|
2391
2410
|
}
|
|
2392
2411
|
function registerMysqlDatabase(server) {
|
|
@@ -9756,7 +9775,7 @@ class TelemetryReporter {
|
|
|
9756
9775
|
const nodeVersion = process.version; // Node.js版本
|
|
9757
9776
|
const arch = os_1.default.arch(); // 系统架构
|
|
9758
9777
|
// 从构建时注入的版本号获取MCP版本信息
|
|
9759
|
-
const mcpVersion = process.env.npm_package_version || "2.23.
|
|
9778
|
+
const mcpVersion = process.env.npm_package_version || "2.23.6" || 0;
|
|
9760
9779
|
return {
|
|
9761
9780
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
9762
9781
|
deviceId: this.deviceId,
|
|
@@ -13077,7 +13096,7 @@ function registerPermissionTools(server) {
|
|
|
13077
13096
|
}));
|
|
13078
13097
|
server.registerTool?.("managePermissions", {
|
|
13079
13098
|
title: "管理 CloudBase 权限与用户配置",
|
|
13080
|
-
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 语句(通过 `
|
|
13099
|
+
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`)。",
|
|
13081
13100
|
inputSchema: {
|
|
13082
13101
|
action: zod_1.z.enum(MANAGE_PERMISSION_ACTIONS),
|
|
13083
13102
|
resourceType: zod_1.z
|
|
@@ -13767,7 +13786,7 @@ function registerSetupTools(server) {
|
|
|
13767
13786
|
server.registerTool("downloadTemplate", {
|
|
13768
13787
|
title: "下载项目模板",
|
|
13769
13788
|
description: `自动下载并部署CloudBase项目模板。
|
|
13770
|
-
**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.
|
|
13789
|
+
**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)`,
|
|
13771
13790
|
inputSchema: {
|
|
13772
13791
|
template: zod_1.z
|
|
13773
13792
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
@@ -17264,7 +17283,7 @@ async function checkMysqlGate(server) {
|
|
|
17264
17283
|
success: false,
|
|
17265
17284
|
errorCode: "MYSQL_NOT_AVAILABLE",
|
|
17266
17285
|
message: `This environment (${envId}) does not have MySQL. Use managePgDatabase / queryPgDatabase instead.`,
|
|
17267
|
-
nextActions: [{ tool: "managePgDatabase", params: { action: "execute" }, description: "Use managePgDatabase" }],
|
|
17286
|
+
nextActions: [{ tool: "managePgDatabase", params: { action: "execute" }, description: "Use managePgDatabase for PostgreSQL operations" }],
|
|
17268
17287
|
});
|
|
17269
17288
|
}
|
|
17270
17289
|
try {
|
|
@@ -17276,7 +17295,7 @@ async function checkMysqlGate(server) {
|
|
|
17276
17295
|
return (0, tool_result_js_1.buildJsonToolResult)({
|
|
17277
17296
|
success: false,
|
|
17278
17297
|
errorCode: "MYSQL_NOT_AVAILABLE",
|
|
17279
|
-
message: `This environment (${envId}) has PostgreSQL enabled but MySQL is NOT available. Use managePgDatabase / queryPgDatabase instead of
|
|
17298
|
+
message: `This environment (${envId}) has PostgreSQL enabled but MySQL is NOT available. Use managePgDatabase / queryPgDatabase instead of manageMysqlDatabase / queryMysqlDatabase.`,
|
|
17280
17299
|
nextActions: [{ tool: "managePgDatabase", params: { action: "execute" }, description: "Use managePgDatabase for PostgreSQL operations" }],
|
|
17281
17300
|
});
|
|
17282
17301
|
}
|
|
@@ -17285,8 +17304,8 @@ async function checkMysqlGate(server) {
|
|
|
17285
17304
|
MYSQL_GATE_CACHE.set(envId, true);
|
|
17286
17305
|
return null;
|
|
17287
17306
|
}
|
|
17288
|
-
const
|
|
17289
|
-
const
|
|
17307
|
+
const QUERY_MYSQL_DATABASE = "queryMysqlDatabase";
|
|
17308
|
+
const MANAGE_MYSQL_DATABASE = "manageMysqlDatabase";
|
|
17290
17309
|
const QUERY_PERMISSIONS = "queryPermissions";
|
|
17291
17310
|
const MANAGE_PERMISSIONS = "managePermissions";
|
|
17292
17311
|
const QUERY_ACTIONS = [
|
|
@@ -17578,14 +17597,14 @@ async function getSqlInstanceInfo({ getManager, cloudBaseOptions, server, }) {
|
|
|
17578
17597
|
function buildProvisionNextActions(status, request) {
|
|
17579
17598
|
if (status === "READY") {
|
|
17580
17599
|
return [
|
|
17581
|
-
buildNextAction(
|
|
17600
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "initializeSchema", "MySQL is ready. Initialize tables and indexes next."),
|
|
17582
17601
|
];
|
|
17583
17602
|
}
|
|
17584
17603
|
if (status === "FAILED") {
|
|
17585
17604
|
return [];
|
|
17586
17605
|
}
|
|
17587
17606
|
return [
|
|
17588
|
-
buildNextAction(
|
|
17607
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "describeCreateResult", "MySQL provisioning is still running. Check the create result again before initializing schema.", request
|
|
17589
17608
|
? { action: "describeCreateResult", request }
|
|
17590
17609
|
: { action: "describeCreateResult" }),
|
|
17591
17610
|
];
|
|
@@ -17604,15 +17623,15 @@ function buildTaskStatusNextActions(status, request) {
|
|
|
17604
17623
|
if (status === "READY") {
|
|
17605
17624
|
if (inferTaskKind(request) === "destroy") {
|
|
17606
17625
|
return [
|
|
17607
|
-
buildNextAction(
|
|
17626
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "getInstanceInfo", "The destroy task completed. Confirm whether the MySQL instance no longer exists."),
|
|
17608
17627
|
];
|
|
17609
17628
|
}
|
|
17610
17629
|
return [
|
|
17611
|
-
buildNextAction(
|
|
17630
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "initializeSchema", "MySQL is ready. Initialize tables and indexes next."),
|
|
17612
17631
|
];
|
|
17613
17632
|
}
|
|
17614
17633
|
return [
|
|
17615
|
-
buildNextAction(
|
|
17634
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "describeTaskStatus", "MySQL task is still running. Check task status again before continuing.", request ? { action: "describeTaskStatus", request } : { action: "describeTaskStatus" }),
|
|
17616
17635
|
];
|
|
17617
17636
|
}
|
|
17618
17637
|
async function handleRunQuery(args, context) {
|
|
@@ -17622,7 +17641,7 @@ async function handleRunQuery(args, context) {
|
|
|
17622
17641
|
errorCode: "SQL_REQUIRED",
|
|
17623
17642
|
message: "`sql` is required when action is `runQuery`.",
|
|
17624
17643
|
nextActions: [
|
|
17625
|
-
buildNextAction(
|
|
17644
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "runQuery", "Provide a read-only SQL statement such as SELECT/SHOW/DESCRIBE."),
|
|
17626
17645
|
],
|
|
17627
17646
|
});
|
|
17628
17647
|
}
|
|
@@ -17630,9 +17649,9 @@ async function handleRunQuery(args, context) {
|
|
|
17630
17649
|
return buildSqlToolResult({
|
|
17631
17650
|
success: false,
|
|
17632
17651
|
errorCode: "READ_ONLY_SQL_REQUIRED",
|
|
17633
|
-
message: "`
|
|
17652
|
+
message: "`queryMysqlDatabase(action=runQuery)` only accepts read-only SQL statements.",
|
|
17634
17653
|
nextActions: [
|
|
17635
|
-
buildNextAction(
|
|
17654
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "runStatement", "Use the manage tool for INSERT/UPDATE/DELETE/DDL statements."),
|
|
17636
17655
|
],
|
|
17637
17656
|
});
|
|
17638
17657
|
}
|
|
@@ -17660,7 +17679,7 @@ async function handleRunQuery(args, context) {
|
|
|
17660
17679
|
errorCode: "MYSQL_NOT_CREATED",
|
|
17661
17680
|
message: "MySQL is not provisioned yet or not found. Please provision MySQL before running queries.",
|
|
17662
17681
|
nextActions: [
|
|
17663
|
-
buildNextAction(
|
|
17682
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before querying data.", { action: "provisionMySQL", confirm: true }),
|
|
17664
17683
|
],
|
|
17665
17684
|
});
|
|
17666
17685
|
}
|
|
@@ -17759,7 +17778,7 @@ async function handleGetInstanceInfo(context) {
|
|
|
17759
17778
|
nextActions: instanceInfo.exists
|
|
17760
17779
|
? undefined
|
|
17761
17780
|
: [
|
|
17762
|
-
buildNextAction(
|
|
17781
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before running SQL statements or schema initialization.", { action: "provisionMySQL", confirm: true }),
|
|
17763
17782
|
],
|
|
17764
17783
|
});
|
|
17765
17784
|
}
|
|
@@ -17770,7 +17789,7 @@ async function handleProvisionMySQL(args, context) {
|
|
|
17770
17789
|
errorCode: "CONFIRM_REQUIRED",
|
|
17771
17790
|
message: "Provisioning MySQL creates billable resources. Re-run with `confirm: true` to continue.",
|
|
17772
17791
|
nextActions: [
|
|
17773
|
-
buildNextAction(
|
|
17792
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Explicit confirmation is required before provisioning MySQL.", { action: "provisionMySQL", confirm: true }),
|
|
17774
17793
|
],
|
|
17775
17794
|
});
|
|
17776
17795
|
}
|
|
@@ -17784,7 +17803,7 @@ async function handleProvisionMySQL(args, context) {
|
|
|
17784
17803
|
message: "A SQL database instance already exists for the current environment.",
|
|
17785
17804
|
nextActions: existing.status === "READY"
|
|
17786
17805
|
? [
|
|
17787
|
-
buildNextAction(
|
|
17806
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "initializeSchema", "The instance already exists. You can initialize schema next if needed."),
|
|
17788
17807
|
]
|
|
17789
17808
|
: undefined,
|
|
17790
17809
|
});
|
|
@@ -17830,7 +17849,7 @@ async function handleDestroyMySQL(args, context) {
|
|
|
17830
17849
|
errorCode: "CONFIRM_REQUIRED",
|
|
17831
17850
|
message: "Destroying MySQL removes database resources. Re-run with `confirm: true` to continue.",
|
|
17832
17851
|
nextActions: [
|
|
17833
|
-
buildNextAction(
|
|
17852
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "destroyMySQL", "Explicit confirmation is required before destroying MySQL.", { action: "destroyMySQL", confirm: true }),
|
|
17834
17853
|
],
|
|
17835
17854
|
});
|
|
17836
17855
|
}
|
|
@@ -17877,7 +17896,7 @@ async function handleDestroyMySQL(args, context) {
|
|
|
17877
17896
|
: "MySQL destroy request was rejected.",
|
|
17878
17897
|
nextActions: isSuccess
|
|
17879
17898
|
? [
|
|
17880
|
-
buildNextAction(
|
|
17899
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "describeTaskStatus", "Check the MySQL destroy task status before assuming the instance is gone.", {
|
|
17881
17900
|
action: "describeTaskStatus",
|
|
17882
17901
|
request: taskRequest,
|
|
17883
17902
|
}),
|
|
@@ -17900,7 +17919,7 @@ async function handleRunStatement(args, context) {
|
|
|
17900
17919
|
errorCode: "MYSQL_NOT_CREATED",
|
|
17901
17920
|
message: "MySQL is not provisioned for the current environment yet.",
|
|
17902
17921
|
nextActions: [
|
|
17903
|
-
buildNextAction(
|
|
17922
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before executing write statements or DDL.", { action: "provisionMySQL", confirm: true }),
|
|
17904
17923
|
],
|
|
17905
17924
|
});
|
|
17906
17925
|
}
|
|
@@ -17910,7 +17929,7 @@ async function handleRunStatement(args, context) {
|
|
|
17910
17929
|
errorCode: "MYSQL_NOT_READY",
|
|
17911
17930
|
message: `MySQL is not ready yet (current status: ${instanceInfo.status}).`,
|
|
17912
17931
|
nextActions: [
|
|
17913
|
-
buildNextAction(
|
|
17932
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "getInstanceInfo", "Check current instance status before retrying the statement."),
|
|
17914
17933
|
],
|
|
17915
17934
|
});
|
|
17916
17935
|
}
|
|
@@ -17937,7 +17956,7 @@ async function handleRunStatement(args, context) {
|
|
|
17937
17956
|
errorCode: "MYSQL_NOT_CREATED",
|
|
17938
17957
|
message: "MySQL is not provisioned yet or not found. Please provision MySQL before running statements.",
|
|
17939
17958
|
nextActions: [
|
|
17940
|
-
buildNextAction(
|
|
17959
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before executing statements.", { action: "provisionMySQL", confirm: true }),
|
|
17941
17960
|
],
|
|
17942
17961
|
});
|
|
17943
17962
|
}
|
|
@@ -17966,7 +17985,7 @@ async function resolveInitializationReadiness(args, context) {
|
|
|
17966
17985
|
errorCode: "MYSQL_NOT_CREATED",
|
|
17967
17986
|
message: "MySQL is not provisioned yet. Initialize schema only after provisioning completes.",
|
|
17968
17987
|
nextActions: [
|
|
17969
|
-
buildNextAction(
|
|
17988
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before schema initialization.", { action: "provisionMySQL", confirm: true }),
|
|
17970
17989
|
],
|
|
17971
17990
|
}),
|
|
17972
17991
|
};
|
|
@@ -18006,7 +18025,7 @@ async function resolveInitializationReadiness(args, context) {
|
|
|
18006
18025
|
rawStatus,
|
|
18007
18026
|
},
|
|
18008
18027
|
nextActions: [
|
|
18009
|
-
buildNextAction(
|
|
18028
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "describeTaskStatus", "Check MySQL task status until the instance becomes ready.", args.statusContext?.taskStatusRequest
|
|
18010
18029
|
? {
|
|
18011
18030
|
action: "describeTaskStatus",
|
|
18012
18031
|
request: args.statusContext.taskStatusRequest,
|
|
@@ -18063,7 +18082,7 @@ async function handleInitializeSchema(args, context) {
|
|
|
18063
18082
|
errorCode: "MYSQL_NOT_CREATED",
|
|
18064
18083
|
message: "MySQL is not provisioned yet or not found. Please provision MySQL before initializing schema.",
|
|
18065
18084
|
nextActions: [
|
|
18066
|
-
buildNextAction(
|
|
18085
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", "Provision MySQL before executing statements.", { action: "provisionMySQL", confirm: true }),
|
|
18067
18086
|
],
|
|
18068
18087
|
});
|
|
18069
18088
|
}
|
|
@@ -18111,7 +18130,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
18111
18130
|
cloudBaseOptions,
|
|
18112
18131
|
server,
|
|
18113
18132
|
};
|
|
18114
|
-
server.registerTool?.(
|
|
18133
|
+
server.registerTool?.(QUERY_MYSQL_DATABASE, {
|
|
18115
18134
|
title: "查询 CloudBase MySQL 数据库状态或执行只读 SQL",
|
|
18116
18135
|
description: "查询 CloudBase MySQL 数据库信息。支持执行只读 SQL、查询 MySQL 开通结果、查询 MySQL 任务状态,以及获取当前实例上下文信息。",
|
|
18117
18136
|
inputSchema: {
|
|
@@ -18157,7 +18176,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
18157
18176
|
throw new Error(`Unsupported SQL query action: ${args.action}`);
|
|
18158
18177
|
}
|
|
18159
18178
|
});
|
|
18160
|
-
server.registerTool?.(
|
|
18179
|
+
server.registerTool?.(MANAGE_MYSQL_DATABASE, {
|
|
18161
18180
|
title: "管理 CloudBase MySQL 数据库生命周期或执行写入 SQL",
|
|
18162
18181
|
description: "管理 CloudBase MySQL 数据库资源。支持开通 MySQL、销毁 MySQL、执行写入 SQL/DDL,以及初始化数据库 Schema。注意:必须先开通 MySQL(action=provisionMySQL,confirm=true)才能执行 runStatement 或 initializeSchema。若 MySQL 尚未开通,工具会返回 MYSQL_NOT_CREATED 并给出开通的 nextAction 提示。",
|
|
18163
18182
|
inputSchema: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cloudbase-mcp",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.6",
|
|
4
4
|
"packageManager": "pnpm@10.8.0",
|
|
5
5
|
"description": "腾讯云开发 MCP Server,通过AI提示词和MCP协议+云开发,让开发更智能、更高效,当你在Cursor/ VSCode GitHub Copilot/WinSurf/CodeBuddy/Augment Code/Claude Code等AI编程工具里写代码时,它能自动帮你生成可直接部署的前后端应用+小程序,并一键发布到腾讯云开发 CloudBase。",
|
|
6
6
|
"main": "./dist/index.cjs",
|