@cloudbase/cloudbase-mcp 2.25.8 → 2.25.10

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.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import CloudBase from '@cloudbase/manager-node';
2
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
3
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
6
+ import type { ToolAnnotations as ToolAnnotations_2 } from '@modelcontextprotocol/sdk/types.js';
4
7
 
5
8
  export declare const ALL_SUPPORTED_RUNTIMES: ("Nodejs20.19" | "Nodejs18.15" | "Nodejs16.13" | "Nodejs14.18" | "Nodejs12.16" | "Nodejs10.15" | "Nodejs8.9" | "Python3.10" | "Python3.9" | "Python3.7" | "Python3.6" | "Python2.7" | "Php8.0" | "Php7.4" | "Php7.2" | "Java8" | "Java11" | "Golang1")[];
6
9
 
@@ -32,6 +35,19 @@ export declare type CloudBaseOptions = CloudBaseConfigBase & {
32
35
  requestFn?: CloudApiRequestFn;
33
36
  };
34
37
 
38
+ /**
39
+ * registerTool config with CloudBase `annotations.category` retained after
40
+ * MCP SDK >=1.26 closed ToolAnnotations to strip unknown keys at the type level.
41
+ */
42
+ export declare type CloudBaseRegisterToolConfig = {
43
+ title?: string;
44
+ description?: string;
45
+ inputSchema?: any;
46
+ outputSchema?: any;
47
+ annotations?: ToolAnnotations;
48
+ _meta?: Record<string, unknown>;
49
+ };
50
+
35
51
  /**
36
52
  * Create a manager with the provided CloudBase options, without using cache
37
53
  * @param cloudBaseOptions Provided CloudBase options
@@ -161,7 +177,7 @@ export declare interface ExtendedMcpServer extends McpServer {
161
177
  logger?: Logger;
162
178
  enabledPlugins?: string[];
163
179
  pluginOptions?: PluginOptions;
164
- /** 已注册工具的列表,供外部(如微信 IDE)提取并注册到自己的 MCP server */
180
+ /** Registered tools for external hosts (e.g. WeChat IDE) to re-register. */
165
181
  toolDefs: Array<{
166
182
  name: string;
167
183
  description: string;
@@ -169,6 +185,11 @@ export declare interface ExtendedMcpServer extends McpServer {
169
185
  handler: (input: any) => Promise<any>;
170
186
  }>;
171
187
  setLogger(logger: Logger): void;
188
+ /**
189
+ * Same as MCP SDK registerTool, but annotations may include CloudBase `category`.
190
+ * Handler typing stays intentionally loose to match existing tool call sites.
191
+ */
192
+ registerTool(name: string, config: CloudBaseRegisterToolConfig, cb: (...args: any[]) => any): RegisteredTool;
172
193
  }
173
194
 
174
195
  export declare function formatRuntimeList(): string;
