@cloudbase/cloudbase-mcp 2.23.6 → 2.23.8
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 +3 -3
- package/dist/index.cjs +182 -22
- package/dist/index.js +182 -22
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1990,13 +1990,14 @@ async function fetchAvailableEnvCandidates(cloudBaseOptions, server) {
|
|
|
1990
1990
|
return [];
|
|
1991
1991
|
}
|
|
1992
1992
|
}
|
|
1993
|
-
const CODEBUDDY_AUTH_ACTIONS = ["status", "set_env"];
|
|
1993
|
+
const CODEBUDDY_AUTH_ACTIONS = ["status", "set_env", "login_by_api_key"];
|
|
1994
1994
|
const DEFAULT_AUTH_ACTIONS = [
|
|
1995
1995
|
"status",
|
|
1996
1996
|
"start_auth",
|
|
1997
1997
|
"set_env",
|
|
1998
1998
|
"logout",
|
|
1999
1999
|
"get_temp_credentials",
|
|
2000
|
+
"login_by_api_key",
|
|
2000
2001
|
];
|
|
2001
2002
|
function maskSensitiveValue(value) {
|
|
2002
2003
|
if (value.length <= 4) {
|
|
@@ -2553,12 +2554,12 @@ function registerEnvTools(server) {
|
|
|
2553
2554
|
if (server.ide !== 'wxide') {
|
|
2554
2555
|
server.registerTool?.("auth", {
|
|
2555
2556
|
title: "CloudBase 开发阶段登录与环境",
|
|
2556
|
-
description: "CloudBase(腾讯云开发)开发阶段登录与环境绑定。登录后即可访问云资源;环境(env)是云函数、数据库、静态托管等资源的隔离单元,绑定环境后其他 MCP
|
|
2557
|
+
description: "CloudBase(腾讯云开发)开发阶段登录与环境绑定。登录后即可访问云资源;环境(env)是云函数、数据库、静态托管等资源的隔离单元,绑定环境后其他 MCP 工具才能操作该环境。支持:查询状态、发起登录、API Key登录、绑定环境(set_env)、退出登录。",
|
|
2557
2558
|
inputSchema: {
|
|
2558
2559
|
action: zod_1.z
|
|
2559
2560
|
.enum(authActionEnum)
|
|
2560
2561
|
.optional()
|
|
2561
|
-
.describe("动作:status=查询状态,start_auth=发起登录,set_env=绑定环境(传envId),logout=退出登录"),
|
|
2562
|
+
.describe("动作:status=查询状态,start_auth=发起登录,login_by_api_key=API Key登录,set_env=绑定环境(传envId),logout=退出登录"),
|
|
2562
2563
|
...(supportedAuthActions.includes("start_auth")
|
|
2563
2564
|
? {
|
|
2564
2565
|
authMode: zod_1.z
|
|
@@ -2583,6 +2584,18 @@ function registerEnvTools(server) {
|
|
|
2583
2584
|
.string()
|
|
2584
2585
|
.optional()
|
|
2585
2586
|
.describe("环境ID(CloudBase 环境唯一标识),绑定后工具将操作该环境。action=set_env 时必填"),
|
|
2587
|
+
...(supportedAuthActions.includes("login_by_api_key")
|
|
2588
|
+
? {
|
|
2589
|
+
apiKey: zod_1.z
|
|
2590
|
+
.string()
|
|
2591
|
+
.optional()
|
|
2592
|
+
.describe("CloudBase API Key,action=login_by_api_key 时必填"),
|
|
2593
|
+
apiKeyEnvId: zod_1.z
|
|
2594
|
+
.string()
|
|
2595
|
+
.optional()
|
|
2596
|
+
.describe("CloudBase 环境ID(EnvId),action=login_by_api_key 时必填,用于指定 API Key 所属环境"),
|
|
2597
|
+
}
|
|
2598
|
+
: {}),
|
|
2586
2599
|
...(supportedAuthActions.includes("logout")
|
|
2587
2600
|
? {
|
|
2588
2601
|
confirm: zod_1.z
|
|
@@ -2898,6 +2911,78 @@ function registerEnvTools(server) {
|
|
|
2898
2911
|
next_step: envPreparation.nextStep,
|
|
2899
2912
|
});
|
|
2900
2913
|
}
|
|
2914
|
+
if (action === "login_by_api_key") {
|
|
2915
|
+
const toolApiKey = normalizeOptionalToolString(rawArgs.apiKey);
|
|
2916
|
+
const toolApiKeyEnvId = normalizeOptionalToolString(rawArgs.apiKeyEnvId);
|
|
2917
|
+
if (!toolApiKey || !toolApiKeyEnvId) {
|
|
2918
|
+
return (0, tool_result_js_1.buildJsonToolResult)({
|
|
2919
|
+
ok: false,
|
|
2920
|
+
code: "INVALID_ARGS",
|
|
2921
|
+
message: "action=login_by_api_key 时必须同时提供 apiKey 和 envId。",
|
|
2922
|
+
next_step: (0, tool_result_js_1.buildAuthNextStep)("login_by_api_key", {
|
|
2923
|
+
suggestedArgs: { action: "login_by_api_key", apiKey: "<your-api-key>", envId: "<your-env-id>" },
|
|
2924
|
+
}),
|
|
2925
|
+
});
|
|
2926
|
+
}
|
|
2927
|
+
// 写入 process.env(与 cli.ts 处理 --api-key/--env-id 的逻辑一致)
|
|
2928
|
+
process.env.CLOUDBASE_API_KEY = toolApiKey;
|
|
2929
|
+
process.env.CLOUDBASE_ENV_ID = toolApiKeyEnvId;
|
|
2930
|
+
try {
|
|
2931
|
+
const loginState = await (0, auth_js_1.peekLoginState)();
|
|
2932
|
+
if (loginState) {
|
|
2933
|
+
const envPreparation = await prepareAuthEnvironment({
|
|
2934
|
+
server,
|
|
2935
|
+
cloudBaseOptions,
|
|
2936
|
+
loginState,
|
|
2937
|
+
});
|
|
2938
|
+
return (0, tool_result_js_1.buildJsonToolResult)({
|
|
2939
|
+
ok: true,
|
|
2940
|
+
code: "AUTH_READY",
|
|
2941
|
+
message: "API Key 认证成功,已获取临时密钥。",
|
|
2942
|
+
auth_mode: "api_key",
|
|
2943
|
+
...buildAuthEnvSetupPayload(envPreparation),
|
|
2944
|
+
next_step: envPreparation.nextStep,
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
// API Key 换取失败:清理 env vars 并返回诊断信息
|
|
2948
|
+
delete process.env.CLOUDBASE_API_KEY;
|
|
2949
|
+
delete process.env.CLOUDBASE_ENV_ID;
|
|
2950
|
+
let diagMessage = "API Key 换取临时密钥失败。";
|
|
2951
|
+
diagMessage += `\n\n诊断信息:`;
|
|
2952
|
+
diagMessage += `\n- CLOUDBASE_ENV_ID: ${toolApiKeyEnvId}`;
|
|
2953
|
+
diagMessage += `\n- CLOUDBASE_API_KEY: ${toolApiKey.slice(0, 20)}...(已截断)`;
|
|
2954
|
+
diagMessage += `\n\n可能原因:`;
|
|
2955
|
+
diagMessage += `\n1. API Key 已过期或被删除`;
|
|
2956
|
+
diagMessage += `\n2. CLOUDBASE_ENV_ID 与 API Key 所属环境不匹配`;
|
|
2957
|
+
diagMessage += `\n3. 网络连接问题`;
|
|
2958
|
+
diagMessage += `\n\n建议:请检查 API Key 和环境 ID 是否正确。`;
|
|
2959
|
+
return (0, tool_result_js_1.buildJsonToolResult)({
|
|
2960
|
+
ok: false,
|
|
2961
|
+
code: "API_KEY_AUTH_FAILED",
|
|
2962
|
+
message: diagMessage,
|
|
2963
|
+
auth_mode: "api_key",
|
|
2964
|
+
envId: toolApiKeyEnvId,
|
|
2965
|
+
next_step: (0, tool_result_js_1.buildAuthNextStep)("login_by_api_key", {
|
|
2966
|
+
suggestedArgs: { action: "login_by_api_key", apiKey: "<your-api-key>", envId: "<your-env-id>" },
|
|
2967
|
+
}),
|
|
2968
|
+
});
|
|
2969
|
+
}
|
|
2970
|
+
catch (error) {
|
|
2971
|
+
// 异常时清理 env vars
|
|
2972
|
+
delete process.env.CLOUDBASE_API_KEY;
|
|
2973
|
+
delete process.env.CLOUDBASE_ENV_ID;
|
|
2974
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2975
|
+
return (0, tool_result_js_1.buildJsonToolResult)({
|
|
2976
|
+
ok: false,
|
|
2977
|
+
code: "API_KEY_AUTH_FAILED",
|
|
2978
|
+
message: `API Key 认证异常: ${message}`,
|
|
2979
|
+
auth_mode: "api_key",
|
|
2980
|
+
next_step: (0, tool_result_js_1.buildAuthNextStep)("login_by_api_key", {
|
|
2981
|
+
suggestedArgs: { action: "login_by_api_key", apiKey: "<your-api-key>", envId: "<your-env-id>" },
|
|
2982
|
+
}),
|
|
2983
|
+
});
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2901
2986
|
if (action === "set_env") {
|
|
2902
2987
|
const loginState = await (0, auth_js_1.peekLoginState)();
|
|
2903
2988
|
if (!loginState) {
|
|
@@ -39137,6 +39222,18 @@ function buildErrorEnvelope(error) {
|
|
|
39137
39222
|
function normalizeString(value) {
|
|
39138
39223
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
39139
39224
|
}
|
|
39225
|
+
/**
|
|
39226
|
+
* Sanitize agent name for CloudBase backend.
|
|
39227
|
+
* The backend creates a cloud function alias from the agent name (e.g. "agent-{name}"),
|
|
39228
|
+
* and SCF aliases only allow alphanumeric characters and hyphens.
|
|
39229
|
+
* This function replaces any character that is not [a-zA-Z0-9] with a hyphen,
|
|
39230
|
+
* then collapses consecutive hyphens into one.
|
|
39231
|
+
*/
|
|
39232
|
+
function sanitizeAgentName(name) {
|
|
39233
|
+
return name
|
|
39234
|
+
.replace(/[^a-zA-Z0-9]+/g, "-")
|
|
39235
|
+
.replace(/^-+|-+$/g, "");
|
|
39236
|
+
}
|
|
39140
39237
|
function normalizeNumber(value) {
|
|
39141
39238
|
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
39142
39239
|
}
|
|
@@ -39291,13 +39388,19 @@ function registerAgentTools(server) {
|
|
|
39291
39388
|
}
|
|
39292
39389
|
// CloudBase 后端在创建 Agent 时会同步创建云函数,函数名/别名长度受 SCF 限制(最大 64 字符)。
|
|
39293
39390
|
// envId 可能被用作前缀或别名的一部分,因此这里预留足够余量,避免后端 CreateFunction 失败。
|
|
39294
|
-
|
|
39295
|
-
|
|
39296
|
-
|
|
39391
|
+
// 同时,后端会用 name 生成云函数 alias(如 "agent-{name}"),而 SCF alias 只允许字母、数字和连字符,
|
|
39392
|
+
// 因此需要对 name 做 sanitize,将非法字符(如下划线)替换为连字符。
|
|
39393
|
+
const sanitizedName = sanitizeAgentName(normalizedName);
|
|
39394
|
+
if (!sanitizedName) {
|
|
39395
|
+
throw new Error(`name "${normalizedName}" 经 sanitize 后为空,请使用包含字母或数字的 name`);
|
|
39396
|
+
}
|
|
39397
|
+
if (sanitizedName.length > 30) {
|
|
39398
|
+
throw new Error(`agent name 过长(当前 ${sanitizedName.length} 字符)。CloudBase 创建 Agent 时会同步创建云函数,` +
|
|
39399
|
+
`函数名/别名受 SCF 64 字符长度限制,且 envId 可能作为前缀拼接。请将 name 控制在 30 字符以内。`);
|
|
39297
39400
|
}
|
|
39298
39401
|
const createPayload = {
|
|
39299
39402
|
...payload,
|
|
39300
|
-
Name:
|
|
39403
|
+
Name: sanitizedName,
|
|
39301
39404
|
Runtime: normalizeString(payload.Runtime) ?? "Nodejs20.19",
|
|
39302
39405
|
};
|
|
39303
39406
|
const result = await cloudbase.agent.createAgent(createPayload);
|
|
@@ -113869,14 +113972,43 @@ const ManageCloudRunInputSchema = {
|
|
|
113869
113972
|
})).optional().describe('扩缩容配置数组,用于配置服务的自动扩缩容策略。可配置多个扩缩容策略'),
|
|
113870
113973
|
CustomLogs: zod_1.z.string().optional().describe('自定义日志配置,用于配置服务的日志收集和存储策略'),
|
|
113871
113974
|
Port: zod_1.z.number().min(1).max(65535).optional().describe('服务监听端口配置。函数型服务固定为3000,容器型服务可自定义。服务代码必须监听此端口才能正常接收请求'),
|
|
113872
|
-
EnvParams: zod_1.z.string().optional().describe('环境变量配置,JSON字符串格式。用于传递配置信息给服务代码,如\'{"DATABASE_URL":"mysql://...","NODE_ENV":"production"}\'
|
|
113975
|
+
EnvParams: zod_1.z.string().optional().describe('环境变量配置,JSON字符串格式。用于传递配置信息给服务代码,如\'{"DATABASE_URL":"mysql://...","NODE_ENV":"production"}\'。SDK v5.6.1+ 会自动对传入的环境变量进行 AES-256-CBC 加密传输'),
|
|
113873
113976
|
Dockerfile: zod_1.z.string().optional().describe('Dockerfile文件名配置,仅容器型服务需要。指定用于构建容器镜像的Dockerfile文件路径,默认为项目根目录下的Dockerfile'),
|
|
113874
113977
|
BuildDir: zod_1.z.string().optional().describe('构建目录配置,指定代码构建的目录路径。当代码结构与标准不同时使用,默认为项目根目录'),
|
|
113875
113978
|
InternalAccess: zod_1.z.string().optional().describe('内网访问开关配置,控制是否启用内网访问。true=启用内网访问(可通过云开发SDK直接调用),false=关闭内网访问(仅公网访问)'),
|
|
113876
113979
|
InternalDomain: zod_1.z.string().optional().describe('内网域名配置,用于配置服务的内网访问域名。仅在启用内网访问时有效'),
|
|
113877
113980
|
EntryPoint: zod_1.z.array(zod_1.z.string()).optional().describe('Dockerfile EntryPoint参数配置,仅容器型服务需要。指定容器启动时的入口程序数组,如["node","app.js"]'),
|
|
113878
113981
|
Cmd: zod_1.z.array(zod_1.z.string()).optional().describe('Dockerfile Cmd参数配置,仅容器型服务需要。指定容器启动时的默认命令数组,如["npm","start"]'),
|
|
113879
|
-
|
|
113982
|
+
InitialDelaySeconds: zod_1.z.number().min(0).optional().describe('延迟检测时间(秒),用于配置服务启动后的健康检查延迟。在此期间内不会将请求路由到该实例,适用于启动时间较长的服务'),
|
|
113983
|
+
LogType: zod_1.z.string().optional().describe('日志类型配置,指定服务的日志收集类型。影响日志的采集方式和存储格式'),
|
|
113984
|
+
LogSetId: zod_1.z.string().optional().describe('CLS日志集ID配置,指定日志服务(CLS)的日志集ID。需要先开通CLS日志服务'),
|
|
113985
|
+
LogTopicId: zod_1.z.string().optional().describe('CLS日志主题ID配置,指定日志服务(CLS)的日志主题ID。需要先开通CLS日志服务'),
|
|
113986
|
+
LogParseType: zod_1.z.string().optional().describe('日志解析类型配置,指定日志的解析方式。用于将原始日志解析为结构化数据'),
|
|
113987
|
+
Tag: zod_1.z.string().optional().describe('服务标签配置,用于标识服务类型。如设置为"function:"表示函数型服务。SDK会自动根据配置生成'),
|
|
113988
|
+
OperationMode: zod_1.z.string().optional().describe('运行模式配置,指定服务的运行模式。影响服务的调度和资源分配方式'),
|
|
113989
|
+
SessionAffinity: zod_1.z.string().optional().describe('会话保持配置,用于控制是否启用会话保持功能。启用后会将同一客户端的请求路由到同一实例'),
|
|
113990
|
+
TimerScale: zod_1.z.array(zod_1.z.object({
|
|
113991
|
+
CycleType: zod_1.z.enum(['none', 'daily', 'weekly', 'monthly']).describe('循环类型:none=无循环,daily=每日循环,weekly=每周循环,monthly=每月循环'),
|
|
113992
|
+
StartDate: zod_1.z.string().optional().describe('循环起始日期,格式:YYYY-MM-DD'),
|
|
113993
|
+
EndDate: zod_1.z.string().optional().describe('循环结束日期,格式:YYYY-MM-DD'),
|
|
113994
|
+
StartTime: zod_1.z.string().describe('起始时间,格式:HH:mm:ss'),
|
|
113995
|
+
EndTime: zod_1.z.string().describe('结束时间,格式:HH:mm:ss'),
|
|
113996
|
+
ReplicaNum: zod_1.z.number().min(0).describe('定时扩缩容的目标副本数,最小值0(缩容到0)')
|
|
113997
|
+
})).optional().describe('定时扩缩容配置数组,用于配置服务的定时自动扩缩容策略。可配置多个时间段的扩缩容计划,支持每日/每周/每月循环'),
|
|
113998
|
+
VpcConf: zod_1.z.object({
|
|
113999
|
+
VpcId: zod_1.z.string().describe('VPC网络ID,指定服务所在的私有网络'),
|
|
114000
|
+
SubnetId: zod_1.z.string().describe('子网ID,指定服务所在的子网'),
|
|
114001
|
+
}).optional().describe('VPC网络配置,用于将云托管服务部署到指定的私有网络中。需要提前创建好VPC和子网'),
|
|
114002
|
+
VolumesConf: zod_1.z.array(zod_1.z.object({
|
|
114003
|
+
VolumeName: zod_1.z.string().describe('存储卷名称'),
|
|
114004
|
+
VolumeType: zod_1.z.string().describe('存储卷类型,如CFS表示云文件存储'),
|
|
114005
|
+
VolumePath: zod_1.z.string().describe('存储卷挂载路径,服务代码中的目标路径')
|
|
114006
|
+
})).optional().describe('存储卷配置数组,用于挂载云存储(如CFS)到服务实例中。可用于持久化数据或共享文件'),
|
|
114007
|
+
PublicNetConf: zod_1.z.object({
|
|
114008
|
+
PublicAccess: zod_1.z.boolean().optional().describe('是否开启公网访问,true=开启公网访问,false=关闭公网访问'),
|
|
114009
|
+
PublicAccessPath: zod_1.z.string().optional().describe('公网访问路径配置')
|
|
114010
|
+
}).optional().describe('公网访问配置,用于控制服务的公网访问策略。可配置是否开启公网访问及访问路径'),
|
|
114011
|
+
}).optional().describe('服务配置项,用于部署时设置服务的运行参数。包括资源规格、访问权限、环境变量、日志、网络等配置。不提供时使用默认配置'),
|
|
113880
114012
|
// Init operation parameters
|
|
113881
114013
|
template: zod_1.z.string().optional().default('helloworld').describe('项目模板标识符,用于指定初始化项目时使用的模板。可通过queryCloudRun的templates操作获取可用模板列表。常用模板:helloworld=Hello World示例,nodejs=Node.js项目模板,python=Python项目模板等'),
|
|
113882
114014
|
// Run operation parameters (function services only)
|
|
@@ -113931,18 +114063,31 @@ function checkIfAgentProject(projectPath) {
|
|
|
113931
114063
|
}
|
|
113932
114064
|
}
|
|
113933
114065
|
/**
|
|
113934
|
-
* Validate and normalize file path
|
|
114066
|
+
* Validate and normalize file path.
|
|
114067
|
+
* Accepts absolute paths as-is; for relative paths, resolves against CWD and
|
|
114068
|
+
* ensures the result does not escape the CWD (path-traversal protection).
|
|
113935
114069
|
* @param inputPath User provided path
|
|
113936
114070
|
* @returns Absolute path
|
|
113937
114071
|
*/
|
|
113938
114072
|
function validateAndNormalizePath(inputPath) {
|
|
113939
|
-
|
|
113940
|
-
//
|
|
114073
|
+
const normalizedPath = path_1.default.resolve(inputPath);
|
|
114074
|
+
// On Windows, path.resolve may return a path on a different drive/UNC share.
|
|
114075
|
+
// That is safe — the user explicitly provided an absolute path there.
|
|
114076
|
+
// Only apply the traversal check when the resolved path shares the same root
|
|
114077
|
+
// as CWD (i.e. the path was relative or on the same drive).
|
|
113941
114078
|
const cwd = process.cwd();
|
|
113942
|
-
const
|
|
113943
|
-
|
|
113944
|
-
|
|
113945
|
-
|
|
114079
|
+
const cwdRoot = path_1.default.parse(cwd).root;
|
|
114080
|
+
const pathRoot = path_1.default.parse(normalizedPath).root;
|
|
114081
|
+
if (cwdRoot === pathRoot) {
|
|
114082
|
+
// Same filesystem root — ensure the resolved path is still inside CWD
|
|
114083
|
+
// (or is exactly CWD) to block "../" traversal.
|
|
114084
|
+
const prefix = cwd.endsWith(path_1.default.sep) ? cwd : cwd + path_1.default.sep;
|
|
114085
|
+
if (!normalizedPath.startsWith(prefix) && normalizedPath !== cwd) {
|
|
114086
|
+
throw new Error(`Path must be within current working directory: ${cwd}`);
|
|
114087
|
+
}
|
|
114088
|
+
}
|
|
114089
|
+
// Cross-root absolute paths (e.g. D:\ on Windows when CWD is C:\) are
|
|
114090
|
+
// allowed — the user own the machine and the path is explicitly absolute.
|
|
113946
114091
|
return normalizedPath;
|
|
113947
114092
|
}
|
|
113948
114093
|
function buildManageCloudRunErrorMessage(action, serverName, error) {
|
|
@@ -136691,7 +136836,7 @@ class TelemetryReporter {
|
|
|
136691
136836
|
const nodeVersion = process.version; // Node.js版本
|
|
136692
136837
|
const arch = os_1.default.arch(); // 系统架构
|
|
136693
136838
|
// 从构建时注入的版本号获取MCP版本信息
|
|
136694
|
-
const mcpVersion = process.env.npm_package_version || "2.23.
|
|
136839
|
+
const mcpVersion = process.env.npm_package_version || "2.23.8" || 0;
|
|
136695
136840
|
return {
|
|
136696
136841
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
136697
136842
|
deviceId: this.deviceId,
|
|
@@ -196476,7 +196621,7 @@ ${envIdSection}
|
|
|
196476
196621
|
## 环境信息
|
|
196477
196622
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
196478
196623
|
- Node.js版本: ${process.version}
|
|
196479
|
-
- MCP 版本:${process.env.npm_package_version || "2.23.
|
|
196624
|
+
- MCP 版本:${process.env.npm_package_version || "2.23.8" || 0}
|
|
196480
196625
|
- 系统架构: ${os_1.default.arch()}
|
|
196481
196626
|
- 时间: ${new Date().toISOString()}
|
|
196482
196627
|
- 请求ID: ${requestId}
|
|
@@ -196557,7 +196702,7 @@ function createWrappedHandler(name, handler, server) {
|
|
|
196557
196702
|
requestId: (typeof error === 'object' && error && 'requestId' in error) ? error.requestId : '',
|
|
196558
196703
|
ide: server.ide || process.env.INTEGRATION_IDE || ''
|
|
196559
196704
|
});
|
|
196560
|
-
const mcpVersion = true ? "2.23.
|
|
196705
|
+
const mcpVersion = true ? "2.23.8" : 0;
|
|
196561
196706
|
const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
|
|
196562
196707
|
const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
|
|
196563
196708
|
// 创建新的错误对象,保持原有的错误类型但更新消息
|
|
@@ -212571,7 +212716,7 @@ function registerSetupTools(server) {
|
|
|
212571
212716
|
server.registerTool("downloadTemplate", {
|
|
212572
212717
|
title: "下载项目模板",
|
|
212573
212718
|
description: `自动下载并部署CloudBase项目模板。
|
|
212574
|
-
**Note**: Call this tool when the user requests to create a new project using a CloudBase template.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置\n- cursor: Cursor AI编辑器\n- 其他IDE类型见下方列表\n\n注意:如果未传入 ide 参数且无法从环境变量检测到 IDE,将提示错误并要求传入 ide 参数\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- qoder: Qoder AI编辑器\n- antigravity: Google Antigravity AI编辑器\n- vscode: Visual Studio Code\n- kiro: Kiro AI编辑器\n- aider: Aider AI编辑器\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.23.
|
|
212719
|
+
**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.8" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
212575
212720
|
inputSchema: {
|
|
212576
212721
|
template: zod_1.z
|
|
212577
212722
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
@@ -229992,6 +230137,7 @@ function registerGatewayTools(server) {
|
|
|
229992
230137
|
const cloudbase = await getManager();
|
|
229993
230138
|
const accessPath = input.path ? normalizeAccessPath(input.path) : undefined;
|
|
229994
230139
|
let resolvedAccessId = input.accessId;
|
|
230140
|
+
let resolvedName;
|
|
229995
230141
|
if (!resolvedAccessId) {
|
|
229996
230142
|
if (!input.targetName && !accessPath) {
|
|
229997
230143
|
throw new Error("action=deleteAccess 时至少需要提供 accessId,或提供 targetName/path 用于定位入口");
|
|
@@ -230013,18 +230159,32 @@ function registerGatewayTools(server) {
|
|
|
230013
230159
|
throw new Error("匹配到多个访问入口,请补充 path 或直接传 accessId");
|
|
230014
230160
|
}
|
|
230015
230161
|
resolvedAccessId = candidates[0]?.APIId;
|
|
230162
|
+
resolvedName = candidates[0]?.Name;
|
|
230163
|
+
}
|
|
230164
|
+
else {
|
|
230165
|
+
// 仅传入 accessId 时,先查询获取 name 等信息,确保删除参数完整
|
|
230166
|
+
try {
|
|
230167
|
+
const accessList = await cloudbase.access.getAccessList({});
|
|
230168
|
+
const match = (accessList.APISet ?? []).find((item) => item.APIId === resolvedAccessId);
|
|
230169
|
+
if (match) {
|
|
230170
|
+
resolvedName = match.Name;
|
|
230171
|
+
}
|
|
230172
|
+
}
|
|
230173
|
+
catch {
|
|
230174
|
+
// 查询失败不影响主流程,继续用 accessId 删除
|
|
230175
|
+
}
|
|
230016
230176
|
}
|
|
230017
230177
|
if (!resolvedAccessId) {
|
|
230018
230178
|
throw new Error("无法解析访问入口 accessId,请改为显式传入 accessId");
|
|
230019
230179
|
}
|
|
230020
230180
|
const result = await cloudbase.access.deleteAccess({
|
|
230021
|
-
...(
|
|
230181
|
+
...(resolvedName ? { name: resolvedName } : {}),
|
|
230022
230182
|
apiId: resolvedAccessId,
|
|
230023
230183
|
});
|
|
230024
230184
|
(0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
|
|
230025
230185
|
return buildEnvelope({
|
|
230026
230186
|
action: input.action,
|
|
230027
|
-
targetName: input.targetName ?? null,
|
|
230187
|
+
targetName: resolvedName ?? input.targetName ?? null,
|
|
230028
230188
|
path: accessPath ?? null,
|
|
230029
230189
|
accessId: resolvedAccessId,
|
|
230030
230190
|
raw: result,
|