@cloudbase/cloudbase-mcp 1.8.41 → 1.8.42
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 +276 -91
- package/dist/index.cjs +276 -91
- package/dist/index.js +275 -89
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -33813,58 +33813,9 @@ function downloadFile(url) {
|
|
|
33813
33813
|
});
|
|
33814
33814
|
}
|
|
33815
33815
|
function registerDownloadTools(server) {
|
|
33816
|
-
// downloadRemoteFile - 下载远程文件到临时目录 (cloud-incompatible)
|
|
33817
33816
|
server.registerTool("downloadRemoteFile", {
|
|
33818
|
-
title: "下载远程文件到临时目录",
|
|
33819
|
-
description: "下载远程文件到本地临时文件,返回一个系统的绝对路径。适用于需要临时处理文件的场景。",
|
|
33820
|
-
inputSchema: {
|
|
33821
|
-
url: zod_1.z.string().describe("远程文件的 URL 地址")
|
|
33822
|
-
},
|
|
33823
|
-
annotations: {
|
|
33824
|
-
readOnlyHint: false,
|
|
33825
|
-
destructiveHint: false,
|
|
33826
|
-
idempotentHint: false,
|
|
33827
|
-
openWorldHint: true,
|
|
33828
|
-
category: "download"
|
|
33829
|
-
}
|
|
33830
|
-
}, async ({ url }) => {
|
|
33831
|
-
try {
|
|
33832
|
-
const result = await downloadFile(url);
|
|
33833
|
-
return {
|
|
33834
|
-
content: [
|
|
33835
|
-
{
|
|
33836
|
-
type: "text",
|
|
33837
|
-
text: JSON.stringify({
|
|
33838
|
-
success: true,
|
|
33839
|
-
filePath: result.filePath,
|
|
33840
|
-
contentType: result.contentType,
|
|
33841
|
-
fileSize: result.fileSize,
|
|
33842
|
-
message: "文件下载成功到临时目录",
|
|
33843
|
-
note: "文件保存在临时目录中,请注意及时处理"
|
|
33844
|
-
}, null, 2)
|
|
33845
|
-
}
|
|
33846
|
-
]
|
|
33847
|
-
};
|
|
33848
|
-
}
|
|
33849
|
-
catch (error) {
|
|
33850
|
-
return {
|
|
33851
|
-
content: [
|
|
33852
|
-
{
|
|
33853
|
-
type: "text",
|
|
33854
|
-
text: JSON.stringify({
|
|
33855
|
-
success: false,
|
|
33856
|
-
error: error.message,
|
|
33857
|
-
message: "文件下载失败"
|
|
33858
|
-
}, null, 2)
|
|
33859
|
-
}
|
|
33860
|
-
]
|
|
33861
|
-
};
|
|
33862
|
-
}
|
|
33863
|
-
});
|
|
33864
|
-
// downloadRemoteFileToPath - 下载远程文件到指定路径 (cloud-incompatible)
|
|
33865
|
-
server.registerTool("downloadRemoteFileToPath", {
|
|
33866
33817
|
title: "下载远程文件到指定路径",
|
|
33867
|
-
description: "
|
|
33818
|
+
description: "下载远程文件到项目根目录下的指定相对路径。例如:小程序的 Tabbar 等素材图片,必须使用 **png** 格式,可以从 Unsplash、wikimedia【一般选用 500 大小即可、Pexels、Apple 官方 UI 等资源中选择来下载。",
|
|
33868
33819
|
inputSchema: {
|
|
33869
33820
|
url: zod_1.z.string().describe("远程文件的 URL 地址"),
|
|
33870
33821
|
relativePath: zod_1.z.string().describe("相对于项目根目录的路径,例如:'assets/images/logo.png' 或 'docs/api.md'。不允许使用 ../ 等路径遍历操作。")
|
|
@@ -97937,7 +97888,7 @@ function convertToJSONSchema(data) {
|
|
|
97937
97888
|
// 处理枚举类型
|
|
97938
97889
|
if (parsed.type.startsWith('x-enum')) {
|
|
97939
97890
|
schema.properties[parsed.name].type = 'string';
|
|
97940
|
-
schema.properties[parsed.name].format = 'enum';
|
|
97891
|
+
schema.properties[parsed.name].format = 'x-enum';
|
|
97941
97892
|
if (parsed.enumValues) {
|
|
97942
97893
|
schema.properties[parsed.name].enum = parsed.enumValues;
|
|
97943
97894
|
}
|
|
@@ -98124,7 +98075,6 @@ function getSpecialFormat(type) {
|
|
|
98124
98075
|
'x-location': 'x-location',
|
|
98125
98076
|
'x-area-code': 'x-area-code',
|
|
98126
98077
|
'x-file': 'x-file',
|
|
98127
|
-
'x-enum': 'enum',
|
|
98128
98078
|
};
|
|
98129
98079
|
// 只保留这些
|
|
98130
98080
|
return formatMap[type] || null;
|
|
@@ -122142,7 +122092,7 @@ class TelemetryReporter {
|
|
|
122142
122092
|
const nodeVersion = process.version; // Node.js版本
|
|
122143
122093
|
const arch = os_1.default.arch(); // 系统架构
|
|
122144
122094
|
// 从构建时注入的版本号获取MCP版本信息
|
|
122145
|
-
const mcpVersion = process.env.npm_package_version || "1.8.
|
|
122095
|
+
const mcpVersion = process.env.npm_package_version || "1.8.42" || 0;
|
|
122146
122096
|
return {
|
|
122147
122097
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
122148
122098
|
deviceId: this.deviceId,
|
|
@@ -180028,7 +179978,7 @@ ${envIdSection}
|
|
|
180028
179978
|
## 环境信息
|
|
180029
179979
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
180030
179980
|
- Node.js版本: ${process.version}
|
|
180031
|
-
- MCP 版本:${process.env.npm_package_version || "1.8.
|
|
179981
|
+
- MCP 版本:${process.env.npm_package_version || "1.8.42" || 0}
|
|
180032
179982
|
- 系统架构: ${os_1.default.arch()}
|
|
180033
179983
|
- 时间: ${new Date().toISOString()}
|
|
180034
179984
|
- 请求ID: ${requestId}
|
|
@@ -195054,7 +195004,7 @@ function registerSetupTools(server) {
|
|
|
195054
195004
|
// downloadTemplate - 下载项目模板 (cloud-incompatible)
|
|
195055
195005
|
server.registerTool("downloadTemplate", {
|
|
195056
195006
|
title: "下载项目模板",
|
|
195057
|
-
description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.
|
|
195007
|
+
description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.42" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
195058
195008
|
inputSchema: {
|
|
195059
195009
|
template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
|
|
195060
195010
|
ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
|
|
@@ -219678,7 +219628,11 @@ function shouldRegisterTool(toolName) {
|
|
|
219678
219628
|
'setupEnvironmentId',
|
|
219679
219629
|
'clearUserEnvId',
|
|
219680
219630
|
// Interactive tools - local server and file operations
|
|
219681
|
-
'interactiveDialog'
|
|
219631
|
+
'interactiveDialog',
|
|
219632
|
+
// CloudRun tools - local file operations
|
|
219633
|
+
'manageCloudRun',
|
|
219634
|
+
// Download tools - local file downloads
|
|
219635
|
+
'manageStorage',
|
|
219682
219636
|
];
|
|
219683
219637
|
const shouldRegister = !cloudIncompatibleTools.includes(toolName);
|
|
219684
219638
|
if (!shouldRegister) {
|
|
@@ -237134,54 +237088,285 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
237134
237088
|
exports.registerStorageTools = registerStorageTools;
|
|
237135
237089
|
const zod_1 = __webpack_require__(21614);
|
|
237136
237090
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
237091
|
+
// Input schema for queryStorage tool
|
|
237092
|
+
const queryStorageInputSchema = {
|
|
237093
|
+
action: zod_1.z.enum(['list', 'info', 'url']).describe('查询操作类型:list=列出目录下的所有文件,info=获取指定文件的详细信息,url=获取文件的临时下载链接'),
|
|
237094
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt 或 files/(目录)'),
|
|
237095
|
+
maxAge: zod_1.z.number().min(1).max(86400).optional().default(3600).describe('临时链接有效期,单位为秒,取值范围:1-86400,默认值:3600(1小时)')
|
|
237096
|
+
};
|
|
237097
|
+
// Input schema for manageStorage tool
|
|
237098
|
+
const manageStorageInputSchema = {
|
|
237099
|
+
action: zod_1.z.enum(['upload', 'download', 'delete']).describe('管理操作类型:upload=上传文件或目录,download=下载文件或目录,delete=删除文件或目录'),
|
|
237100
|
+
localPath: zod_1.z.string().describe('本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt'),
|
|
237101
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt'),
|
|
237102
|
+
force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,删除操作时建议设置为true以确认删除,默认false'),
|
|
237103
|
+
isDirectory: zod_1.z.boolean().optional().default(false).describe('是否为目录操作,true=目录操作,false=文件操作,默认false')
|
|
237104
|
+
};
|
|
237137
237105
|
function registerStorageTools(server) {
|
|
237138
237106
|
// 获取 cloudBaseOptions,如果没有则为 undefined
|
|
237139
237107
|
const cloudBaseOptions = server.cloudBaseOptions;
|
|
237140
237108
|
// 创建闭包函数来获取 CloudBase Manager
|
|
237141
237109
|
const getManager = () => (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions });
|
|
237142
|
-
//
|
|
237143
|
-
server.registerTool("
|
|
237144
|
-
title: "
|
|
237145
|
-
description: "
|
|
237146
|
-
inputSchema:
|
|
237147
|
-
|
|
237148
|
-
|
|
237149
|
-
|
|
237110
|
+
// Tool 1: queryStorage - 查询存储信息(只读操作)
|
|
237111
|
+
server.registerTool("queryStorage", {
|
|
237112
|
+
title: "查询存储信息",
|
|
237113
|
+
description: "查询云存储信息,支持列出目录文件、获取文件信息、获取临时下载链接等只读操作。返回的文件信息包括文件名、大小、修改时间、下载链接等。",
|
|
237114
|
+
inputSchema: queryStorageInputSchema,
|
|
237115
|
+
annotations: {
|
|
237116
|
+
readOnlyHint: true,
|
|
237117
|
+
openWorldHint: true,
|
|
237118
|
+
category: "storage"
|
|
237119
|
+
}
|
|
237120
|
+
}, async (args) => {
|
|
237121
|
+
try {
|
|
237122
|
+
const input = args;
|
|
237123
|
+
const manager = await getManager();
|
|
237124
|
+
if (!manager) {
|
|
237125
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
237126
|
+
}
|
|
237127
|
+
const storageService = manager.storage;
|
|
237128
|
+
switch (input.action) {
|
|
237129
|
+
case 'list': {
|
|
237130
|
+
const result = await storageService.listDirectoryFiles(input.cloudPath);
|
|
237131
|
+
return {
|
|
237132
|
+
content: [
|
|
237133
|
+
{
|
|
237134
|
+
type: "text",
|
|
237135
|
+
text: JSON.stringify({
|
|
237136
|
+
success: true,
|
|
237137
|
+
data: {
|
|
237138
|
+
action: 'list',
|
|
237139
|
+
cloudPath: input.cloudPath,
|
|
237140
|
+
files: result || [],
|
|
237141
|
+
totalCount: result?.length || 0
|
|
237142
|
+
},
|
|
237143
|
+
message: `Successfully listed ${result?.length || 0} files in directory '${input.cloudPath}'`
|
|
237144
|
+
}, null, 2)
|
|
237145
|
+
}
|
|
237146
|
+
]
|
|
237147
|
+
};
|
|
237148
|
+
}
|
|
237149
|
+
case 'info': {
|
|
237150
|
+
const result = await storageService.getFileInfo(input.cloudPath);
|
|
237151
|
+
return {
|
|
237152
|
+
content: [
|
|
237153
|
+
{
|
|
237154
|
+
type: "text",
|
|
237155
|
+
text: JSON.stringify({
|
|
237156
|
+
success: true,
|
|
237157
|
+
data: {
|
|
237158
|
+
action: 'info',
|
|
237159
|
+
cloudPath: input.cloudPath,
|
|
237160
|
+
fileInfo: result
|
|
237161
|
+
},
|
|
237162
|
+
message: `Successfully retrieved file info for '${input.cloudPath}'`
|
|
237163
|
+
}, null, 2)
|
|
237164
|
+
}
|
|
237165
|
+
]
|
|
237166
|
+
};
|
|
237167
|
+
}
|
|
237168
|
+
case 'url': {
|
|
237169
|
+
const result = await storageService.getTemporaryUrl([{
|
|
237170
|
+
cloudPath: input.cloudPath,
|
|
237171
|
+
maxAge: input.maxAge || 3600
|
|
237172
|
+
}]);
|
|
237173
|
+
return {
|
|
237174
|
+
content: [
|
|
237175
|
+
{
|
|
237176
|
+
type: "text",
|
|
237177
|
+
text: JSON.stringify({
|
|
237178
|
+
success: true,
|
|
237179
|
+
data: {
|
|
237180
|
+
action: 'url',
|
|
237181
|
+
cloudPath: input.cloudPath,
|
|
237182
|
+
temporaryUrl: result[0]?.url || "",
|
|
237183
|
+
expireTime: `${input.maxAge || 3600}秒`,
|
|
237184
|
+
fileId: result[0]?.fileId || ""
|
|
237185
|
+
},
|
|
237186
|
+
message: `Successfully generated temporary URL for '${input.cloudPath}'`
|
|
237187
|
+
}, null, 2)
|
|
237188
|
+
}
|
|
237189
|
+
]
|
|
237190
|
+
};
|
|
237191
|
+
}
|
|
237192
|
+
default:
|
|
237193
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
237194
|
+
}
|
|
237195
|
+
}
|
|
237196
|
+
catch (error) {
|
|
237197
|
+
return {
|
|
237198
|
+
content: [
|
|
237199
|
+
{
|
|
237200
|
+
type: "text",
|
|
237201
|
+
text: JSON.stringify({
|
|
237202
|
+
success: false,
|
|
237203
|
+
error: error.message || 'Unknown error occurred',
|
|
237204
|
+
message: `Failed to query storage information. Please check your permissions and parameters.`
|
|
237205
|
+
}, null, 2)
|
|
237206
|
+
}
|
|
237207
|
+
]
|
|
237208
|
+
};
|
|
237209
|
+
}
|
|
237210
|
+
});
|
|
237211
|
+
// Tool 2: manageStorage - 管理存储文件(写操作)
|
|
237212
|
+
server.registerTool("manageStorage", {
|
|
237213
|
+
title: "管理存储文件",
|
|
237214
|
+
description: "管理云存储文件,支持上传文件/目录、下载文件/目录、删除文件/目录等操作。删除操作需要设置force=true进行确认,防止误删除重要文件。",
|
|
237215
|
+
inputSchema: manageStorageInputSchema,
|
|
237150
237216
|
annotations: {
|
|
237151
237217
|
readOnlyHint: false,
|
|
237152
|
-
destructiveHint:
|
|
237218
|
+
destructiveHint: true,
|
|
237153
237219
|
idempotentHint: false,
|
|
237154
237220
|
openWorldHint: true,
|
|
237155
237221
|
category: "storage"
|
|
237156
237222
|
}
|
|
237157
|
-
}, async (
|
|
237158
|
-
|
|
237159
|
-
|
|
237160
|
-
|
|
237161
|
-
|
|
237162
|
-
|
|
237163
|
-
onProgress: (progressData) => {
|
|
237164
|
-
console.log("Upload progress:", progressData);
|
|
237223
|
+
}, async (args) => {
|
|
237224
|
+
try {
|
|
237225
|
+
const input = args;
|
|
237226
|
+
const manager = await getManager();
|
|
237227
|
+
if (!manager) {
|
|
237228
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
237165
237229
|
}
|
|
237166
|
-
|
|
237167
|
-
|
|
237168
|
-
|
|
237169
|
-
|
|
237170
|
-
|
|
237171
|
-
|
|
237172
|
-
|
|
237173
|
-
|
|
237174
|
-
|
|
237175
|
-
|
|
237176
|
-
|
|
237177
|
-
|
|
237178
|
-
|
|
237179
|
-
|
|
237180
|
-
|
|
237181
|
-
|
|
237230
|
+
const storageService = manager.storage;
|
|
237231
|
+
switch (input.action) {
|
|
237232
|
+
case 'upload': {
|
|
237233
|
+
if (input.isDirectory) {
|
|
237234
|
+
// 上传目录
|
|
237235
|
+
await storageService.uploadDirectory({
|
|
237236
|
+
localPath: input.localPath,
|
|
237237
|
+
cloudPath: input.cloudPath,
|
|
237238
|
+
onProgress: (progressData) => {
|
|
237239
|
+
console.log("Upload directory progress:", progressData);
|
|
237240
|
+
}
|
|
237241
|
+
});
|
|
237242
|
+
}
|
|
237243
|
+
else {
|
|
237244
|
+
// 上传文件
|
|
237245
|
+
await storageService.uploadFile({
|
|
237246
|
+
localPath: input.localPath,
|
|
237247
|
+
cloudPath: input.cloudPath,
|
|
237248
|
+
onProgress: (progressData) => {
|
|
237249
|
+
console.log("Upload file progress:", progressData);
|
|
237250
|
+
}
|
|
237251
|
+
});
|
|
237252
|
+
}
|
|
237253
|
+
// 获取文件临时下载地址
|
|
237254
|
+
const fileUrls = await storageService.getTemporaryUrl([{
|
|
237255
|
+
cloudPath: input.cloudPath,
|
|
237256
|
+
maxAge: 3600 // 临时链接有效期1小时
|
|
237257
|
+
}]);
|
|
237258
|
+
return {
|
|
237259
|
+
content: [
|
|
237260
|
+
{
|
|
237261
|
+
type: "text",
|
|
237262
|
+
text: JSON.stringify({
|
|
237263
|
+
success: true,
|
|
237264
|
+
data: {
|
|
237265
|
+
action: 'upload',
|
|
237266
|
+
localPath: input.localPath,
|
|
237267
|
+
cloudPath: input.cloudPath,
|
|
237268
|
+
isDirectory: input.isDirectory,
|
|
237269
|
+
temporaryUrl: fileUrls[0]?.url || "",
|
|
237270
|
+
expireTime: "1小时"
|
|
237271
|
+
},
|
|
237272
|
+
message: `Successfully uploaded ${input.isDirectory ? 'directory' : 'file'} from '${input.localPath}' to '${input.cloudPath}'`
|
|
237273
|
+
}, null, 2)
|
|
237274
|
+
}
|
|
237275
|
+
]
|
|
237276
|
+
};
|
|
237182
237277
|
}
|
|
237183
|
-
|
|
237184
|
-
|
|
237278
|
+
case 'download': {
|
|
237279
|
+
if (input.isDirectory) {
|
|
237280
|
+
// 下载目录
|
|
237281
|
+
await storageService.downloadDirectory({
|
|
237282
|
+
cloudPath: input.cloudPath,
|
|
237283
|
+
localPath: input.localPath
|
|
237284
|
+
});
|
|
237285
|
+
}
|
|
237286
|
+
else {
|
|
237287
|
+
// 下载文件
|
|
237288
|
+
await storageService.downloadFile({
|
|
237289
|
+
cloudPath: input.cloudPath,
|
|
237290
|
+
localPath: input.localPath
|
|
237291
|
+
});
|
|
237292
|
+
}
|
|
237293
|
+
return {
|
|
237294
|
+
content: [
|
|
237295
|
+
{
|
|
237296
|
+
type: "text",
|
|
237297
|
+
text: JSON.stringify({
|
|
237298
|
+
success: true,
|
|
237299
|
+
data: {
|
|
237300
|
+
action: 'download',
|
|
237301
|
+
cloudPath: input.cloudPath,
|
|
237302
|
+
localPath: input.localPath,
|
|
237303
|
+
isDirectory: input.isDirectory
|
|
237304
|
+
},
|
|
237305
|
+
message: `Successfully downloaded ${input.isDirectory ? 'directory' : 'file'} from '${input.cloudPath}' to '${input.localPath}'`
|
|
237306
|
+
}, null, 2)
|
|
237307
|
+
}
|
|
237308
|
+
]
|
|
237309
|
+
};
|
|
237310
|
+
}
|
|
237311
|
+
case 'delete': {
|
|
237312
|
+
if (!input.force) {
|
|
237313
|
+
return {
|
|
237314
|
+
content: [
|
|
237315
|
+
{
|
|
237316
|
+
type: "text",
|
|
237317
|
+
text: JSON.stringify({
|
|
237318
|
+
success: false,
|
|
237319
|
+
error: "Delete operation requires confirmation",
|
|
237320
|
+
message: "Please set force: true to confirm deletion. This action cannot be undone."
|
|
237321
|
+
}, null, 2)
|
|
237322
|
+
}
|
|
237323
|
+
]
|
|
237324
|
+
};
|
|
237325
|
+
}
|
|
237326
|
+
if (input.isDirectory) {
|
|
237327
|
+
// 删除目录
|
|
237328
|
+
await storageService.deleteDirectory(input.cloudPath);
|
|
237329
|
+
}
|
|
237330
|
+
else {
|
|
237331
|
+
// 删除文件
|
|
237332
|
+
await storageService.deleteFile([input.cloudPath]);
|
|
237333
|
+
}
|
|
237334
|
+
return {
|
|
237335
|
+
content: [
|
|
237336
|
+
{
|
|
237337
|
+
type: "text",
|
|
237338
|
+
text: JSON.stringify({
|
|
237339
|
+
success: true,
|
|
237340
|
+
data: {
|
|
237341
|
+
action: 'delete',
|
|
237342
|
+
cloudPath: input.cloudPath,
|
|
237343
|
+
isDirectory: input.isDirectory,
|
|
237344
|
+
deleted: true
|
|
237345
|
+
},
|
|
237346
|
+
message: `Successfully deleted ${input.isDirectory ? 'directory' : 'file'} '${input.cloudPath}'`
|
|
237347
|
+
}, null, 2)
|
|
237348
|
+
}
|
|
237349
|
+
]
|
|
237350
|
+
};
|
|
237351
|
+
}
|
|
237352
|
+
default:
|
|
237353
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
237354
|
+
}
|
|
237355
|
+
}
|
|
237356
|
+
catch (error) {
|
|
237357
|
+
return {
|
|
237358
|
+
content: [
|
|
237359
|
+
{
|
|
237360
|
+
type: "text",
|
|
237361
|
+
text: JSON.stringify({
|
|
237362
|
+
success: false,
|
|
237363
|
+
error: error.message || 'Unknown error occurred',
|
|
237364
|
+
message: `Failed to manage storage. Please check your permissions and parameters.`
|
|
237365
|
+
}, null, 2)
|
|
237366
|
+
}
|
|
237367
|
+
]
|
|
237368
|
+
};
|
|
237369
|
+
}
|
|
237185
237370
|
});
|
|
237186
237371
|
}
|
|
237187
237372
|
|
package/dist/index.cjs
CHANGED
|
@@ -33812,58 +33812,9 @@ function downloadFile(url) {
|
|
|
33812
33812
|
});
|
|
33813
33813
|
}
|
|
33814
33814
|
function registerDownloadTools(server) {
|
|
33815
|
-
// downloadRemoteFile - 下载远程文件到临时目录 (cloud-incompatible)
|
|
33816
33815
|
server.registerTool("downloadRemoteFile", {
|
|
33817
|
-
title: "下载远程文件到临时目录",
|
|
33818
|
-
description: "下载远程文件到本地临时文件,返回一个系统的绝对路径。适用于需要临时处理文件的场景。",
|
|
33819
|
-
inputSchema: {
|
|
33820
|
-
url: zod_1.z.string().describe("远程文件的 URL 地址")
|
|
33821
|
-
},
|
|
33822
|
-
annotations: {
|
|
33823
|
-
readOnlyHint: false,
|
|
33824
|
-
destructiveHint: false,
|
|
33825
|
-
idempotentHint: false,
|
|
33826
|
-
openWorldHint: true,
|
|
33827
|
-
category: "download"
|
|
33828
|
-
}
|
|
33829
|
-
}, async ({ url }) => {
|
|
33830
|
-
try {
|
|
33831
|
-
const result = await downloadFile(url);
|
|
33832
|
-
return {
|
|
33833
|
-
content: [
|
|
33834
|
-
{
|
|
33835
|
-
type: "text",
|
|
33836
|
-
text: JSON.stringify({
|
|
33837
|
-
success: true,
|
|
33838
|
-
filePath: result.filePath,
|
|
33839
|
-
contentType: result.contentType,
|
|
33840
|
-
fileSize: result.fileSize,
|
|
33841
|
-
message: "文件下载成功到临时目录",
|
|
33842
|
-
note: "文件保存在临时目录中,请注意及时处理"
|
|
33843
|
-
}, null, 2)
|
|
33844
|
-
}
|
|
33845
|
-
]
|
|
33846
|
-
};
|
|
33847
|
-
}
|
|
33848
|
-
catch (error) {
|
|
33849
|
-
return {
|
|
33850
|
-
content: [
|
|
33851
|
-
{
|
|
33852
|
-
type: "text",
|
|
33853
|
-
text: JSON.stringify({
|
|
33854
|
-
success: false,
|
|
33855
|
-
error: error.message,
|
|
33856
|
-
message: "文件下载失败"
|
|
33857
|
-
}, null, 2)
|
|
33858
|
-
}
|
|
33859
|
-
]
|
|
33860
|
-
};
|
|
33861
|
-
}
|
|
33862
|
-
});
|
|
33863
|
-
// downloadRemoteFileToPath - 下载远程文件到指定路径 (cloud-incompatible)
|
|
33864
|
-
server.registerTool("downloadRemoteFileToPath", {
|
|
33865
33816
|
title: "下载远程文件到指定路径",
|
|
33866
|
-
description: "
|
|
33817
|
+
description: "下载远程文件到项目根目录下的指定相对路径。例如:小程序的 Tabbar 等素材图片,必须使用 **png** 格式,可以从 Unsplash、wikimedia【一般选用 500 大小即可、Pexels、Apple 官方 UI 等资源中选择来下载。",
|
|
33867
33818
|
inputSchema: {
|
|
33868
33819
|
url: zod_1.z.string().describe("远程文件的 URL 地址"),
|
|
33869
33820
|
relativePath: zod_1.z.string().describe("相对于项目根目录的路径,例如:'assets/images/logo.png' 或 'docs/api.md'。不允许使用 ../ 等路径遍历操作。")
|
|
@@ -97788,7 +97739,7 @@ function convertToJSONSchema(data) {
|
|
|
97788
97739
|
// 处理枚举类型
|
|
97789
97740
|
if (parsed.type.startsWith('x-enum')) {
|
|
97790
97741
|
schema.properties[parsed.name].type = 'string';
|
|
97791
|
-
schema.properties[parsed.name].format = 'enum';
|
|
97742
|
+
schema.properties[parsed.name].format = 'x-enum';
|
|
97792
97743
|
if (parsed.enumValues) {
|
|
97793
97744
|
schema.properties[parsed.name].enum = parsed.enumValues;
|
|
97794
97745
|
}
|
|
@@ -97975,7 +97926,6 @@ function getSpecialFormat(type) {
|
|
|
97975
97926
|
'x-location': 'x-location',
|
|
97976
97927
|
'x-area-code': 'x-area-code',
|
|
97977
97928
|
'x-file': 'x-file',
|
|
97978
|
-
'x-enum': 'enum',
|
|
97979
97929
|
};
|
|
97980
97930
|
// 只保留这些
|
|
97981
97931
|
return formatMap[type] || null;
|
|
@@ -121993,7 +121943,7 @@ class TelemetryReporter {
|
|
|
121993
121943
|
const nodeVersion = process.version; // Node.js版本
|
|
121994
121944
|
const arch = os_1.default.arch(); // 系统架构
|
|
121995
121945
|
// 从构建时注入的版本号获取MCP版本信息
|
|
121996
|
-
const mcpVersion = process.env.npm_package_version || "1.8.
|
|
121946
|
+
const mcpVersion = process.env.npm_package_version || "1.8.42" || 0;
|
|
121997
121947
|
return {
|
|
121998
121948
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
121999
121949
|
deviceId: this.deviceId,
|
|
@@ -179879,7 +179829,7 @@ ${envIdSection}
|
|
|
179879
179829
|
## 环境信息
|
|
179880
179830
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
179881
179831
|
- Node.js版本: ${process.version}
|
|
179882
|
-
- MCP 版本:${process.env.npm_package_version || "1.8.
|
|
179832
|
+
- MCP 版本:${process.env.npm_package_version || "1.8.42" || 0}
|
|
179883
179833
|
- 系统架构: ${os_1.default.arch()}
|
|
179884
179834
|
- 时间: ${new Date().toISOString()}
|
|
179885
179835
|
- 请求ID: ${requestId}
|
|
@@ -194905,7 +194855,7 @@ function registerSetupTools(server) {
|
|
|
194905
194855
|
// downloadTemplate - 下载项目模板 (cloud-incompatible)
|
|
194906
194856
|
server.registerTool("downloadTemplate", {
|
|
194907
194857
|
title: "下载项目模板",
|
|
194908
|
-
description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.
|
|
194858
|
+
description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.42" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
194909
194859
|
inputSchema: {
|
|
194910
194860
|
template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
|
|
194911
194861
|
ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
|
|
@@ -219574,7 +219524,11 @@ function shouldRegisterTool(toolName) {
|
|
|
219574
219524
|
'setupEnvironmentId',
|
|
219575
219525
|
'clearUserEnvId',
|
|
219576
219526
|
// Interactive tools - local server and file operations
|
|
219577
|
-
'interactiveDialog'
|
|
219527
|
+
'interactiveDialog',
|
|
219528
|
+
// CloudRun tools - local file operations
|
|
219529
|
+
'manageCloudRun',
|
|
219530
|
+
// Download tools - local file downloads
|
|
219531
|
+
'manageStorage',
|
|
219578
219532
|
];
|
|
219579
219533
|
const shouldRegister = !cloudIncompatibleTools.includes(toolName);
|
|
219580
219534
|
if (!shouldRegister) {
|
|
@@ -237030,54 +236984,285 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
237030
236984
|
exports.registerStorageTools = registerStorageTools;
|
|
237031
236985
|
const zod_1 = __webpack_require__(21614);
|
|
237032
236986
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
236987
|
+
// Input schema for queryStorage tool
|
|
236988
|
+
const queryStorageInputSchema = {
|
|
236989
|
+
action: zod_1.z.enum(['list', 'info', 'url']).describe('查询操作类型:list=列出目录下的所有文件,info=获取指定文件的详细信息,url=获取文件的临时下载链接'),
|
|
236990
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt 或 files/(目录)'),
|
|
236991
|
+
maxAge: zod_1.z.number().min(1).max(86400).optional().default(3600).describe('临时链接有效期,单位为秒,取值范围:1-86400,默认值:3600(1小时)')
|
|
236992
|
+
};
|
|
236993
|
+
// Input schema for manageStorage tool
|
|
236994
|
+
const manageStorageInputSchema = {
|
|
236995
|
+
action: zod_1.z.enum(['upload', 'download', 'delete']).describe('管理操作类型:upload=上传文件或目录,download=下载文件或目录,delete=删除文件或目录'),
|
|
236996
|
+
localPath: zod_1.z.string().describe('本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt'),
|
|
236997
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt'),
|
|
236998
|
+
force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,删除操作时建议设置为true以确认删除,默认false'),
|
|
236999
|
+
isDirectory: zod_1.z.boolean().optional().default(false).describe('是否为目录操作,true=目录操作,false=文件操作,默认false')
|
|
237000
|
+
};
|
|
237033
237001
|
function registerStorageTools(server) {
|
|
237034
237002
|
// 获取 cloudBaseOptions,如果没有则为 undefined
|
|
237035
237003
|
const cloudBaseOptions = server.cloudBaseOptions;
|
|
237036
237004
|
// 创建闭包函数来获取 CloudBase Manager
|
|
237037
237005
|
const getManager = () => (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions });
|
|
237038
|
-
//
|
|
237039
|
-
server.registerTool("
|
|
237040
|
-
title: "
|
|
237041
|
-
description: "
|
|
237042
|
-
inputSchema:
|
|
237043
|
-
|
|
237044
|
-
|
|
237045
|
-
|
|
237006
|
+
// Tool 1: queryStorage - 查询存储信息(只读操作)
|
|
237007
|
+
server.registerTool("queryStorage", {
|
|
237008
|
+
title: "查询存储信息",
|
|
237009
|
+
description: "查询云存储信息,支持列出目录文件、获取文件信息、获取临时下载链接等只读操作。返回的文件信息包括文件名、大小、修改时间、下载链接等。",
|
|
237010
|
+
inputSchema: queryStorageInputSchema,
|
|
237011
|
+
annotations: {
|
|
237012
|
+
readOnlyHint: true,
|
|
237013
|
+
openWorldHint: true,
|
|
237014
|
+
category: "storage"
|
|
237015
|
+
}
|
|
237016
|
+
}, async (args) => {
|
|
237017
|
+
try {
|
|
237018
|
+
const input = args;
|
|
237019
|
+
const manager = await getManager();
|
|
237020
|
+
if (!manager) {
|
|
237021
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
237022
|
+
}
|
|
237023
|
+
const storageService = manager.storage;
|
|
237024
|
+
switch (input.action) {
|
|
237025
|
+
case 'list': {
|
|
237026
|
+
const result = await storageService.listDirectoryFiles(input.cloudPath);
|
|
237027
|
+
return {
|
|
237028
|
+
content: [
|
|
237029
|
+
{
|
|
237030
|
+
type: "text",
|
|
237031
|
+
text: JSON.stringify({
|
|
237032
|
+
success: true,
|
|
237033
|
+
data: {
|
|
237034
|
+
action: 'list',
|
|
237035
|
+
cloudPath: input.cloudPath,
|
|
237036
|
+
files: result || [],
|
|
237037
|
+
totalCount: result?.length || 0
|
|
237038
|
+
},
|
|
237039
|
+
message: `Successfully listed ${result?.length || 0} files in directory '${input.cloudPath}'`
|
|
237040
|
+
}, null, 2)
|
|
237041
|
+
}
|
|
237042
|
+
]
|
|
237043
|
+
};
|
|
237044
|
+
}
|
|
237045
|
+
case 'info': {
|
|
237046
|
+
const result = await storageService.getFileInfo(input.cloudPath);
|
|
237047
|
+
return {
|
|
237048
|
+
content: [
|
|
237049
|
+
{
|
|
237050
|
+
type: "text",
|
|
237051
|
+
text: JSON.stringify({
|
|
237052
|
+
success: true,
|
|
237053
|
+
data: {
|
|
237054
|
+
action: 'info',
|
|
237055
|
+
cloudPath: input.cloudPath,
|
|
237056
|
+
fileInfo: result
|
|
237057
|
+
},
|
|
237058
|
+
message: `Successfully retrieved file info for '${input.cloudPath}'`
|
|
237059
|
+
}, null, 2)
|
|
237060
|
+
}
|
|
237061
|
+
]
|
|
237062
|
+
};
|
|
237063
|
+
}
|
|
237064
|
+
case 'url': {
|
|
237065
|
+
const result = await storageService.getTemporaryUrl([{
|
|
237066
|
+
cloudPath: input.cloudPath,
|
|
237067
|
+
maxAge: input.maxAge || 3600
|
|
237068
|
+
}]);
|
|
237069
|
+
return {
|
|
237070
|
+
content: [
|
|
237071
|
+
{
|
|
237072
|
+
type: "text",
|
|
237073
|
+
text: JSON.stringify({
|
|
237074
|
+
success: true,
|
|
237075
|
+
data: {
|
|
237076
|
+
action: 'url',
|
|
237077
|
+
cloudPath: input.cloudPath,
|
|
237078
|
+
temporaryUrl: result[0]?.url || "",
|
|
237079
|
+
expireTime: `${input.maxAge || 3600}秒`,
|
|
237080
|
+
fileId: result[0]?.fileId || ""
|
|
237081
|
+
},
|
|
237082
|
+
message: `Successfully generated temporary URL for '${input.cloudPath}'`
|
|
237083
|
+
}, null, 2)
|
|
237084
|
+
}
|
|
237085
|
+
]
|
|
237086
|
+
};
|
|
237087
|
+
}
|
|
237088
|
+
default:
|
|
237089
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
237090
|
+
}
|
|
237091
|
+
}
|
|
237092
|
+
catch (error) {
|
|
237093
|
+
return {
|
|
237094
|
+
content: [
|
|
237095
|
+
{
|
|
237096
|
+
type: "text",
|
|
237097
|
+
text: JSON.stringify({
|
|
237098
|
+
success: false,
|
|
237099
|
+
error: error.message || 'Unknown error occurred',
|
|
237100
|
+
message: `Failed to query storage information. Please check your permissions and parameters.`
|
|
237101
|
+
}, null, 2)
|
|
237102
|
+
}
|
|
237103
|
+
]
|
|
237104
|
+
};
|
|
237105
|
+
}
|
|
237106
|
+
});
|
|
237107
|
+
// Tool 2: manageStorage - 管理存储文件(写操作)
|
|
237108
|
+
server.registerTool("manageStorage", {
|
|
237109
|
+
title: "管理存储文件",
|
|
237110
|
+
description: "管理云存储文件,支持上传文件/目录、下载文件/目录、删除文件/目录等操作。删除操作需要设置force=true进行确认,防止误删除重要文件。",
|
|
237111
|
+
inputSchema: manageStorageInputSchema,
|
|
237046
237112
|
annotations: {
|
|
237047
237113
|
readOnlyHint: false,
|
|
237048
|
-
destructiveHint:
|
|
237114
|
+
destructiveHint: true,
|
|
237049
237115
|
idempotentHint: false,
|
|
237050
237116
|
openWorldHint: true,
|
|
237051
237117
|
category: "storage"
|
|
237052
237118
|
}
|
|
237053
|
-
}, async (
|
|
237054
|
-
|
|
237055
|
-
|
|
237056
|
-
|
|
237057
|
-
|
|
237058
|
-
|
|
237059
|
-
onProgress: (progressData) => {
|
|
237060
|
-
console.log("Upload progress:", progressData);
|
|
237119
|
+
}, async (args) => {
|
|
237120
|
+
try {
|
|
237121
|
+
const input = args;
|
|
237122
|
+
const manager = await getManager();
|
|
237123
|
+
if (!manager) {
|
|
237124
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
237061
237125
|
}
|
|
237062
|
-
|
|
237063
|
-
|
|
237064
|
-
|
|
237065
|
-
|
|
237066
|
-
|
|
237067
|
-
|
|
237068
|
-
|
|
237069
|
-
|
|
237070
|
-
|
|
237071
|
-
|
|
237072
|
-
|
|
237073
|
-
|
|
237074
|
-
|
|
237075
|
-
|
|
237076
|
-
|
|
237077
|
-
|
|
237126
|
+
const storageService = manager.storage;
|
|
237127
|
+
switch (input.action) {
|
|
237128
|
+
case 'upload': {
|
|
237129
|
+
if (input.isDirectory) {
|
|
237130
|
+
// 上传目录
|
|
237131
|
+
await storageService.uploadDirectory({
|
|
237132
|
+
localPath: input.localPath,
|
|
237133
|
+
cloudPath: input.cloudPath,
|
|
237134
|
+
onProgress: (progressData) => {
|
|
237135
|
+
console.log("Upload directory progress:", progressData);
|
|
237136
|
+
}
|
|
237137
|
+
});
|
|
237138
|
+
}
|
|
237139
|
+
else {
|
|
237140
|
+
// 上传文件
|
|
237141
|
+
await storageService.uploadFile({
|
|
237142
|
+
localPath: input.localPath,
|
|
237143
|
+
cloudPath: input.cloudPath,
|
|
237144
|
+
onProgress: (progressData) => {
|
|
237145
|
+
console.log("Upload file progress:", progressData);
|
|
237146
|
+
}
|
|
237147
|
+
});
|
|
237148
|
+
}
|
|
237149
|
+
// 获取文件临时下载地址
|
|
237150
|
+
const fileUrls = await storageService.getTemporaryUrl([{
|
|
237151
|
+
cloudPath: input.cloudPath,
|
|
237152
|
+
maxAge: 3600 // 临时链接有效期1小时
|
|
237153
|
+
}]);
|
|
237154
|
+
return {
|
|
237155
|
+
content: [
|
|
237156
|
+
{
|
|
237157
|
+
type: "text",
|
|
237158
|
+
text: JSON.stringify({
|
|
237159
|
+
success: true,
|
|
237160
|
+
data: {
|
|
237161
|
+
action: 'upload',
|
|
237162
|
+
localPath: input.localPath,
|
|
237163
|
+
cloudPath: input.cloudPath,
|
|
237164
|
+
isDirectory: input.isDirectory,
|
|
237165
|
+
temporaryUrl: fileUrls[0]?.url || "",
|
|
237166
|
+
expireTime: "1小时"
|
|
237167
|
+
},
|
|
237168
|
+
message: `Successfully uploaded ${input.isDirectory ? 'directory' : 'file'} from '${input.localPath}' to '${input.cloudPath}'`
|
|
237169
|
+
}, null, 2)
|
|
237170
|
+
}
|
|
237171
|
+
]
|
|
237172
|
+
};
|
|
237078
237173
|
}
|
|
237079
|
-
|
|
237080
|
-
|
|
237174
|
+
case 'download': {
|
|
237175
|
+
if (input.isDirectory) {
|
|
237176
|
+
// 下载目录
|
|
237177
|
+
await storageService.downloadDirectory({
|
|
237178
|
+
cloudPath: input.cloudPath,
|
|
237179
|
+
localPath: input.localPath
|
|
237180
|
+
});
|
|
237181
|
+
}
|
|
237182
|
+
else {
|
|
237183
|
+
// 下载文件
|
|
237184
|
+
await storageService.downloadFile({
|
|
237185
|
+
cloudPath: input.cloudPath,
|
|
237186
|
+
localPath: input.localPath
|
|
237187
|
+
});
|
|
237188
|
+
}
|
|
237189
|
+
return {
|
|
237190
|
+
content: [
|
|
237191
|
+
{
|
|
237192
|
+
type: "text",
|
|
237193
|
+
text: JSON.stringify({
|
|
237194
|
+
success: true,
|
|
237195
|
+
data: {
|
|
237196
|
+
action: 'download',
|
|
237197
|
+
cloudPath: input.cloudPath,
|
|
237198
|
+
localPath: input.localPath,
|
|
237199
|
+
isDirectory: input.isDirectory
|
|
237200
|
+
},
|
|
237201
|
+
message: `Successfully downloaded ${input.isDirectory ? 'directory' : 'file'} from '${input.cloudPath}' to '${input.localPath}'`
|
|
237202
|
+
}, null, 2)
|
|
237203
|
+
}
|
|
237204
|
+
]
|
|
237205
|
+
};
|
|
237206
|
+
}
|
|
237207
|
+
case 'delete': {
|
|
237208
|
+
if (!input.force) {
|
|
237209
|
+
return {
|
|
237210
|
+
content: [
|
|
237211
|
+
{
|
|
237212
|
+
type: "text",
|
|
237213
|
+
text: JSON.stringify({
|
|
237214
|
+
success: false,
|
|
237215
|
+
error: "Delete operation requires confirmation",
|
|
237216
|
+
message: "Please set force: true to confirm deletion. This action cannot be undone."
|
|
237217
|
+
}, null, 2)
|
|
237218
|
+
}
|
|
237219
|
+
]
|
|
237220
|
+
};
|
|
237221
|
+
}
|
|
237222
|
+
if (input.isDirectory) {
|
|
237223
|
+
// 删除目录
|
|
237224
|
+
await storageService.deleteDirectory(input.cloudPath);
|
|
237225
|
+
}
|
|
237226
|
+
else {
|
|
237227
|
+
// 删除文件
|
|
237228
|
+
await storageService.deleteFile([input.cloudPath]);
|
|
237229
|
+
}
|
|
237230
|
+
return {
|
|
237231
|
+
content: [
|
|
237232
|
+
{
|
|
237233
|
+
type: "text",
|
|
237234
|
+
text: JSON.stringify({
|
|
237235
|
+
success: true,
|
|
237236
|
+
data: {
|
|
237237
|
+
action: 'delete',
|
|
237238
|
+
cloudPath: input.cloudPath,
|
|
237239
|
+
isDirectory: input.isDirectory,
|
|
237240
|
+
deleted: true
|
|
237241
|
+
},
|
|
237242
|
+
message: `Successfully deleted ${input.isDirectory ? 'directory' : 'file'} '${input.cloudPath}'`
|
|
237243
|
+
}, null, 2)
|
|
237244
|
+
}
|
|
237245
|
+
]
|
|
237246
|
+
};
|
|
237247
|
+
}
|
|
237248
|
+
default:
|
|
237249
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
237250
|
+
}
|
|
237251
|
+
}
|
|
237252
|
+
catch (error) {
|
|
237253
|
+
return {
|
|
237254
|
+
content: [
|
|
237255
|
+
{
|
|
237256
|
+
type: "text",
|
|
237257
|
+
text: JSON.stringify({
|
|
237258
|
+
success: false,
|
|
237259
|
+
error: error.message || 'Unknown error occurred',
|
|
237260
|
+
message: `Failed to manage storage. Please check your permissions and parameters.`
|
|
237261
|
+
}, null, 2)
|
|
237262
|
+
}
|
|
237263
|
+
]
|
|
237264
|
+
};
|
|
237265
|
+
}
|
|
237081
237266
|
});
|
|
237082
237267
|
}
|
|
237083
237268
|
|
package/dist/index.js
CHANGED
|
@@ -1491,58 +1491,9 @@ function downloadFile(url) {
|
|
|
1491
1491
|
});
|
|
1492
1492
|
}
|
|
1493
1493
|
function registerDownloadTools(server) {
|
|
1494
|
-
// downloadRemoteFile - 下载远程文件到临时目录 (cloud-incompatible)
|
|
1495
1494
|
server.registerTool("downloadRemoteFile", {
|
|
1496
|
-
title: "下载远程文件到临时目录",
|
|
1497
|
-
description: "下载远程文件到本地临时文件,返回一个系统的绝对路径。适用于需要临时处理文件的场景。",
|
|
1498
|
-
inputSchema: {
|
|
1499
|
-
url: zod_1.z.string().describe("远程文件的 URL 地址")
|
|
1500
|
-
},
|
|
1501
|
-
annotations: {
|
|
1502
|
-
readOnlyHint: false,
|
|
1503
|
-
destructiveHint: false,
|
|
1504
|
-
idempotentHint: false,
|
|
1505
|
-
openWorldHint: true,
|
|
1506
|
-
category: "download"
|
|
1507
|
-
}
|
|
1508
|
-
}, async ({ url }) => {
|
|
1509
|
-
try {
|
|
1510
|
-
const result = await downloadFile(url);
|
|
1511
|
-
return {
|
|
1512
|
-
content: [
|
|
1513
|
-
{
|
|
1514
|
-
type: "text",
|
|
1515
|
-
text: JSON.stringify({
|
|
1516
|
-
success: true,
|
|
1517
|
-
filePath: result.filePath,
|
|
1518
|
-
contentType: result.contentType,
|
|
1519
|
-
fileSize: result.fileSize,
|
|
1520
|
-
message: "文件下载成功到临时目录",
|
|
1521
|
-
note: "文件保存在临时目录中,请注意及时处理"
|
|
1522
|
-
}, null, 2)
|
|
1523
|
-
}
|
|
1524
|
-
]
|
|
1525
|
-
};
|
|
1526
|
-
}
|
|
1527
|
-
catch (error) {
|
|
1528
|
-
return {
|
|
1529
|
-
content: [
|
|
1530
|
-
{
|
|
1531
|
-
type: "text",
|
|
1532
|
-
text: JSON.stringify({
|
|
1533
|
-
success: false,
|
|
1534
|
-
error: error.message,
|
|
1535
|
-
message: "文件下载失败"
|
|
1536
|
-
}, null, 2)
|
|
1537
|
-
}
|
|
1538
|
-
]
|
|
1539
|
-
};
|
|
1540
|
-
}
|
|
1541
|
-
});
|
|
1542
|
-
// downloadRemoteFileToPath - 下载远程文件到指定路径 (cloud-incompatible)
|
|
1543
|
-
server.registerTool("downloadRemoteFileToPath", {
|
|
1544
1495
|
title: "下载远程文件到指定路径",
|
|
1545
|
-
description: "
|
|
1496
|
+
description: "下载远程文件到项目根目录下的指定相对路径。例如:小程序的 Tabbar 等素材图片,必须使用 **png** 格式,可以从 Unsplash、wikimedia【一般选用 500 大小即可、Pexels、Apple 官方 UI 等资源中选择来下载。",
|
|
1546
1497
|
inputSchema: {
|
|
1547
1498
|
url: zod_1.z.string().describe("远程文件的 URL 地址"),
|
|
1548
1499
|
relativePath: zod_1.z.string().describe("相对于项目根目录的路径,例如:'assets/images/logo.png' 或 'docs/api.md'。不允许使用 ../ 等路径遍历操作。")
|
|
@@ -5057,7 +5008,7 @@ ${envIdSection}
|
|
|
5057
5008
|
## 环境信息
|
|
5058
5009
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
5059
5010
|
- Node.js版本: ${process.version}
|
|
5060
|
-
- MCP 版本:${process.env.npm_package_version || "1.8.
|
|
5011
|
+
- MCP 版本:${process.env.npm_package_version || "1.8.42" || 0}
|
|
5061
5012
|
- 系统架构: ${os_1.default.arch()}
|
|
5062
5013
|
- 时间: ${new Date().toISOString()}
|
|
5063
5014
|
- 请求ID: ${requestId}
|
|
@@ -6100,7 +6051,7 @@ function registerSetupTools(server) {
|
|
|
6100
6051
|
// downloadTemplate - 下载项目模板 (cloud-incompatible)
|
|
6101
6052
|
server.registerTool("downloadTemplate", {
|
|
6102
6053
|
title: "下载项目模板",
|
|
6103
|
-
description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.
|
|
6054
|
+
description: `自动下载并部署CloudBase项目模板。\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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "1.8.42" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
6104
6055
|
inputSchema: {
|
|
6105
6056
|
template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
|
|
6106
6057
|
ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
|
|
@@ -8256,7 +8207,11 @@ function shouldRegisterTool(toolName) {
|
|
|
8256
8207
|
'setupEnvironmentId',
|
|
8257
8208
|
'clearUserEnvId',
|
|
8258
8209
|
// Interactive tools - local server and file operations
|
|
8259
|
-
'interactiveDialog'
|
|
8210
|
+
'interactiveDialog',
|
|
8211
|
+
// CloudRun tools - local file operations
|
|
8212
|
+
'manageCloudRun',
|
|
8213
|
+
// Download tools - local file downloads
|
|
8214
|
+
'manageStorage',
|
|
8260
8215
|
];
|
|
8261
8216
|
const shouldRegister = !cloudIncompatibleTools.includes(toolName);
|
|
8262
8217
|
if (!shouldRegister) {
|
|
@@ -8383,54 +8338,285 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
8383
8338
|
exports.registerStorageTools = registerStorageTools;
|
|
8384
8339
|
const zod_1 = __webpack_require__(971);
|
|
8385
8340
|
const cloudbase_manager_js_1 = __webpack_require__(431);
|
|
8341
|
+
// Input schema for queryStorage tool
|
|
8342
|
+
const queryStorageInputSchema = {
|
|
8343
|
+
action: zod_1.z.enum(['list', 'info', 'url']).describe('查询操作类型:list=列出目录下的所有文件,info=获取指定文件的详细信息,url=获取文件的临时下载链接'),
|
|
8344
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt 或 files/(目录)'),
|
|
8345
|
+
maxAge: zod_1.z.number().min(1).max(86400).optional().default(3600).describe('临时链接有效期,单位为秒,取值范围:1-86400,默认值:3600(1小时)')
|
|
8346
|
+
};
|
|
8347
|
+
// Input schema for manageStorage tool
|
|
8348
|
+
const manageStorageInputSchema = {
|
|
8349
|
+
action: zod_1.z.enum(['upload', 'download', 'delete']).describe('管理操作类型:upload=上传文件或目录,download=下载文件或目录,delete=删除文件或目录'),
|
|
8350
|
+
localPath: zod_1.z.string().describe('本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt'),
|
|
8351
|
+
cloudPath: zod_1.z.string().describe('云端文件路径,例如 files/data.txt'),
|
|
8352
|
+
force: zod_1.z.boolean().optional().default(false).describe('强制操作开关,删除操作时建议设置为true以确认删除,默认false'),
|
|
8353
|
+
isDirectory: zod_1.z.boolean().optional().default(false).describe('是否为目录操作,true=目录操作,false=文件操作,默认false')
|
|
8354
|
+
};
|
|
8386
8355
|
function registerStorageTools(server) {
|
|
8387
8356
|
// 获取 cloudBaseOptions,如果没有则为 undefined
|
|
8388
8357
|
const cloudBaseOptions = server.cloudBaseOptions;
|
|
8389
8358
|
// 创建闭包函数来获取 CloudBase Manager
|
|
8390
8359
|
const getManager = () => (0, cloudbase_manager_js_1.getCloudBaseManager)({ cloudBaseOptions });
|
|
8391
|
-
//
|
|
8392
|
-
server.registerTool("
|
|
8393
|
-
title: "
|
|
8394
|
-
description: "
|
|
8395
|
-
inputSchema:
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8360
|
+
// Tool 1: queryStorage - 查询存储信息(只读操作)
|
|
8361
|
+
server.registerTool("queryStorage", {
|
|
8362
|
+
title: "查询存储信息",
|
|
8363
|
+
description: "查询云存储信息,支持列出目录文件、获取文件信息、获取临时下载链接等只读操作。返回的文件信息包括文件名、大小、修改时间、下载链接等。",
|
|
8364
|
+
inputSchema: queryStorageInputSchema,
|
|
8365
|
+
annotations: {
|
|
8366
|
+
readOnlyHint: true,
|
|
8367
|
+
openWorldHint: true,
|
|
8368
|
+
category: "storage"
|
|
8369
|
+
}
|
|
8370
|
+
}, async (args) => {
|
|
8371
|
+
try {
|
|
8372
|
+
const input = args;
|
|
8373
|
+
const manager = await getManager();
|
|
8374
|
+
if (!manager) {
|
|
8375
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
8376
|
+
}
|
|
8377
|
+
const storageService = manager.storage;
|
|
8378
|
+
switch (input.action) {
|
|
8379
|
+
case 'list': {
|
|
8380
|
+
const result = await storageService.listDirectoryFiles(input.cloudPath);
|
|
8381
|
+
return {
|
|
8382
|
+
content: [
|
|
8383
|
+
{
|
|
8384
|
+
type: "text",
|
|
8385
|
+
text: JSON.stringify({
|
|
8386
|
+
success: true,
|
|
8387
|
+
data: {
|
|
8388
|
+
action: 'list',
|
|
8389
|
+
cloudPath: input.cloudPath,
|
|
8390
|
+
files: result || [],
|
|
8391
|
+
totalCount: result?.length || 0
|
|
8392
|
+
},
|
|
8393
|
+
message: `Successfully listed ${result?.length || 0} files in directory '${input.cloudPath}'`
|
|
8394
|
+
}, null, 2)
|
|
8395
|
+
}
|
|
8396
|
+
]
|
|
8397
|
+
};
|
|
8398
|
+
}
|
|
8399
|
+
case 'info': {
|
|
8400
|
+
const result = await storageService.getFileInfo(input.cloudPath);
|
|
8401
|
+
return {
|
|
8402
|
+
content: [
|
|
8403
|
+
{
|
|
8404
|
+
type: "text",
|
|
8405
|
+
text: JSON.stringify({
|
|
8406
|
+
success: true,
|
|
8407
|
+
data: {
|
|
8408
|
+
action: 'info',
|
|
8409
|
+
cloudPath: input.cloudPath,
|
|
8410
|
+
fileInfo: result
|
|
8411
|
+
},
|
|
8412
|
+
message: `Successfully retrieved file info for '${input.cloudPath}'`
|
|
8413
|
+
}, null, 2)
|
|
8414
|
+
}
|
|
8415
|
+
]
|
|
8416
|
+
};
|
|
8417
|
+
}
|
|
8418
|
+
case 'url': {
|
|
8419
|
+
const result = await storageService.getTemporaryUrl([{
|
|
8420
|
+
cloudPath: input.cloudPath,
|
|
8421
|
+
maxAge: input.maxAge || 3600
|
|
8422
|
+
}]);
|
|
8423
|
+
return {
|
|
8424
|
+
content: [
|
|
8425
|
+
{
|
|
8426
|
+
type: "text",
|
|
8427
|
+
text: JSON.stringify({
|
|
8428
|
+
success: true,
|
|
8429
|
+
data: {
|
|
8430
|
+
action: 'url',
|
|
8431
|
+
cloudPath: input.cloudPath,
|
|
8432
|
+
temporaryUrl: result[0]?.url || "",
|
|
8433
|
+
expireTime: `${input.maxAge || 3600}秒`,
|
|
8434
|
+
fileId: result[0]?.fileId || ""
|
|
8435
|
+
},
|
|
8436
|
+
message: `Successfully generated temporary URL for '${input.cloudPath}'`
|
|
8437
|
+
}, null, 2)
|
|
8438
|
+
}
|
|
8439
|
+
]
|
|
8440
|
+
};
|
|
8441
|
+
}
|
|
8442
|
+
default:
|
|
8443
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
8444
|
+
}
|
|
8445
|
+
}
|
|
8446
|
+
catch (error) {
|
|
8447
|
+
return {
|
|
8448
|
+
content: [
|
|
8449
|
+
{
|
|
8450
|
+
type: "text",
|
|
8451
|
+
text: JSON.stringify({
|
|
8452
|
+
success: false,
|
|
8453
|
+
error: error.message || 'Unknown error occurred',
|
|
8454
|
+
message: `Failed to query storage information. Please check your permissions and parameters.`
|
|
8455
|
+
}, null, 2)
|
|
8456
|
+
}
|
|
8457
|
+
]
|
|
8458
|
+
};
|
|
8459
|
+
}
|
|
8460
|
+
});
|
|
8461
|
+
// Tool 2: manageStorage - 管理存储文件(写操作)
|
|
8462
|
+
server.registerTool("manageStorage", {
|
|
8463
|
+
title: "管理存储文件",
|
|
8464
|
+
description: "管理云存储文件,支持上传文件/目录、下载文件/目录、删除文件/目录等操作。删除操作需要设置force=true进行确认,防止误删除重要文件。",
|
|
8465
|
+
inputSchema: manageStorageInputSchema,
|
|
8399
8466
|
annotations: {
|
|
8400
8467
|
readOnlyHint: false,
|
|
8401
|
-
destructiveHint:
|
|
8468
|
+
destructiveHint: true,
|
|
8402
8469
|
idempotentHint: false,
|
|
8403
8470
|
openWorldHint: true,
|
|
8404
8471
|
category: "storage"
|
|
8405
8472
|
}
|
|
8406
|
-
}, async (
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
onProgress: (progressData) => {
|
|
8413
|
-
console.log("Upload progress:", progressData);
|
|
8473
|
+
}, async (args) => {
|
|
8474
|
+
try {
|
|
8475
|
+
const input = args;
|
|
8476
|
+
const manager = await getManager();
|
|
8477
|
+
if (!manager) {
|
|
8478
|
+
throw new Error("Failed to initialize CloudBase manager. Please check your credentials and environment configuration.");
|
|
8414
8479
|
}
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8480
|
+
const storageService = manager.storage;
|
|
8481
|
+
switch (input.action) {
|
|
8482
|
+
case 'upload': {
|
|
8483
|
+
if (input.isDirectory) {
|
|
8484
|
+
// 上传目录
|
|
8485
|
+
await storageService.uploadDirectory({
|
|
8486
|
+
localPath: input.localPath,
|
|
8487
|
+
cloudPath: input.cloudPath,
|
|
8488
|
+
onProgress: (progressData) => {
|
|
8489
|
+
console.log("Upload directory progress:", progressData);
|
|
8490
|
+
}
|
|
8491
|
+
});
|
|
8492
|
+
}
|
|
8493
|
+
else {
|
|
8494
|
+
// 上传文件
|
|
8495
|
+
await storageService.uploadFile({
|
|
8496
|
+
localPath: input.localPath,
|
|
8497
|
+
cloudPath: input.cloudPath,
|
|
8498
|
+
onProgress: (progressData) => {
|
|
8499
|
+
console.log("Upload file progress:", progressData);
|
|
8500
|
+
}
|
|
8501
|
+
});
|
|
8502
|
+
}
|
|
8503
|
+
// 获取文件临时下载地址
|
|
8504
|
+
const fileUrls = await storageService.getTemporaryUrl([{
|
|
8505
|
+
cloudPath: input.cloudPath,
|
|
8506
|
+
maxAge: 3600 // 临时链接有效期1小时
|
|
8507
|
+
}]);
|
|
8508
|
+
return {
|
|
8509
|
+
content: [
|
|
8510
|
+
{
|
|
8511
|
+
type: "text",
|
|
8512
|
+
text: JSON.stringify({
|
|
8513
|
+
success: true,
|
|
8514
|
+
data: {
|
|
8515
|
+
action: 'upload',
|
|
8516
|
+
localPath: input.localPath,
|
|
8517
|
+
cloudPath: input.cloudPath,
|
|
8518
|
+
isDirectory: input.isDirectory,
|
|
8519
|
+
temporaryUrl: fileUrls[0]?.url || "",
|
|
8520
|
+
expireTime: "1小时"
|
|
8521
|
+
},
|
|
8522
|
+
message: `Successfully uploaded ${input.isDirectory ? 'directory' : 'file'} from '${input.localPath}' to '${input.cloudPath}'`
|
|
8523
|
+
}, null, 2)
|
|
8524
|
+
}
|
|
8525
|
+
]
|
|
8526
|
+
};
|
|
8431
8527
|
}
|
|
8432
|
-
|
|
8433
|
-
|
|
8528
|
+
case 'download': {
|
|
8529
|
+
if (input.isDirectory) {
|
|
8530
|
+
// 下载目录
|
|
8531
|
+
await storageService.downloadDirectory({
|
|
8532
|
+
cloudPath: input.cloudPath,
|
|
8533
|
+
localPath: input.localPath
|
|
8534
|
+
});
|
|
8535
|
+
}
|
|
8536
|
+
else {
|
|
8537
|
+
// 下载文件
|
|
8538
|
+
await storageService.downloadFile({
|
|
8539
|
+
cloudPath: input.cloudPath,
|
|
8540
|
+
localPath: input.localPath
|
|
8541
|
+
});
|
|
8542
|
+
}
|
|
8543
|
+
return {
|
|
8544
|
+
content: [
|
|
8545
|
+
{
|
|
8546
|
+
type: "text",
|
|
8547
|
+
text: JSON.stringify({
|
|
8548
|
+
success: true,
|
|
8549
|
+
data: {
|
|
8550
|
+
action: 'download',
|
|
8551
|
+
cloudPath: input.cloudPath,
|
|
8552
|
+
localPath: input.localPath,
|
|
8553
|
+
isDirectory: input.isDirectory
|
|
8554
|
+
},
|
|
8555
|
+
message: `Successfully downloaded ${input.isDirectory ? 'directory' : 'file'} from '${input.cloudPath}' to '${input.localPath}'`
|
|
8556
|
+
}, null, 2)
|
|
8557
|
+
}
|
|
8558
|
+
]
|
|
8559
|
+
};
|
|
8560
|
+
}
|
|
8561
|
+
case 'delete': {
|
|
8562
|
+
if (!input.force) {
|
|
8563
|
+
return {
|
|
8564
|
+
content: [
|
|
8565
|
+
{
|
|
8566
|
+
type: "text",
|
|
8567
|
+
text: JSON.stringify({
|
|
8568
|
+
success: false,
|
|
8569
|
+
error: "Delete operation requires confirmation",
|
|
8570
|
+
message: "Please set force: true to confirm deletion. This action cannot be undone."
|
|
8571
|
+
}, null, 2)
|
|
8572
|
+
}
|
|
8573
|
+
]
|
|
8574
|
+
};
|
|
8575
|
+
}
|
|
8576
|
+
if (input.isDirectory) {
|
|
8577
|
+
// 删除目录
|
|
8578
|
+
await storageService.deleteDirectory(input.cloudPath);
|
|
8579
|
+
}
|
|
8580
|
+
else {
|
|
8581
|
+
// 删除文件
|
|
8582
|
+
await storageService.deleteFile([input.cloudPath]);
|
|
8583
|
+
}
|
|
8584
|
+
return {
|
|
8585
|
+
content: [
|
|
8586
|
+
{
|
|
8587
|
+
type: "text",
|
|
8588
|
+
text: JSON.stringify({
|
|
8589
|
+
success: true,
|
|
8590
|
+
data: {
|
|
8591
|
+
action: 'delete',
|
|
8592
|
+
cloudPath: input.cloudPath,
|
|
8593
|
+
isDirectory: input.isDirectory,
|
|
8594
|
+
deleted: true
|
|
8595
|
+
},
|
|
8596
|
+
message: `Successfully deleted ${input.isDirectory ? 'directory' : 'file'} '${input.cloudPath}'`
|
|
8597
|
+
}, null, 2)
|
|
8598
|
+
}
|
|
8599
|
+
]
|
|
8600
|
+
};
|
|
8601
|
+
}
|
|
8602
|
+
default:
|
|
8603
|
+
throw new Error(`Unsupported action: ${input.action}`);
|
|
8604
|
+
}
|
|
8605
|
+
}
|
|
8606
|
+
catch (error) {
|
|
8607
|
+
return {
|
|
8608
|
+
content: [
|
|
8609
|
+
{
|
|
8610
|
+
type: "text",
|
|
8611
|
+
text: JSON.stringify({
|
|
8612
|
+
success: false,
|
|
8613
|
+
error: error.message || 'Unknown error occurred',
|
|
8614
|
+
message: `Failed to manage storage. Please check your permissions and parameters.`
|
|
8615
|
+
}, null, 2)
|
|
8616
|
+
}
|
|
8617
|
+
]
|
|
8618
|
+
};
|
|
8619
|
+
}
|
|
8434
8620
|
});
|
|
8435
8621
|
}
|
|
8436
8622
|
|
|
@@ -8721,7 +8907,7 @@ class TelemetryReporter {
|
|
|
8721
8907
|
const nodeVersion = process.version; // Node.js版本
|
|
8722
8908
|
const arch = os_1.default.arch(); // 系统架构
|
|
8723
8909
|
// 从构建时注入的版本号获取MCP版本信息
|
|
8724
|
-
const mcpVersion = process.env.npm_package_version || "1.8.
|
|
8910
|
+
const mcpVersion = process.env.npm_package_version || "1.8.42" || 0;
|
|
8725
8911
|
return {
|
|
8726
8912
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
8727
8913
|
deviceId: this.deviceId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cloudbase-mcp",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.42",
|
|
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",
|