@cloudbase/cloudbase-mcp 2.16.0-beta.1 → 2.16.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/index.cjs CHANGED
@@ -39846,17 +39846,34 @@ async function handleRunQuery(args, context) {
39846
39846
  }
39847
39847
  const cloudbase = await context.getManager();
39848
39848
  const dbContext = await resolveSqlDbContext(context.getManager, context.cloudBaseOptions, args.dbInstance);
39849
- const result = await callSqlControlPlane(cloudbase, "RunSql", {
39850
- EnvId: dbContext.envId,
39851
- Sql: args.sql,
39852
- ReadOnly: true,
39853
- DbInstance: {
39849
+ let result;
39850
+ try {
39851
+ result = await callSqlControlPlane(cloudbase, "RunSql", {
39854
39852
  EnvId: dbContext.envId,
39855
- InstanceId: dbContext.instanceId,
39856
- Schema: dbContext.schema,
39857
- },
39858
- });
39859
- (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
39853
+ Sql: args.sql,
39854
+ ReadOnly: true,
39855
+ DbInstance: {
39856
+ EnvId: dbContext.envId,
39857
+ InstanceId: dbContext.instanceId,
39858
+ Schema: dbContext.schema,
39859
+ },
39860
+ });
39861
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
39862
+ }
39863
+ catch (error) {
39864
+ const errorCode = typeof error === "object" && error && "code" in error ? error.code : "";
39865
+ if (errorCode === "FailedOperation.DataSourceNotExist" || error.message?.includes("Database instance not found")) {
39866
+ return buildSqlToolResult({
39867
+ success: false,
39868
+ errorCode: "MYSQL_NOT_CREATED",
39869
+ message: "MySQL is not provisioned yet or not found. Please provision MySQL before running queries.",
39870
+ nextActions: [
39871
+ buildNextAction(MANAGE_SQL_DATABASE, "provisionMySQL", "Provision MySQL before querying data.", { action: "provisionMySQL", confirm: true }),
39872
+ ],
39873
+ });
39874
+ }
39875
+ throw error;
39876
+ }
39860
39877
  const normalized = normalizeRunSqlResult(result);
39861
39878
  return buildSqlToolResult({
39862
39879
  success: true,
@@ -40107,16 +40124,33 @@ async function handleRunStatement(args, context) {
40107
40124
  }
40108
40125
  const cloudbase = await context.getManager();
40109
40126
  const dbContext = await resolveSqlDbContext(context.getManager, context.cloudBaseOptions, args.dbInstance);
40110
- const result = await callSqlControlPlane(cloudbase, "RunSql", {
40111
- EnvId: dbContext.envId,
40112
- Sql: args.sql,
40113
- DbInstance: {
40127
+ let result;
40128
+ try {
40129
+ result = await callSqlControlPlane(cloudbase, "RunSql", {
40114
40130
  EnvId: dbContext.envId,
40115
- InstanceId: dbContext.instanceId,
40116
- Schema: dbContext.schema,
40117
- },
40118
- });
40119
- (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
40131
+ Sql: args.sql,
40132
+ DbInstance: {
40133
+ EnvId: dbContext.envId,
40134
+ InstanceId: dbContext.instanceId,
40135
+ Schema: dbContext.schema,
40136
+ },
40137
+ });
40138
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
40139
+ }
40140
+ catch (error) {
40141
+ const errorCode = typeof error === "object" && error && "code" in error ? error.code : "";
40142
+ if (errorCode === "FailedOperation.DataSourceNotExist" || error.message?.includes("Database instance not found")) {
40143
+ return buildSqlToolResult({
40144
+ success: false,
40145
+ errorCode: "MYSQL_NOT_CREATED",
40146
+ message: "MySQL is not provisioned yet or not found. Please provision MySQL before running statements.",
40147
+ nextActions: [
40148
+ buildNextAction(MANAGE_SQL_DATABASE, "provisionMySQL", "Provision MySQL before executing statements.", { action: "provisionMySQL", confirm: true }),
40149
+ ],
40150
+ });
40151
+ }
40152
+ throw error;
40153
+ }
40120
40154
  const statementType = getSqlVerb(args.sql) || "UNKNOWN";
40121
40155
  const normalized = normalizeRunSqlResult(result);
40122
40156
  return buildSqlToolResult({
@@ -40216,16 +40250,33 @@ async function handleInitializeSchema(args, context) {
40216
40250
  const requestIdList = [];
40217
40251
  for (const statement of args.statements) {
40218
40252
  try {
40219
- const result = await callSqlControlPlane(cloudbase, "RunSql", {
40220
- EnvId: dbContext.envId,
40221
- Sql: statement,
40222
- DbInstance: {
40253
+ let result;
40254
+ try {
40255
+ result = await callSqlControlPlane(cloudbase, "RunSql", {
40223
40256
  EnvId: dbContext.envId,
40224
- InstanceId: dbContext.instanceId,
40225
- Schema: dbContext.schema,
40226
- },
40227
- });
40228
- (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
40257
+ Sql: statement,
40258
+ DbInstance: {
40259
+ EnvId: dbContext.envId,
40260
+ InstanceId: dbContext.instanceId,
40261
+ Schema: dbContext.schema,
40262
+ },
40263
+ });
40264
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
40265
+ }
40266
+ catch (error) {
40267
+ const errorCode = typeof error === "object" && error && "code" in error ? error.code : "";
40268
+ if (errorCode === "FailedOperation.DataSourceNotExist" || error.message?.includes("Database instance not found")) {
40269
+ return buildSqlToolResult({
40270
+ success: false,
40271
+ errorCode: "MYSQL_NOT_CREATED",
40272
+ message: "MySQL is not provisioned yet or not found. Please provision MySQL before initializing schema.",
40273
+ nextActions: [
40274
+ buildNextAction(MANAGE_SQL_DATABASE, "provisionMySQL", "Provision MySQL before executing statements.", { action: "provisionMySQL", confirm: true }),
40275
+ ],
40276
+ });
40277
+ }
40278
+ throw error;
40279
+ }
40229
40280
  const normalized = normalizeRunSqlResult(result);
40230
40281
  if (typeof normalized.requestId === "string") {
40231
40282
  requestIdList.push(normalized.requestId);
@@ -132946,7 +132997,7 @@ class TelemetryReporter {
132946
132997
  const nodeVersion = process.version; // Node.js版本
132947
132998
  const arch = os_1.default.arch(); // 系统架构
132948
132999
  // 从构建时注入的版本号获取MCP版本信息
132949
- const mcpVersion = process.env.npm_package_version || "2.16.0-beta.1" || 0;
133000
+ const mcpVersion = process.env.npm_package_version || "2.16.1" || 0;
132950
133001
  return {
132951
133002
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
132952
133003
  deviceId: this.deviceId,
@@ -190997,7 +191048,7 @@ ${envIdSection}
190997
191048
  ## 环境信息
190998
191049
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
190999
191050
  - Node.js版本: ${process.version}
191000
- - MCP 版本:${process.env.npm_package_version || "2.16.0-beta.1" || 0}
191051
+ - MCP 版本:${process.env.npm_package_version || "2.16.1" || 0}
191001
191052
  - 系统架构: ${os_1.default.arch()}
191002
191053
  - 时间: ${new Date().toISOString()}
191003
191054
  - 请求ID: ${requestId}
@@ -199112,7 +199163,7 @@ function registerDatabaseTools(server) {
199112
199163
  // readNoSqlDatabaseStructure
199113
199164
  server.registerTool?.("readNoSqlDatabaseStructure", {
199114
199165
  title: "读取 NoSQL 数据库结构",
199115
- description: "读取 NoSQL 数据库结构",
199166
+ description: "读取 NoSQL 数据库集合与索引结构,支持列出集合、查看集合详情、列出索引以及检查索引是否存在。",
199116
199167
  inputSchema: {
199117
199168
  action: zod_1.z.enum([
199118
199169
  "listCollections",
@@ -199121,10 +199172,10 @@ function registerDatabaseTools(server) {
199121
199172
  "listIndexes",
199122
199173
  "checkIndex",
199123
199174
  ]).describe(`listCollections: 列出集合列表
199124
- describeCollection: 描述集合
199175
+ describeCollection: 描述集合详情(会返回索引摘要)
199125
199176
  checkCollection: 检查集合是否存在
199126
- listIndexes: 列出索引列表
199127
- checkIndex: 检查索引是否存在`),
199177
+ listIndexes: 列出指定集合的索引列表
199178
+ checkIndex: 检查指定索引是否存在`),
199128
199179
  limit: zod_1.z
199129
199180
  .number()
199130
199181
  .optional()
@@ -199260,38 +199311,42 @@ checkIndex: 检查索引是否存在`),
199260
199311
  // writeNoSqlDatabaseStructure
199261
199312
  server.registerTool?.("writeNoSqlDatabaseStructure", {
199262
199313
  title: "修改 NoSQL 数据库结构",
199263
- description: "修改 NoSQL 数据库结构",
199314
+ description: "修改 NoSQL 数据库结构,支持创建/删除集合,以及通过 updateCollection 的 updateOptions.CreateIndexes / updateOptions.DropIndexes 添加索引和删除索引。",
199264
199315
  inputSchema: {
199265
199316
  action: zod_1.z.enum([
199266
199317
  "createCollection",
199267
199318
  "updateCollection",
199268
199319
  "deleteCollection",
199269
199320
  ]).describe(`createCollection: 创建集合
199270
- updateCollection: 更新集合
199321
+ updateCollection: 更新集合配置;添加索引请传 updateOptions.CreateIndexes,删除索引请传 updateOptions.DropIndexes
199271
199322
  deleteCollection: 删除集合`),
199272
199323
  collectionName: zod_1.z.string().describe("集合名称"),
199273
199324
  updateOptions: zod_1.z
199274
199325
  .object({
199275
199326
  CreateIndexes: zod_1.z
199276
199327
  .array(zod_1.z.object({
199277
- IndexName: zod_1.z.string(),
199328
+ IndexName: zod_1.z.string().describe("要创建的索引名称"),
199278
199329
  MgoKeySchema: zod_1.z.object({
199279
- MgoIsUnique: zod_1.z.boolean(),
199330
+ MgoIsUnique: zod_1.z.boolean().describe("是否唯一索引"),
199280
199331
  MgoIndexKeys: zod_1.z.array(zod_1.z.object({
199281
- Name: zod_1.z.string(),
199282
- Direction: zod_1.z.string(),
199283
- })),
199284
- }),
199332
+ Name: zod_1.z.string().describe("索引字段名"),
199333
+ Direction: zod_1.z
199334
+ .string()
199335
+ .describe("索引方向,通常 1 表示升序,-1 表示降序"),
199336
+ })).describe("索引字段列表,支持单字段或复合索引"),
199337
+ }).describe("待创建索引的字段与约束配置"),
199285
199338
  }))
199286
- .optional(),
199339
+ .optional()
199340
+ .describe("要添加的索引列表"),
199287
199341
  DropIndexes: zod_1.z
199288
199342
  .array(zod_1.z.object({
199289
- IndexName: zod_1.z.string(),
199343
+ IndexName: zod_1.z.string().describe("要删除的索引名称"),
199290
199344
  }))
199291
- .optional(),
199345
+ .optional()
199346
+ .describe("要删除的索引列表"),
199292
199347
  })
199293
199348
  .optional()
199294
- .describe("更新选项(updateCollection 时使用)"),
199349
+ .describe("更新选项(updateCollection 时使用)。CreateIndexes 用于添加索引,DropIndexes 用于删除索引。"),
199295
199350
  },
199296
199351
  annotations: {
199297
199352
  readOnlyHint: false,
@@ -205156,7 +205211,7 @@ function registerSetupTools(server) {
205156
205211
  title: "下载项目模板",
205157
205212
  description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
205158
205213
 
205159
- **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.16.0-beta.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
205214
+ **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.16.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
205160
205215
  inputSchema: {
205161
205216
  template: zod_1.z
205162
205217
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
@@ -222298,12 +222353,25 @@ function registerGatewayTools(server) {
222298
222353
  }
222299
222354
  const cloudbase = await getManager();
222300
222355
  const accessPath = normalizeAccessPath(input.path || `/${input.targetName}`);
222301
- const result = await cloudbase.access.createAccess({
222302
- name: input.targetName,
222303
- path: accessPath,
222304
- type: ((input.type || "Event") === "HTTP" ? 6 : 1),
222305
- auth: input.auth,
222306
- });
222356
+ let result;
222357
+ try {
222358
+ result = await cloudbase.access.createAccess({
222359
+ name: input.targetName,
222360
+ path: accessPath,
222361
+ type: ((input.type || "Event") === "HTTP" ? 6 : 1),
222362
+ auth: input.auth,
222363
+ });
222364
+ }
222365
+ catch (err) {
222366
+ if (err.message && err.message.includes("An error has occurred")) {
222367
+ let hint = "为目标资源配置访问路由失败(后端内部错误)。请确保:1) 目标云函数已成功创建并处于 Active 状态;2) 环境默认 HTTP 域名已完成初始化;3) 该访问路径未被占用。";
222368
+ if (input.type === "HTTP") {
222369
+ hint += "此外注意:如果目标函数最初是作为 Event 函数创建的,这里 type 必须依然传 Event(或省略),传 HTTP 会导致此错误。";
222370
+ }
222371
+ throw new Error(`${hint} 原始错误:${err.message}`);
222372
+ }
222373
+ throw err;
222374
+ }
222307
222375
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
222308
222376
  return buildEnvelope({
222309
222377
  action: input.action,
@@ -222479,7 +222547,7 @@ function registerGatewayTools(server) {
222479
222547
  .describe("目标资源类型。当前支持 function,后续可扩展"),
222480
222548
  targetName: zod_1.z.string().optional().describe("目标资源名称"),
222481
222549
  path: zod_1.z.string().optional().describe("访问路径,默认 /{targetName}"),
222482
- type: zod_1.z.enum(["Event", "HTTP"]).optional().describe("函数接入类型"),
222550
+ type: zod_1.z.enum(["Event", "HTTP"]).optional().describe("目标函数的本身类型(非接入形式)。如果被访问的函数是 Event 型(默认),此处必须传 Event;只有当被访问函数在创建时就是 HTTP 函数时才传 HTTP。"),
222483
222551
  auth: zod_1.z.boolean().optional().describe("是否开启鉴权"),
222484
222552
  route: zod_1.z
222485
222553
  .object({
package/dist/index.js CHANGED
@@ -1509,7 +1509,7 @@ ${envIdSection}
1509
1509
  ## 环境信息
1510
1510
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
1511
1511
  - Node.js版本: ${process.version}
1512
- - MCP 版本:${process.env.npm_package_version || "2.16.0-beta.1" || 0}
1512
+ - MCP 版本:${process.env.npm_package_version || "2.16.1" || 0}
1513
1513
  - 系统架构: ${os_1.default.arch()}
1514
1514
  - 时间: ${new Date().toISOString()}
1515
1515
  - 请求ID: ${requestId}
@@ -3692,7 +3692,7 @@ function registerDatabaseTools(server) {
3692
3692
  // readNoSqlDatabaseStructure
3693
3693
  server.registerTool?.("readNoSqlDatabaseStructure", {
3694
3694
  title: "读取 NoSQL 数据库结构",
3695
- description: "读取 NoSQL 数据库结构",
3695
+ description: "读取 NoSQL 数据库集合与索引结构,支持列出集合、查看集合详情、列出索引以及检查索引是否存在。",
3696
3696
  inputSchema: {
3697
3697
  action: zod_1.z.enum([
3698
3698
  "listCollections",
@@ -3701,10 +3701,10 @@ function registerDatabaseTools(server) {
3701
3701
  "listIndexes",
3702
3702
  "checkIndex",
3703
3703
  ]).describe(`listCollections: 列出集合列表
3704
- describeCollection: 描述集合
3704
+ describeCollection: 描述集合详情(会返回索引摘要)
3705
3705
  checkCollection: 检查集合是否存在
3706
- listIndexes: 列出索引列表
3707
- checkIndex: 检查索引是否存在`),
3706
+ listIndexes: 列出指定集合的索引列表
3707
+ checkIndex: 检查指定索引是否存在`),
3708
3708
  limit: zod_1.z
3709
3709
  .number()
3710
3710
  .optional()
@@ -3840,38 +3840,42 @@ checkIndex: 检查索引是否存在`),
3840
3840
  // writeNoSqlDatabaseStructure
3841
3841
  server.registerTool?.("writeNoSqlDatabaseStructure", {
3842
3842
  title: "修改 NoSQL 数据库结构",
3843
- description: "修改 NoSQL 数据库结构",
3843
+ description: "修改 NoSQL 数据库结构,支持创建/删除集合,以及通过 updateCollection 的 updateOptions.CreateIndexes / updateOptions.DropIndexes 添加索引和删除索引。",
3844
3844
  inputSchema: {
3845
3845
  action: zod_1.z.enum([
3846
3846
  "createCollection",
3847
3847
  "updateCollection",
3848
3848
  "deleteCollection",
3849
3849
  ]).describe(`createCollection: 创建集合
3850
- updateCollection: 更新集合
3850
+ updateCollection: 更新集合配置;添加索引请传 updateOptions.CreateIndexes,删除索引请传 updateOptions.DropIndexes
3851
3851
  deleteCollection: 删除集合`),
3852
3852
  collectionName: zod_1.z.string().describe("集合名称"),
3853
3853
  updateOptions: zod_1.z
3854
3854
  .object({
3855
3855
  CreateIndexes: zod_1.z
3856
3856
  .array(zod_1.z.object({
3857
- IndexName: zod_1.z.string(),
3857
+ IndexName: zod_1.z.string().describe("要创建的索引名称"),
3858
3858
  MgoKeySchema: zod_1.z.object({
3859
- MgoIsUnique: zod_1.z.boolean(),
3859
+ MgoIsUnique: zod_1.z.boolean().describe("是否唯一索引"),
3860
3860
  MgoIndexKeys: zod_1.z.array(zod_1.z.object({
3861
- Name: zod_1.z.string(),
3862
- Direction: zod_1.z.string(),
3863
- })),
3864
- }),
3861
+ Name: zod_1.z.string().describe("索引字段名"),
3862
+ Direction: zod_1.z
3863
+ .string()
3864
+ .describe("索引方向,通常 1 表示升序,-1 表示降序"),
3865
+ })).describe("索引字段列表,支持单字段或复合索引"),
3866
+ }).describe("待创建索引的字段与约束配置"),
3865
3867
  }))
3866
- .optional(),
3868
+ .optional()
3869
+ .describe("要添加的索引列表"),
3867
3870
  DropIndexes: zod_1.z
3868
3871
  .array(zod_1.z.object({
3869
- IndexName: zod_1.z.string(),
3872
+ IndexName: zod_1.z.string().describe("要删除的索引名称"),
3870
3873
  }))
3871
- .optional(),
3874
+ .optional()
3875
+ .describe("要删除的索引列表"),
3872
3876
  })
3873
3877
  .optional()
3874
- .describe("更新选项(updateCollection 时使用)"),
3878
+ .describe("更新选项(updateCollection 时使用)。CreateIndexes 用于添加索引,DropIndexes 用于删除索引。"),
3875
3879
  },
3876
3880
  annotations: {
3877
3881
  readOnlyHint: false,
@@ -6106,12 +6110,25 @@ function registerGatewayTools(server) {
6106
6110
  }
6107
6111
  const cloudbase = await getManager();
6108
6112
  const accessPath = normalizeAccessPath(input.path || `/${input.targetName}`);
6109
- const result = await cloudbase.access.createAccess({
6110
- name: input.targetName,
6111
- path: accessPath,
6112
- type: ((input.type || "Event") === "HTTP" ? 6 : 1),
6113
- auth: input.auth,
6114
- });
6113
+ let result;
6114
+ try {
6115
+ result = await cloudbase.access.createAccess({
6116
+ name: input.targetName,
6117
+ path: accessPath,
6118
+ type: ((input.type || "Event") === "HTTP" ? 6 : 1),
6119
+ auth: input.auth,
6120
+ });
6121
+ }
6122
+ catch (err) {
6123
+ if (err.message && err.message.includes("An error has occurred")) {
6124
+ let hint = "为目标资源配置访问路由失败(后端内部错误)。请确保:1) 目标云函数已成功创建并处于 Active 状态;2) 环境默认 HTTP 域名已完成初始化;3) 该访问路径未被占用。";
6125
+ if (input.type === "HTTP") {
6126
+ hint += "此外注意:如果目标函数最初是作为 Event 函数创建的,这里 type 必须依然传 Event(或省略),传 HTTP 会导致此错误。";
6127
+ }
6128
+ throw new Error(`${hint} 原始错误:${err.message}`);
6129
+ }
6130
+ throw err;
6131
+ }
6115
6132
  (0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
6116
6133
  return buildEnvelope({
6117
6134
  action: input.action,
@@ -6287,7 +6304,7 @@ function registerGatewayTools(server) {
6287
6304
  .describe("目标资源类型。当前支持 function,后续可扩展"),
6288
6305
  targetName: zod_1.z.string().optional().describe("目标资源名称"),
6289
6306
  path: zod_1.z.string().optional().describe("访问路径,默认 /{targetName}"),
6290
- type: zod_1.z.enum(["Event", "HTTP"]).optional().describe("函数接入类型"),
6307
+ type: zod_1.z.enum(["Event", "HTTP"]).optional().describe("目标函数的本身类型(非接入形式)。如果被访问的函数是 Event 型(默认),此处必须传 Event;只有当被访问函数在创建时就是 HTTP 函数时才传 HTTP。"),
6291
6308
  auth: zod_1.z.boolean().optional().describe("是否开启鉴权"),
6292
6309
  route: zod_1.z
6293
6310
  .object({
@@ -7866,7 +7883,7 @@ class TelemetryReporter {
7866
7883
  const nodeVersion = process.version; // Node.js版本
7867
7884
  const arch = os_1.default.arch(); // 系统架构
7868
7885
  // 从构建时注入的版本号获取MCP版本信息
7869
- const mcpVersion = process.env.npm_package_version || "2.16.0-beta.1" || 0;
7886
+ const mcpVersion = process.env.npm_package_version || "2.16.1" || 0;
7870
7887
  return {
7871
7888
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
7872
7889
  deviceId: this.deviceId,
@@ -10062,7 +10079,7 @@ function registerSetupTools(server) {
10062
10079
  title: "下载项目模板",
10063
10080
  description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
10064
10081
 
10065
- **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.16.0-beta.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
10082
+ **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.16.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
10066
10083
  inputSchema: {
10067
10084
  template: zod_1.z
10068
10085
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
@@ -12969,17 +12986,34 @@ async function handleRunQuery(args, context) {
12969
12986
  }
12970
12987
  const cloudbase = await context.getManager();
12971
12988
  const dbContext = await resolveSqlDbContext(context.getManager, context.cloudBaseOptions, args.dbInstance);
12972
- const result = await callSqlControlPlane(cloudbase, "RunSql", {
12973
- EnvId: dbContext.envId,
12974
- Sql: args.sql,
12975
- ReadOnly: true,
12976
- DbInstance: {
12989
+ let result;
12990
+ try {
12991
+ result = await callSqlControlPlane(cloudbase, "RunSql", {
12977
12992
  EnvId: dbContext.envId,
12978
- InstanceId: dbContext.instanceId,
12979
- Schema: dbContext.schema,
12980
- },
12981
- });
12982
- (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
12993
+ Sql: args.sql,
12994
+ ReadOnly: true,
12995
+ DbInstance: {
12996
+ EnvId: dbContext.envId,
12997
+ InstanceId: dbContext.instanceId,
12998
+ Schema: dbContext.schema,
12999
+ },
13000
+ });
13001
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
13002
+ }
13003
+ catch (error) {
13004
+ const errorCode = typeof error === "object" && error && "code" in error ? error.code : "";
13005
+ if (errorCode === "FailedOperation.DataSourceNotExist" || error.message?.includes("Database instance not found")) {
13006
+ return buildSqlToolResult({
13007
+ success: false,
13008
+ errorCode: "MYSQL_NOT_CREATED",
13009
+ message: "MySQL is not provisioned yet or not found. Please provision MySQL before running queries.",
13010
+ nextActions: [
13011
+ buildNextAction(MANAGE_SQL_DATABASE, "provisionMySQL", "Provision MySQL before querying data.", { action: "provisionMySQL", confirm: true }),
13012
+ ],
13013
+ });
13014
+ }
13015
+ throw error;
13016
+ }
12983
13017
  const normalized = normalizeRunSqlResult(result);
12984
13018
  return buildSqlToolResult({
12985
13019
  success: true,
@@ -13230,16 +13264,33 @@ async function handleRunStatement(args, context) {
13230
13264
  }
13231
13265
  const cloudbase = await context.getManager();
13232
13266
  const dbContext = await resolveSqlDbContext(context.getManager, context.cloudBaseOptions, args.dbInstance);
13233
- const result = await callSqlControlPlane(cloudbase, "RunSql", {
13234
- EnvId: dbContext.envId,
13235
- Sql: args.sql,
13236
- DbInstance: {
13267
+ let result;
13268
+ try {
13269
+ result = await callSqlControlPlane(cloudbase, "RunSql", {
13237
13270
  EnvId: dbContext.envId,
13238
- InstanceId: dbContext.instanceId,
13239
- Schema: dbContext.schema,
13240
- },
13241
- });
13242
- (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
13271
+ Sql: args.sql,
13272
+ DbInstance: {
13273
+ EnvId: dbContext.envId,
13274
+ InstanceId: dbContext.instanceId,
13275
+ Schema: dbContext.schema,
13276
+ },
13277
+ });
13278
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
13279
+ }
13280
+ catch (error) {
13281
+ const errorCode = typeof error === "object" && error && "code" in error ? error.code : "";
13282
+ if (errorCode === "FailedOperation.DataSourceNotExist" || error.message?.includes("Database instance not found")) {
13283
+ return buildSqlToolResult({
13284
+ success: false,
13285
+ errorCode: "MYSQL_NOT_CREATED",
13286
+ message: "MySQL is not provisioned yet or not found. Please provision MySQL before running statements.",
13287
+ nextActions: [
13288
+ buildNextAction(MANAGE_SQL_DATABASE, "provisionMySQL", "Provision MySQL before executing statements.", { action: "provisionMySQL", confirm: true }),
13289
+ ],
13290
+ });
13291
+ }
13292
+ throw error;
13293
+ }
13243
13294
  const statementType = getSqlVerb(args.sql) || "UNKNOWN";
13244
13295
  const normalized = normalizeRunSqlResult(result);
13245
13296
  return buildSqlToolResult({
@@ -13339,16 +13390,33 @@ async function handleInitializeSchema(args, context) {
13339
13390
  const requestIdList = [];
13340
13391
  for (const statement of args.statements) {
13341
13392
  try {
13342
- const result = await callSqlControlPlane(cloudbase, "RunSql", {
13343
- EnvId: dbContext.envId,
13344
- Sql: statement,
13345
- DbInstance: {
13393
+ let result;
13394
+ try {
13395
+ result = await callSqlControlPlane(cloudbase, "RunSql", {
13346
13396
  EnvId: dbContext.envId,
13347
- InstanceId: dbContext.instanceId,
13348
- Schema: dbContext.schema,
13349
- },
13350
- });
13351
- (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
13397
+ Sql: statement,
13398
+ DbInstance: {
13399
+ EnvId: dbContext.envId,
13400
+ InstanceId: dbContext.instanceId,
13401
+ Schema: dbContext.schema,
13402
+ },
13403
+ });
13404
+ (0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
13405
+ }
13406
+ catch (error) {
13407
+ const errorCode = typeof error === "object" && error && "code" in error ? error.code : "";
13408
+ if (errorCode === "FailedOperation.DataSourceNotExist" || error.message?.includes("Database instance not found")) {
13409
+ return buildSqlToolResult({
13410
+ success: false,
13411
+ errorCode: "MYSQL_NOT_CREATED",
13412
+ message: "MySQL is not provisioned yet or not found. Please provision MySQL before initializing schema.",
13413
+ nextActions: [
13414
+ buildNextAction(MANAGE_SQL_DATABASE, "provisionMySQL", "Provision MySQL before executing statements.", { action: "provisionMySQL", confirm: true }),
13415
+ ],
13416
+ });
13417
+ }
13418
+ throw error;
13419
+ }
13352
13420
  const normalized = normalizeRunSqlResult(result);
13353
13421
  if (typeof normalized.requestId === "string") {
13354
13422
  requestIdList.push(normalized.requestId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cloudbase-mcp",
3
- "version": "2.16.0-beta.1",
3
+ "version": "2.16.1",
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",