@@ -528,6 +549,18 @@ declare class TelemetryReporter {
528
549
 
529
550
  export declare const telemetryReporter: TelemetryReporter;
530
551
 
552
+ export { Tool }
553
+
554
+ /**
555
+ * CloudBase extends MCP ToolAnnotations with a stable `category` hint used by
556
+ * IDE UIs for grouping. SDK >=1.26 types annotations as a closed/strip object,
557
+ * so we keep category via an intersection while still passing it through at
558
+ * runtime (listTools returns registered annotations without schema stripping).
559
+ */
560
+ export declare type ToolAnnotations = ToolAnnotations_2 & {
561
+ category?: string;
562
+ };
563
+
531
564
  export declare interface ToolResponse {
532
565
  success: boolean;
533
566
  [key: string]: any;
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
33
33
  exports.DEFAULT_CREATE_ENV_RESOURCES = exports.CREATE_ENV_RESOURCE_VALUES = void 0;
34
34
  exports.resolveCreateEnvResources = resolveCreateEnvResources;
35
35
  exports.simplifyEnvList = simplifyEnvList;
36
+ exports.isUsableNoSqlDatabaseEntry = isUsableNoSqlDatabaseEntry;
36
37
  exports.registerEnvTools = registerEnvTools;
37
38
  const toolbox_1 = __webpack_require__(2090);
38
39
  const zod_1 = __webpack_require__(2971);
@@ -597,19 +598,21 @@ async function enrichEnvInfoWithBilling(params) {
597
598
  * CloudBase environment can have any combination of:
598
599
  * - PostgreSQL (CloudBase PG / pgstore): signaled by `EnvInfo.PostgreSQL[]`
599
600
  * non-empty and/or `EnvInfo.Meta` containing `postgresql=enable`.
600
- * - NoSQL document database + the matching legacy COS-style bucket:
601
- * signaled by `EnvInfo.Databases[]` (with InstanceId / RUNNING) and the
602
- * bucket exposed in `EnvInfo.Storages[]`.
601
+ * - NoSQL document database (flexdb): signaled ONLY by a usable entry in
602
+ * `EnvInfo.Databases[]`. The usable signal is a non-empty `InstanceId`
603
+ * (FlexDB Tag, typically `tnt-...` — same value `getDatabaseInstanceId`
604
+ * / ListTables `Tag` consume) with `Status` missing or `RUNNING`.
605
+ * Cloud storage (`EnvInfo.Storages[]` / CreateEnv `storage`) is unrelated
606
+ * and must never flip `RuntimeBackends.nosql`.
603
607
  * - MySQL: signaled by a non-empty `EnvInfo.MysqlInstances[]` (or similar
604
608
  * field, name varies). In a pure PG environment this is absent.
605
609
  *
606
- * In particular: a CloudBase PG environment commonly STILL has the NoSQL
607
- * Database + Storage running in parallel. NoSQL is therefore "co-present"
608
- * — its collection APIs, NoSQL `securityRule`s, and the legacy
609
- * `app.uploadFile()` upload flow remain valid for collections / files
610
- * that already live there. The thing that is NOT a substitute for the new
611
- * PG surface is using NoSQL collections to model a brand-new business
612
- * table that the task explicitly puts in PG.
610
+ * In particular: a CloudBase PG environment commonly STILL has flexdb
611
+ * provisioned in parallel (`Databases[].InstanceId = tnt-...`). NoSQL is
612
+ * therefore "co-present" — its collection APIs and NoSQL `securityRule`s
613
+ * remain valid for collections that already live there. The thing that is
614
+ * NOT a substitute for the new PG surface is using NoSQL collections to
615
+ * model a brand-new business table that the task explicitly puts in PG.
613
616
  *
614
617
  * What this enrichment does:
615
618
  * - Adds `EnvInfo.RuntimeMode = "postgresql" | "nosql"` based on whether
@@ -617,11 +620,29 @@ async function enrichEnvInfoWithBilling(params) {
617
620
  * business data when set to "postgresql".
618
621
  * - Adds `EnvInfo.RuntimeBackends`, a structured snapshot of which
619
622
  * backends are actually available (postgresql / nosql / mysql), so the
620
- * agent does not have to re-read `Databases`/`Storages`/`PostgreSQL`.
623
+ * agent does not have to re-read `Databases`/`PostgreSQL`.
621
624
  * - Adds `EnvInfo.RuntimeModeHints` summarizing which API/tool to prefer
622
625
  * for new code, including an explicit `MysqlNotAvailable` line when
623
626
  * MySQL is absent — that one IS a hard "do not use" signal.
624
627
  */
628
+ /** Exported for unit tests / live-fixture checks against FlexDB InstanceId. */
629
+ function isUsableNoSqlDatabaseEntry(db) {
630
+ if (!db || typeof db !== "object") {
631
+ return false;
632
+ }
633
+ const entry = db;
634
+ const instanceId = typeof entry.InstanceId === "string" ? entry.InstanceId.trim() : "";
635
+ // Empty InstanceId means no flexdb tenant — same failure mode as
636
+ // getDatabaseInstanceId() throwing "无法获取数据库实例ID".
637
+ if (!instanceId) {
638
+ return false;
639
+ }
640
+ // Some API versions omit Status; when present, only RUNNING counts as usable.
641
+ if (entry.Status != null && String(entry.Status).toUpperCase() !== "RUNNING") {
642
+ return false;
643
+ }
644
+ return true;
645
+ }
625
646
  async function enrichEnvInfoWithRuntimeMode(result, manager) {
626
647
  const envInfo = result?.EnvInfo;
627
648
  if (!envInfo || typeof envInfo !== "object") {
@@ -634,14 +655,12 @@ async function enrichEnvInfoWithRuntimeMode(result, manager) {
634
655
  /^postgre[_]?sql$/i.test(item.Key) &&
635
656
  String(item.Value).toLowerCase() === "enable");
636
657
  const hasPostgresql = pgList.length > 0 || metaPostgresEnabled;
637
- // NoSQL document DB shows up under Databases[]; the matching legacy bucket
638
- // shows up under Storages[]. Treat NoSQL as available when either side is
639
- // non-empty (an old env may keep one without the other).
658
+ // NoSQL = flexdb tenant id on Databases[].InstanceId (typically tnt-...).
659
+ // Aligns with getDatabaseInstanceId() / ListTables Tag. Storage is unrelated.
640
660
  const databasesList = Array.isArray(envInfo.Databases)
641
661
  ? envInfo.Databases
642
662
  : [];
643
- const storagesList = Array.isArray(envInfo.Storages) ? envInfo.Storages : [];
644
- const hasNoSql = databasesList.length > 0 || storagesList.length > 0;
663
+ const hasNoSql = databasesList.some(isUsableNoSqlDatabaseEntry);
645
664
  // MySQL field name has been seen as MysqlInstances / MySQLInstances /
646
665
  // MySQL across API versions; check any of them.
647
666
  const mysqlList = (() => {
@@ -688,8 +707,8 @@ async function enrichEnvInfoWithRuntimeMode(result, manager) {
688
707
  Permissions: "PG table permissions use Row-Level Security. Run `ALTER TABLE ... ENABLE ROW LEVEL SECURITY` and `CREATE POLICY` via `managePgDatabase(action=\"execute\", confirm=true)`. `managePermissions(resourceType=\"noSqlDatabase\", securityRule=...)` only governs NoSQL collection rules and has NO effect on PG tables — keep using it for the NoSQL collections that already exist here.",
689
708
  Storage: "PG-mode browser uploads should use `app.storage.from().upload(<bucket>/<key>, file)` against an explicitly-created `pgstore` bucket (same model as Supabase Storage; the v3 SDK does not auto-create one). `EnvInfo.Storages[]` here is the legacy NoSQL bucket — it is still usable for the legacy `app.uploadFile()` flow but is NOT a valid pgstore target.",
690
709
  CoexistingNoSQL: hasNoSql
691
- ? "This env also has the legacy NoSQL Database + Storage running. Existing collections, existing `app.uploadFile()` calls, existing `managePermissions(resourceType=\"noSqlDatabase\")` rules all remain valid for legacy data."
692
- : "No legacy NoSQL Database/Storage observed in this env.",
710
+ ? "This env also has a usable NoSQL (flexdb) InstanceId in EnvInfo.Databases[] (FlexDB Tag, typically tnt-...). Existing collections and `managePermissions(resourceType=\"noSqlDatabase\")` rules remain valid for that data."
711
+ : "No usable NoSQL (flexdb) InstanceId in EnvInfo.Databases[] — do not assume app.database() / NoSQL MCP tools work. Cloud storage does not imply flexdb.",
693
712
  MysqlNotAvailable: hasMysql
694
713
  ? "MySQL instance(s) detected — see EnvInfo.MysqlInstances."
695
714
  : "No MySQL instance is provisioned for this env. Do NOT use `manageMysqlDatabase` / `queryMysqlDatabase` (those are MySQL-specific) and do NOT read the `relational-database-mcp-cloudbase` skill — that family targets MySQL, not CloudBase PG.",
@@ -2718,6 +2737,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
2718
2737
  return (mod && mod.__esModule) ? mod : { "default": mod };
2719
2738
  };
2720
2739
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2740
+ exports.applyCategoryAnnotationMeta = applyCategoryAnnotationMeta;
2721
2741
  exports.wrapServerWithTelemetry = wrapServerWithTelemetry;
2722
2742
  const os_1 = __importDefault(__webpack_require__(8116));
2723
2743
  const cloudbase_manager_js_1 = __webpack_require__(3431);
@@ -2725,6 +2745,30 @@ const cloud_mode_js_1 = __webpack_require__(9684);
2725
2745
  const logger_js_1 = __webpack_require__(3039);
2726
2746
  const telemetry_js_1 = __webpack_require__(5880);
2727
2747
  const tool_result_js_1 = __webpack_require__(9835);
2748
+ /**
2749
+ * Mirror annotations.category into _meta.category.
2750
+ *
2751
+ * MCP SDK Client >=1.26 parses tools/list with a stripping ToolAnnotationsSchema,
2752
+ * which drops unknown annotation keys. `_meta` remains available to clients, while
2753
+ * the server wire payload still includes annotations.category for non-SDK hosts.
2754
+ */
2755
+ function applyCategoryAnnotationMeta(config) {
2756
+ const category = config?.annotations?.category;
2757
+ if (typeof category !== "string" || category.length === 0) {
2758
+ return config;
2759
+ }
2760
+ const existingMeta = config._meta && typeof config._meta === "object" ? config._meta : undefined;
2761
+ if (existingMeta && existingMeta.category === category) {
2762
+ return config;
2763
+ }
2764
+ return {
2765
+ ...config,
2766
+ _meta: {
2767
+ ...existingMeta,
2768
+ category,
2769
+ },
2770
+ };
2771
+ }
2728
2772
  /**
2729
2773
  * 生成 GitHub Issue 创建链接
2730
2774
  * @param toolName 工具名称
@@ -2772,7 +2816,7 @@ ${envIdSection}
2772
2816
  ## 环境信息
2773
2817
  - 操作系统: ${os_1.default.type()} ${os_1.default.release()}
2774
2818
  - Node.js版本: ${process.version}
2775
- - MCP 版本:${process.env.npm_package_version || "2.25.8" || 0}
2819
+ - MCP 版本:${process.env.npm_package_version || ( true ? "2.25.10" : 0)}
2776
2820
  - 系统架构: ${os_1.default.arch()}
2777
2821
  - 时间: ${new Date().toISOString()}
2778
2822
  - 请求ID: ${requestId}
@@ -2853,7 +2897,7 @@ function createWrappedHandler(name, handler, server) {
2853
2897
  requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
2854
2898
  ide: server.ide || process.env.INTEGRATION_IDE || ''
2855
2899
  });
2856
- const mcpVersion = true ? "2.25.8" : 0;
2900
+ const mcpVersion = true ? "2.25.10" : 0;
2857
2901
  const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
2858
2902
  const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
2859
2903
  // 创建新的错误对象,保持原有的错误类型但更新消息
@@ -2950,7 +2994,7 @@ function wrapServerWithTelemetry(server) {
2950
2994
  // Use the wrapped handler, passing the server instance
2951
2995
  const wrappedHandler = createWrappedHandler(toolName, handler, server);
2952
2996
  // Call the original registerTool method
2953
- return originalRegisterTool(toolName, toolConfig, wrappedHandler);
2997
+ return originalRegisterTool(toolName, applyCategoryAnnotationMeta(toolConfig ?? {}), wrappedHandler);
2954
2998
  };
2955
2999
  }
2956
3000
  /**
@@ -3189,14 +3233,15 @@ async function createCloudBaseMcpServer(options) {
3189
3233
  server.toolDefs = [];
3190
3234
  const originalRegisterTool = server.registerTool.bind(server);
3191
3235
  server.registerTool = ((name, meta, handler) => {
3236
+ const toolMeta = (0, tool_wrapper_js_1.applyCategoryAnnotationMeta)(meta ?? {});
3192
3237
  // 同步记录到 toolDefs
3193
3238
  server.toolDefs.push({
3194
3239
  name,
3195
- description: meta?.description ?? meta?.title ?? '',
3196
- inputSchema: meta?.inputSchema ?? {},
3240
+ description: toolMeta?.description ?? toolMeta?.title ?? '',
3241
+ inputSchema: toolMeta?.inputSchema ?? {},
3197
3242
  handler,
3198
3243
  });
3199
- return originalRegisterTool(name, meta, async (args) => {
3244
+ return originalRegisterTool(name, toolMeta, async (args) => {
3200
3245
  try {
3201
3246
  return await handler(args);
3202
3247
  }
@@ -7576,6 +7621,7 @@ async function registerRagTools(server) {
7576
7621
  强烈推荐始终优先使用固定技能文档 (skill)、OpenAPI 文档 (openapi) 或 CloudBase 官方文档 (docs) 模式进行检索,仅当固定文档无法覆盖你的问题时,再使用向量查询 (vector) 模式。
7577
7622
 
7578
7623
  ⚠️ 重要:当 CloudBase skills 处于禁用状态或当前 IDE 不支持 skill 文件读取时,必须使用 searchKnowledgeBase(mode=skill, skillName=...) 来获取 CloudBase 技能文档内容,而不是尝试直接读取 skill 文件。直接读取可能返回 400 错误。示例:
7624
+ - 需要最小 Web+数据库 Demo 路径时:searchKnowledgeBase(mode=skill, skillName=minimal-web-baas-demo)
7579
7625
  - 需要 auth-tool 指南时:searchKnowledgeBase(mode=skill, skillName=auth-tool)
7580
7626
  - 需要 auth-web 指南时:searchKnowledgeBase(mode=skill, skillName=auth-web)
7581
7627
  - 需要 cloudbase-agent 指南时:searchKnowledgeBase(mode=skill, skillName=cloudbase-agent)
@@ -11207,8 +11253,9 @@ class TelemetryReporter {
11207
11253
  const osRelease = os_1.default.release(); // 操作系统版本
11208
11254
  const nodeVersion = process.version; // Node.js版本
11209
11255
  const arch = os_1.default.arch(); // 系统架构
11210
- // 从构建时注入的版本号获取MCP版本信息
11211
- const mcpVersion = process.env.npm_package_version || "2.25.8" || 0;
11256
+ // Build-time injected version; guard for vitest / non-webpack runtimes.
11257
+ const mcpVersion = process.env.npm_package_version ||
11258
+ ( true ? "2.25.10" : 0);
11212
11259
  return {
11213
11260
  userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
11214
11261
  deviceId: this.deviceId,
@@ -16743,7 +16790,7 @@ function registerSetupTools(server) {
16743
16790
  server.registerTool("downloadTemplate", {
16744
16791
  title: "下载项目模板",
16745
16792
  description: `自动下载并部署CloudBase项目模板。
16746
- **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.25.8" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
16793
+ **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.25.10" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
16747
16794
  inputSchema: {
16748
16795
  template: zod_1.z
16749
16796
  .enum(["react", "vue", "miniprogram", "uniapp", "rules"])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cloudbase-mcp",
3
- "version": "2.25.8",
3
+ "version": "2.25.10",
4
4
  "packageManager": "pnpm@10.8.0",
5
5
  "description": "CloudBase MCP Server — operate Tencent CloudBase (database, auth, functions, storage, hosting) from AI coding tools via the Model Context Protocol. Part of CloudBase AI Toolkit.",
6
6
  "main": "./dist/index.cjs",
@@ -69,7 +69,6 @@
69
69
  "dependencies": {},
70
70
  "devDependencies": {
71
71
  "@microsoft/api-extractor": "^7.57.6",
72
- "@modelcontextprotocol/sdk": "^1.13.3",
73
72
  "@rollup/plugin-commonjs": "^28.0.1",
74
73
  "@rollup/plugin-inject": "^5.0.5",
75
74
  "@rollup/plugin-json": "^6.1.0",