@cloudbase/cloudbase-mcp 2.23.7 → 2.23.9
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 +136 -164
- package/dist/index.d.ts +0 -12
- package/dist/index.js +136 -180
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,7 +13,6 @@ import * as __WEBPACK_EXTERNAL_MODULE_https__ from "https";
|
|
|
13
13
|
import * as __WEBPACK_EXTERNAL_MODULE_net__ from "net";
|
|
14
14
|
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
15
15
|
import * as __WEBPACK_EXTERNAL_MODULE__modelcontextprotocol_sdk_server_mcp_js_45c326f0__ from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
16
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_path_02319fef__ from "node:path";
|
|
17
16
|
import * as __WEBPACK_EXTERNAL_MODULE_child_process__ from "child_process";
|
|
18
17
|
import * as __WEBPACK_EXTERNAL_MODULE_ws__ from "ws";
|
|
19
18
|
import * as __WEBPACK_EXTERNAL_MODULE__cloudbase_manager_node_6a52ea40__ from "@cloudbase/manager-node";
|
|
@@ -24,7 +23,6 @@ import * as __WEBPACK_EXTERNAL_MODULE_crypto__ from "crypto";
|
|
|
24
23
|
import * as __WEBPACK_EXTERNAL_MODULE_fs_promises_f8dae9d1__ from "fs/promises";
|
|
25
24
|
import * as __WEBPACK_EXTERNAL_MODULE_os__ from "os";
|
|
26
25
|
import * as __WEBPACK_EXTERNAL_MODULE_winston__ from "winston";
|
|
27
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_75ed2103__ from "node:fs";
|
|
28
26
|
/******/ var __webpack_modules__ = ({
|
|
29
27
|
|
|
30
28
|
/***/ 622:
|
|
@@ -2202,7 +2200,7 @@ ${envIdSection}
|
|
|
2202
2200
|
## 环境信息
|
|
2203
2201
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
2204
2202
|
- Node.js版本: ${process.version}
|
|
2205
|
-
- MCP 版本:${process.env.npm_package_version || "2.23.
|
|
2203
|
+
- MCP 版本:${process.env.npm_package_version || "2.23.9" || 0}
|
|
2206
2204
|
- 系统架构: ${os_1.default.arch()}
|
|
2207
2205
|
- 时间: ${new Date().toISOString()}
|
|
2208
2206
|
- 请求ID: ${requestId}
|
|
@@ -2283,7 +2281,7 @@ function createWrappedHandler(name, handler, server) {
|
|
|
2283
2281
|
requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
|
|
2284
2282
|
ide: server.ide || process.env.INTEGRATION_IDE || ''
|
|
2285
2283
|
});
|
|
2286
|
-
const mcpVersion = true ? "2.23.
|
|
2284
|
+
const mcpVersion = true ? "2.23.9" : 0;
|
|
2287
2285
|
const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
|
|
2288
2286
|
const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
|
|
2289
2287
|
// 创建新的错误对象,保持原有的错误类型但更新消息
|
|
@@ -8269,14 +8267,43 @@ const ManageCloudRunInputSchema = {
|
|
|
8269
8267
|
})).optional().describe('扩缩容配置数组,用于配置服务的自动扩缩容策略。可配置多个扩缩容策略'),
|
|
8270
8268
|
CustomLogs: zod_1.z.string().optional().describe('自定义日志配置,用于配置服务的日志收集和存储策略'),
|
|
8271
8269
|
Port: zod_1.z.number().min(1).max(65535).optional().describe('服务监听端口配置。函数型服务固定为3000,容器型服务可自定义。服务代码必须监听此端口才能正常接收请求'),
|
|
8272
|
-
EnvParams: zod_1.z.string().optional().describe('环境变量配置,JSON字符串格式。用于传递配置信息给服务代码,如\'{"DATABASE_URL":"mysql://...","NODE_ENV":"production"}\'
|
|
8270
|
+
EnvParams: zod_1.z.string().optional().describe('环境变量配置,JSON字符串格式。用于传递配置信息给服务代码,如\'{"DATABASE_URL":"mysql://...","NODE_ENV":"production"}\'。SDK v5.6.1+ 会自动对传入的环境变量进行 AES-256-CBC 加密传输'),
|
|
8273
8271
|
Dockerfile: zod_1.z.string().optional().describe('Dockerfile文件名配置,仅容器型服务需要。指定用于构建容器镜像的Dockerfile文件路径,默认为项目根目录下的Dockerfile'),
|
|
8274
8272
|
BuildDir: zod_1.z.string().optional().describe('构建目录配置,指定代码构建的目录路径。当代码结构与标准不同时使用,默认为项目根目录'),
|
|
8275
8273
|
InternalAccess: zod_1.z.string().optional().describe('内网访问开关配置,控制是否启用内网访问。true=启用内网访问(可通过云开发SDK直接调用),false=关闭内网访问(仅公网访问)'),
|
|
8276
8274
|
InternalDomain: zod_1.z.string().optional().describe('内网域名配置,用于配置服务的内网访问域名。仅在启用内网访问时有效'),
|
|
8277
8275
|
EntryPoint: zod_1.z.array(zod_1.z.string()).optional().describe('Dockerfile EntryPoint参数配置,仅容器型服务需要。指定容器启动时的入口程序数组,如["node","app.js"]'),
|
|
8278
8276
|
Cmd: zod_1.z.array(zod_1.z.string()).optional().describe('Dockerfile Cmd参数配置,仅容器型服务需要。指定容器启动时的默认命令数组,如["npm","start"]'),
|
|
8279
|
-
|
|
8277
|
+
InitialDelaySeconds: zod_1.z.number().min(0).optional().describe('延迟检测时间(秒),用于配置服务启动后的健康检查延迟。在此期间内不会将请求路由到该实例,适用于启动时间较长的服务'),
|
|
8278
|
+
LogType: zod_1.z.string().optional().describe('日志类型配置,指定服务的日志收集类型。影响日志的采集方式和存储格式'),
|
|
8279
|
+
LogSetId: zod_1.z.string().optional().describe('CLS日志集ID配置,指定日志服务(CLS)的日志集ID。需要先开通CLS日志服务'),
|
|
8280
|
+
LogTopicId: zod_1.z.string().optional().describe('CLS日志主题ID配置,指定日志服务(CLS)的日志主题ID。需要先开通CLS日志服务'),
|
|
8281
|
+
LogParseType: zod_1.z.string().optional().describe('日志解析类型配置,指定日志的解析方式。用于将原始日志解析为结构化数据'),
|
|
8282
|
+
Tag: zod_1.z.string().optional().describe('服务标签配置,用于标识服务类型。如设置为"function:"表示函数型服务。SDK会自动根据配置生成'),
|
|
8283
|
+
OperationMode: zod_1.z.string().optional().describe('运行模式配置,指定服务的运行模式。影响服务的调度和资源分配方式'),
|
|
8284
|
+
SessionAffinity: zod_1.z.string().optional().describe('会话保持配置,用于控制是否启用会话保持功能。启用后会将同一客户端的请求路由到同一实例'),
|
|
8285
|
+
TimerScale: zod_1.z.array(zod_1.z.object({
|
|
8286
|
+
CycleType: zod_1.z.enum(['none', 'daily', 'weekly', 'monthly']).describe('循环类型:none=无循环,daily=每日循环,weekly=每周循环,monthly=每月循环'),
|
|
8287
|
+
StartDate: zod_1.z.string().optional().describe('循环起始日期,格式:YYYY-MM-DD'),
|
|
8288
|
+
EndDate: zod_1.z.string().optional().describe('循环结束日期,格式:YYYY-MM-DD'),
|
|
8289
|
+
StartTime: zod_1.z.string().describe('起始时间,格式:HH:mm:ss'),
|
|
8290
|
+
EndTime: zod_1.z.string().describe('结束时间,格式:HH:mm:ss'),
|
|
8291
|
+
ReplicaNum: zod_1.z.number().min(0).describe('定时扩缩容的目标副本数,最小值0(缩容到0)')
|
|
8292
|
+
})).optional().describe('定时扩缩容配置数组,用于配置服务的定时自动扩缩容策略。可配置多个时间段的扩缩容计划,支持每日/每周/每月循环'),
|
|
8293
|
+
VpcConf: zod_1.z.object({
|
|
8294
|
+
VpcId: zod_1.z.string().describe('VPC网络ID,指定服务所在的私有网络'),
|
|
8295
|
+
SubnetId: zod_1.z.string().describe('子网ID,指定服务所在的子网'),
|
|
8296
|
+
}).optional().describe('VPC网络配置,用于将云托管服务部署到指定的私有网络中。需要提前创建好VPC和子网'),
|
|
8297
|
+
VolumesConf: zod_1.z.array(zod_1.z.object({
|
|
8298
|
+
VolumeName: zod_1.z.string().describe('存储卷名称'),
|
|
8299
|
+
VolumeType: zod_1.z.string().describe('存储卷类型,如CFS表示云文件存储'),
|
|
8300
|
+
VolumePath: zod_1.z.string().describe('存储卷挂载路径,服务代码中的目标路径')
|
|
8301
|
+
})).optional().describe('存储卷配置数组,用于挂载云存储(如CFS)到服务实例中。可用于持久化数据或共享文件'),
|
|
8302
|
+
PublicNetConf: zod_1.z.object({
|
|
8303
|
+
PublicAccess: zod_1.z.boolean().optional().describe('是否开启公网访问,true=开启公网访问,false=关闭公网访问'),
|
|
8304
|
+
PublicAccessPath: zod_1.z.string().optional().describe('公网访问路径配置')
|
|
8305
|
+
}).optional().describe('公网访问配置,用于控制服务的公网访问策略。可配置是否开启公网访问及访问路径'),
|
|
8306
|
+
}).optional().describe('服务配置项,用于部署时设置服务的运行参数。包括资源规格、访问权限、环境变量、日志、网络等配置。不提供时使用默认配置'),
|
|
8280
8307
|
// Init operation parameters
|
|
8281
8308
|
template: zod_1.z.string().optional().default('helloworld').describe('项目模板标识符,用于指定初始化项目时使用的模板。可通过queryCloudRun的templates操作获取可用模板列表。常用模板:helloworld=Hello World示例,nodejs=Node.js项目模板,python=Python项目模板等'),
|
|
8282
8309
|
// Run operation parameters (function services only)
|
|
@@ -9812,13 +9839,6 @@ function registerAppAuthTools(server) {
|
|
|
9812
9839
|
}
|
|
9813
9840
|
|
|
9814
9841
|
|
|
9815
|
-
/***/ }),
|
|
9816
|
-
|
|
9817
|
-
/***/ 5663:
|
|
9818
|
-
/***/ ((module) => {
|
|
9819
|
-
|
|
9820
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_02319fef__;
|
|
9821
|
-
|
|
9822
9842
|
/***/ }),
|
|
9823
9843
|
|
|
9824
9844
|
/***/ 5814:
|
|
@@ -9888,7 +9908,7 @@ class TelemetryReporter {
|
|
|
9888
9908
|
const nodeVersion = process.version; // Node.js版本
|
|
9889
9909
|
const arch = os_1.default.arch(); // 系统架构
|
|
9890
9910
|
// 从构建时注入的版本号获取MCP版本信息
|
|
9891
|
-
const mcpVersion = process.env.npm_package_version || "2.23.
|
|
9911
|
+
const mcpVersion = process.env.npm_package_version || "2.23.9" || 0;
|
|
9892
9912
|
return {
|
|
9893
9913
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
9894
9914
|
deviceId: this.deviceId,
|
|
@@ -11558,16 +11578,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_ws__;
|
|
|
11558
11578
|
/***/ }),
|
|
11559
11579
|
|
|
11560
11580
|
/***/ 6473:
|
|
11561
|
-
/***/ (
|
|
11581
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
11562
11582
|
|
|
11563
11583
|
|
|
11564
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11565
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11566
|
-
};
|
|
11567
11584
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11585
|
+
exports.__resetPgReadyCache = __resetPgReadyCache;
|
|
11568
11586
|
exports.registerPGDatabaseTools = registerPGDatabaseTools;
|
|
11569
|
-
const node_fs_1 = __webpack_require__(9627);
|
|
11570
|
-
const node_path_1 = __importDefault(__webpack_require__(5663));
|
|
11571
11587
|
const zod_1 = __webpack_require__(2971);
|
|
11572
11588
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
11573
11589
|
const tool_result_js_1 = __webpack_require__(9835);
|
|
@@ -11582,7 +11598,6 @@ const QUERY_ACTIONS = [
|
|
|
11582
11598
|
"sql",
|
|
11583
11599
|
];
|
|
11584
11600
|
const MANAGE_ACTIONS = [
|
|
11585
|
-
"init",
|
|
11586
11601
|
"execute",
|
|
11587
11602
|
"dryRun",
|
|
11588
11603
|
"planMigration",
|
|
@@ -11603,63 +11618,19 @@ function buildNextAction(tool, action, reason, suggestedArgs) {
|
|
|
11603
11618
|
reason,
|
|
11604
11619
|
};
|
|
11605
11620
|
}
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
async function
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
try {
|
|
11615
|
-
const raw = await node_fs_1.promises.readFile(getPgContextStorePath(), "utf8");
|
|
11616
|
-
return JSON.parse(raw);
|
|
11617
|
-
}
|
|
11618
|
-
catch {
|
|
11619
|
-
return undefined;
|
|
11620
|
-
}
|
|
11621
|
-
}
|
|
11622
|
-
async function savePgContext(server, context) {
|
|
11623
|
-
server.pgRuntimeContext = context;
|
|
11624
|
-
if (!process.env.CLOUDBASE_PG_CONTEXT_PATH) {
|
|
11625
|
-
return;
|
|
11626
|
-
}
|
|
11627
|
-
const storePath = getPgContextStorePath();
|
|
11628
|
-
await node_fs_1.promises.mkdir(node_path_1.default.dirname(storePath), { recursive: true });
|
|
11629
|
-
await node_fs_1.promises.writeFile(storePath, JSON.stringify(context, null, 2), {
|
|
11630
|
-
encoding: "utf8",
|
|
11631
|
-
mode: 0o600,
|
|
11632
|
-
});
|
|
11633
|
-
await node_fs_1.promises.chmod(storePath, 0o600).catch(() => undefined);
|
|
11634
|
-
}
|
|
11635
|
-
async function getPgContext(server) {
|
|
11636
|
-
if (server.pgRuntimeContext) {
|
|
11637
|
-
return server.pgRuntimeContext;
|
|
11638
|
-
}
|
|
11639
|
-
const stored = await loadStoredPgContext();
|
|
11640
|
-
if (stored) {
|
|
11641
|
-
server.pgRuntimeContext = stored;
|
|
11642
|
-
}
|
|
11643
|
-
return stored;
|
|
11644
|
-
}
|
|
11645
|
-
function buildMissingContextResult() {
|
|
11646
|
-
return buildPgToolResult({
|
|
11647
|
-
success: false,
|
|
11648
|
-
errorCode: "PG_CONTEXT_NOT_INITIALIZED",
|
|
11649
|
-
message: "PostgreSQL context is not initialized yet. Call managePgDatabase(action=init) to bind the current CloudBase environment's built-in PostgreSQL runtime.",
|
|
11650
|
-
nextActions: [
|
|
11651
|
-
buildNextAction(MANAGE_PG_DATABASE, "init", "初始化 CloudBase PG 云端执行上下文,然后再查询 schema 或执行 SQL。", { action: "init" }),
|
|
11652
|
-
],
|
|
11653
|
-
});
|
|
11654
|
-
}
|
|
11655
|
-
function sanitizePgContext(context) {
|
|
11621
|
+
/**
|
|
11622
|
+
* 从 cloudBaseOptions + args 推导 PG 执行上下文(无状态)
|
|
11623
|
+
* 照搬 MySQL 的 resolveSqlDbContext 模式
|
|
11624
|
+
*/
|
|
11625
|
+
async function resolvePgDbContext(cloudBaseOptions, args) {
|
|
11626
|
+
const envId = args?.envId ??
|
|
11627
|
+
cloudBaseOptions?.envId ??
|
|
11628
|
+
(await (0, cloudbase_manager_js_1.getEnvId)(cloudBaseOptions));
|
|
11656
11629
|
return {
|
|
11657
|
-
envId
|
|
11658
|
-
instanceId:
|
|
11659
|
-
defaultSchema:
|
|
11660
|
-
|
|
11661
|
-
bootstrapMode: context.bootstrapMode,
|
|
11662
|
-
role: context.role,
|
|
11630
|
+
envId,
|
|
11631
|
+
instanceId: args?.instanceId ?? "cloudbase-pg",
|
|
11632
|
+
defaultSchema: args?.defaultSchema ?? "public",
|
|
11633
|
+
role: args?.role ?? "cloudbase_admin",
|
|
11663
11634
|
};
|
|
11664
11635
|
}
|
|
11665
11636
|
function normalizeLimit(limit, fallback = 20, max = 200) {
|
|
@@ -12227,89 +12198,65 @@ function createManagerPgClient(context, cloudBaseOptions) {
|
|
|
12227
12198
|
function sleep(ms) {
|
|
12228
12199
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
12229
12200
|
}
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
|
|
12201
|
+
/**
|
|
12202
|
+
* 模块级 Promise 缓存:同一 server 生命周期内只探测一次 PG 就绪状态
|
|
12203
|
+
* 照搬 MySQL lazy 就绪检查模式,避免每次业务调用都 SELECT 1
|
|
12204
|
+
*/
|
|
12205
|
+
let pgReadyPromise = null;
|
|
12206
|
+
/**
|
|
12207
|
+
* @internal 重置就绪探测缓存(仅供测试使用)
|
|
12208
|
+
*/
|
|
12209
|
+
function __resetPgReadyCache() {
|
|
12210
|
+
pgReadyPromise = null;
|
|
12211
|
+
}
|
|
12212
|
+
/**
|
|
12213
|
+
* 首次 SQL 调用时探测 PG 就绪,Promise 缓存避免重复探测
|
|
12214
|
+
* 探测失败抛错,由调用方捕获返回 PG_NOT_READY 错误码
|
|
12215
|
+
*/
|
|
12216
|
+
async function ensurePgReadyOnce(cloudBaseOptions, deps) {
|
|
12217
|
+
if (pgReadyPromise) {
|
|
12218
|
+
return pgReadyPromise;
|
|
12219
|
+
}
|
|
12220
|
+
pgReadyPromise = (async () => {
|
|
12221
|
+
const context = await resolvePgDbContext(cloudBaseOptions);
|
|
12222
|
+
const maxAttempts = deps.readyCheckOptions?.maxAttempts ?? 20;
|
|
12223
|
+
const retryDelayMs = deps.readyCheckOptions?.retryDelayMs ?? 1000;
|
|
12224
|
+
let lastError;
|
|
12225
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
12226
|
+
try {
|
|
12227
|
+
await withPgClient(context, deps, async (client) => {
|
|
12228
|
+
await client.query("SELECT 1");
|
|
12229
|
+
});
|
|
12230
|
+
return;
|
|
12231
|
+
}
|
|
12232
|
+
catch (error) {
|
|
12233
|
+
lastError = error;
|
|
12234
|
+
if (attempt === maxAttempts) {
|
|
12235
|
+
break;
|
|
12236
|
+
}
|
|
12237
|
+
await sleep(retryDelayMs);
|
|
12245
12238
|
}
|
|
12246
|
-
await sleep(retryDelayMs);
|
|
12247
12239
|
}
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
async function handleInit(args, server, deps) {
|
|
12253
|
-
const existing = await getPgContext(server);
|
|
12254
|
-
const resolvedEnvId = args.envId ??
|
|
12255
|
-
server.cloudBaseOptions?.envId ??
|
|
12256
|
-
process.env.CLOUDBASE_ENV_ID ??
|
|
12257
|
-
existing?.envId;
|
|
12258
|
-
if (!resolvedEnvId) {
|
|
12259
|
-
return buildPgToolResult({
|
|
12260
|
-
success: false,
|
|
12261
|
-
errorCode: "ENV_ID_REQUIRED",
|
|
12262
|
-
message: "CloudBase PostgreSQL only supports the built-in cloud runtime. Provide envId or bind a CloudBase environment before calling managePgDatabase(action=init).",
|
|
12263
|
-
});
|
|
12264
|
-
}
|
|
12265
|
-
const bootstrapResult = {
|
|
12266
|
-
instanceId: args.instanceId ?? "cloudbase-pg",
|
|
12267
|
-
defaultSchema: args.defaultSchema ?? "public",
|
|
12268
|
-
status: "ready",
|
|
12269
|
-
runtimeMode: "cloudbase-manager",
|
|
12270
|
-
role: args.role ?? "cloudbase_admin",
|
|
12271
|
-
};
|
|
12272
|
-
const now = new Date().toISOString();
|
|
12273
|
-
const context = {
|
|
12274
|
-
envId: resolvedEnvId,
|
|
12275
|
-
instanceId: bootstrapResult.instanceId,
|
|
12276
|
-
defaultSchema: bootstrapResult.defaultSchema,
|
|
12277
|
-
runtimeMode: "cloudbase-manager",
|
|
12278
|
-
bootstrapMode: "cloud",
|
|
12279
|
-
role: bootstrapResult.role,
|
|
12280
|
-
createdAt: existing?.createdAt ?? now,
|
|
12281
|
-
updatedAt: now,
|
|
12282
|
-
};
|
|
12283
|
-
await ensurePgReady(context, deps, deps.readyCheckOptions);
|
|
12284
|
-
await savePgContext(server, context);
|
|
12285
|
-
return buildPgToolResult({
|
|
12286
|
-
success: true,
|
|
12287
|
-
data: {
|
|
12288
|
-
context: {
|
|
12289
|
-
...sanitizePgContext(context),
|
|
12290
|
-
},
|
|
12291
|
-
status: bootstrapResult.status,
|
|
12292
|
-
},
|
|
12293
|
-
message: "CloudBase PG 云端执行上下文已就绪。先查询对象或 schema,再执行写入 SQL。",
|
|
12294
|
-
nextActions: [
|
|
12295
|
-
buildNextAction(QUERY_PG_DATABASE, "objects", "List schema-qualified database objects before drilling into a specific table.", { action: "objects", limit: 20 }),
|
|
12296
|
-
buildSchemaNextAction("Inspect a concrete schema-qualified table after you know which object matters.", `${context.defaultSchema}.your_table`),
|
|
12297
|
-
],
|
|
12298
|
-
});
|
|
12240
|
+
const reason = lastError instanceof Error ? lastError.message : String(lastError);
|
|
12241
|
+
throw new Error(`PostgreSQL is not ready after ${maxAttempts} attempts. Last error: ${reason}`);
|
|
12242
|
+
})();
|
|
12243
|
+
return pgReadyPromise;
|
|
12299
12244
|
}
|
|
12300
12245
|
async function handleQueryContext(server) {
|
|
12301
|
-
const context = await
|
|
12302
|
-
if (!context) {
|
|
12303
|
-
return buildMissingContextResult();
|
|
12304
|
-
}
|
|
12246
|
+
const context = await resolvePgDbContext(server.cloudBaseOptions);
|
|
12305
12247
|
return buildPgToolResult({
|
|
12306
12248
|
success: true,
|
|
12307
12249
|
data: {
|
|
12308
12250
|
context: {
|
|
12309
|
-
|
|
12251
|
+
envId: context.envId,
|
|
12252
|
+
instanceId: context.instanceId,
|
|
12253
|
+
defaultSchema: context.defaultSchema,
|
|
12254
|
+
runtimeMode: "cloudbase-manager",
|
|
12255
|
+
bootstrapMode: "cloud",
|
|
12256
|
+
role: context.role,
|
|
12310
12257
|
},
|
|
12311
12258
|
},
|
|
12312
|
-
message: "Resolved current CloudBase PostgreSQL context.",
|
|
12259
|
+
message: "Resolved current CloudBase PostgreSQL context (auto-derived).",
|
|
12313
12260
|
nextActions: [
|
|
12314
12261
|
buildNextAction(QUERY_PG_DATABASE, "objects", "List schema-qualified objects before inspecting an individual table.", { action: "objects", limit: 20 }),
|
|
12315
12262
|
],
|
|
@@ -12705,9 +12652,20 @@ function registerPGDatabaseTools(server, providedDeps) {
|
|
|
12705
12652
|
if (args.action === "context") {
|
|
12706
12653
|
return handleQueryContext(server);
|
|
12707
12654
|
}
|
|
12708
|
-
const context = await
|
|
12709
|
-
|
|
12710
|
-
|
|
12655
|
+
const context = await resolvePgDbContext(server.cloudBaseOptions);
|
|
12656
|
+
try {
|
|
12657
|
+
await ensurePgReadyOnce(server.cloudBaseOptions, deps);
|
|
12658
|
+
}
|
|
12659
|
+
catch (error) {
|
|
12660
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
12661
|
+
return buildPgToolResult({
|
|
12662
|
+
success: false,
|
|
12663
|
+
errorCode: "PG_NOT_READY",
|
|
12664
|
+
message: `CloudBase PostgreSQL is not ready. ${reason}`,
|
|
12665
|
+
nextActions: [
|
|
12666
|
+
buildNextAction("queryEnv", "info", "检查当前环境 PostgreSQL 实例状态。", { action: "info", envId: context.envId }),
|
|
12667
|
+
],
|
|
12668
|
+
});
|
|
12711
12669
|
}
|
|
12712
12670
|
switch (args.action) {
|
|
12713
12671
|
case "objects":
|
|
@@ -12728,11 +12686,11 @@ function registerPGDatabaseTools(server, providedDeps) {
|
|
|
12728
12686
|
});
|
|
12729
12687
|
server.registerTool?.(MANAGE_PG_DATABASE, {
|
|
12730
12688
|
title: "管理 PostgreSQL 上下文或执行写入 SQL",
|
|
12731
|
-
description: "管理 CloudBase PostgreSQL MCP
|
|
12689
|
+
description: "管理 CloudBase PostgreSQL:执行已确认的写入 SQL 或 DDL、SQL 风险预检、迁移规划。上下文自动从当前 MCP 环境推导,无需 init。仅支持 CloudBase 内置 PostgreSQL 云端 Manager SDK 执行路径。",
|
|
12732
12690
|
inputSchema: {
|
|
12733
12691
|
action: zod_1.z
|
|
12734
12692
|
.enum(MANAGE_ACTIONS)
|
|
12735
|
-
.describe("操作类型:
|
|
12693
|
+
.describe("操作类型:execute=执行已确认的写入 SQL 或 DDL;dryRun=只分析 SQL 风险不执行;planMigration=通过 PreviewPGUserMigrations 预览迁移计划;applyMigration=通过 PushPGUserMigrations 应用迁移;listMigrations=查询已应用的 Migration 列表;migrationDetail=查看单条 Migration 详情;rollbackMigration=回滚指定 Migration"),
|
|
12736
12694
|
sql: zod_1.z
|
|
12737
12695
|
.string()
|
|
12738
12696
|
.optional()
|
|
@@ -12748,11 +12706,11 @@ function registerPGDatabaseTools(server, providedDeps) {
|
|
|
12748
12706
|
instanceId: zod_1.z
|
|
12749
12707
|
.string()
|
|
12750
12708
|
.optional()
|
|
12751
|
-
.describe("可选的 PostgreSQL
|
|
12709
|
+
.describe("可选的 PostgreSQL 逻辑实例标识,默认 cloudbase-pg。"),
|
|
12752
12710
|
defaultSchema: zod_1.z
|
|
12753
12711
|
.string()
|
|
12754
12712
|
.optional()
|
|
12755
|
-
.describe("
|
|
12713
|
+
.describe("可选的默认 schema,默认 public。"),
|
|
12756
12714
|
role: zod_1.z
|
|
12757
12715
|
.string()
|
|
12758
12716
|
.optional()
|
|
@@ -12770,13 +12728,23 @@ function registerPGDatabaseTools(server, providedDeps) {
|
|
|
12770
12728
|
category: CATEGORY,
|
|
12771
12729
|
},
|
|
12772
12730
|
}, async (args) => {
|
|
12731
|
+
const context = await resolvePgDbContext(server.cloudBaseOptions, args);
|
|
12732
|
+
const cbOpts = server.cloudBaseOptions;
|
|
12773
12733
|
switch (args.action) {
|
|
12774
|
-
case "init":
|
|
12775
|
-
return handleInit(args, server, deps);
|
|
12776
12734
|
case "execute": {
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12735
|
+
try {
|
|
12736
|
+
await ensurePgReadyOnce(cbOpts, deps);
|
|
12737
|
+
}
|
|
12738
|
+
catch (error) {
|
|
12739
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
12740
|
+
return buildPgToolResult({
|
|
12741
|
+
success: false,
|
|
12742
|
+
errorCode: "PG_NOT_READY",
|
|
12743
|
+
message: `CloudBase PostgreSQL is not ready. ${reason}`,
|
|
12744
|
+
nextActions: [
|
|
12745
|
+
buildNextAction("queryEnv", "info", "检查当前环境 PostgreSQL 实例状态。", { action: "info", envId: context.envId }),
|
|
12746
|
+
],
|
|
12747
|
+
});
|
|
12780
12748
|
}
|
|
12781
12749
|
return handleExecuteSql(args, context, deps);
|
|
12782
12750
|
}
|
|
@@ -12787,17 +12755,12 @@ function registerPGDatabaseTools(server, providedDeps) {
|
|
|
12787
12755
|
case "listMigrations":
|
|
12788
12756
|
case "migrationDetail":
|
|
12789
12757
|
case "rollbackMigration": {
|
|
12790
|
-
const migrationCtx = await getPgContext(server);
|
|
12791
|
-
if (!migrationCtx) {
|
|
12792
|
-
return buildMissingContextResult();
|
|
12793
|
-
}
|
|
12794
|
-
const cbOpts = server.cloudBaseOptions;
|
|
12795
12758
|
switch (args.action) {
|
|
12796
|
-
case "planMigration": return handlePlanMigration(args,
|
|
12797
|
-
case "applyMigration": return handleApplyMigration(args,
|
|
12798
|
-
case "listMigrations": return handleListMigrations(args,
|
|
12799
|
-
case "migrationDetail": return handleMigrationDetail(args,
|
|
12800
|
-
case "rollbackMigration": return handleRollbackMigration(args,
|
|
12759
|
+
case "planMigration": return handlePlanMigration(args, context, deps, cbOpts);
|
|
12760
|
+
case "applyMigration": return handleApplyMigration(args, context, deps, cbOpts);
|
|
12761
|
+
case "listMigrations": return handleListMigrations(args, context, deps, cbOpts);
|
|
12762
|
+
case "migrationDetail": return handleMigrationDetail(args, context, deps, cbOpts);
|
|
12763
|
+
case "rollbackMigration": return handleRollbackMigration(args, context, deps, cbOpts);
|
|
12801
12764
|
default: return buildPgToolResult({ success: false, errorCode: "UNSUPPORTED_ACTION", message: `Unsupported action: ${args.action}` });
|
|
12802
12765
|
}
|
|
12803
12766
|
}
|
|
@@ -13899,7 +13862,7 @@ function registerSetupTools(server) {
|
|
|
13899
13862
|
server.registerTool("downloadTemplate", {
|
|
13900
13863
|
title: "下载项目模板",
|
|
13901
13864
|
description: `自动下载并部署CloudBase项目模板。
|
|
13902
|
-
**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.
|
|
13865
|
+
**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.9" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
13903
13866
|
inputSchema: {
|
|
13904
13867
|
template: zod_1.z
|
|
13905
13868
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
@@ -17283,13 +17246,6 @@ function registerAgentTools(server) {
|
|
|
17283
17246
|
}
|
|
17284
17247
|
|
|
17285
17248
|
|
|
17286
|
-
/***/ }),
|
|
17287
|
-
|
|
17288
|
-
/***/ 9627:
|
|
17289
|
-
/***/ ((module) => {
|
|
17290
|
-
|
|
17291
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_75ed2103__;
|
|
17292
|
-
|
|
17293
17249
|
/***/ }),
|
|
17294
17250
|
|
|
17295
17251
|
/***/ 9684:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cloudbase-mcp",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.9",
|
|
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",
|