@cloudbase/cloudbase-mcp 1.0.3 → 1.0.4

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.
@@ -1,50 +1,13 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
1
  import { z } from "zod";
38
2
  import CloudBase from "@cloudbase/manager-node";
39
3
  // 初始化CloudBase
40
- var cloudbase = new CloudBase({
4
+ const cloudbase = new CloudBase({
41
5
  secretId: process.env.TENCENTCLOUD_SECRETID,
42
6
  secretKey: process.env.TENCENTCLOUD_SECRETKEY,
43
7
  envId: process.env.CLOUDBASE_ENV_ID,
44
8
  token: process.env.TENCENTCLOUD_SESSIONTOKEN
45
9
  });
46
10
  export function registerHostingTools(server) {
47
- var _this = this;
48
11
  // uploadFiles - 上传文件到静态网站托管
49
12
  server.tool("uploadFiles", "上传文件到静态网站托管", {
50
13
  localPath: z.string().optional().describe("本地文件或文件夹路径"),
@@ -54,103 +17,72 @@ export function registerHostingTools(server) {
54
17
  cloudPath: z.string()
55
18
  })).default([]).describe("多文件上传配置"),
56
19
  ignore: z.union([z.string(), z.array(z.string())]).optional().describe("忽略文件模式")
57
- }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
58
- var result;
59
- var localPath = _b.localPath, cloudPath = _b.cloudPath, files = _b.files, ignore = _b.ignore;
60
- return __generator(this, function (_c) {
61
- switch (_c.label) {
62
- case 0: return [4 /*yield*/, cloudbase.hosting.uploadFiles({
63
- localPath: localPath,
64
- cloudPath: cloudPath,
65
- files: files,
66
- ignore: ignore
67
- })];
68
- case 1:
69
- result = _c.sent();
70
- return [2 /*return*/, {
71
- content: [
72
- {
73
- type: "text",
74
- text: JSON.stringify(result, null, 2)
75
- }
76
- ]
77
- }];
78
- }
20
+ }, async ({ localPath, cloudPath, files, ignore }) => {
21
+ const result = await cloudbase.hosting.uploadFiles({
22
+ localPath,
23
+ cloudPath,
24
+ files,
25
+ ignore
79
26
  });
80
- }); });
27
+ return {
28
+ content: [
29
+ {
30
+ type: "text",
31
+ text: JSON.stringify(result, null, 2)
32
+ }
33
+ ]
34
+ };
35
+ });
81
36
  // listFiles - 获取文件列表
82
- server.tool("listFiles", "获取静态网站托管的文件列表", {}, function () { return __awaiter(_this, void 0, void 0, function () {
83
- var result;
84
- return __generator(this, function (_a) {
85
- switch (_a.label) {
86
- case 0: return [4 /*yield*/, cloudbase.hosting.listFiles()];
87
- case 1:
88
- result = _a.sent();
89
- return [2 /*return*/, {
90
- content: [
91
- {
92
- type: "text",
93
- text: JSON.stringify(result, null, 2)
94
- }
95
- ]
96
- }];
97
- }
98
- });
99
- }); });
37
+ server.tool("listFiles", "获取静态网站托管的文件列表", {}, async () => {
38
+ const result = await cloudbase.hosting.listFiles();
39
+ return {
40
+ content: [
41
+ {
42
+ type: "text",
43
+ text: JSON.stringify(result, null, 2)
44
+ }
45
+ ]
46
+ };
47
+ });
100
48
  // deleteFiles - 删除文件
101
49
  server.tool("deleteFiles", "删除静态网站托管的文件或文件夹", {
102
50
  cloudPath: z.string().describe("云端文件或文件夹路径"),
103
51
  isDir: z.boolean().default(false).describe("是否为文件夹")
104
- }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
105
- var result;
106
- var cloudPath = _b.cloudPath, isDir = _b.isDir;
107
- return __generator(this, function (_c) {
108
- switch (_c.label) {
109
- case 0: return [4 /*yield*/, cloudbase.hosting.deleteFiles({
110
- cloudPath: cloudPath,
111
- isDir: isDir
112
- })];
113
- case 1:
114
- result = _c.sent();
115
- return [2 /*return*/, {
116
- content: [
117
- {
118
- type: "text",
119
- text: JSON.stringify(result, null, 2)
120
- }
121
- ]
122
- }];
123
- }
52
+ }, async ({ cloudPath, isDir }) => {
53
+ const result = await cloudbase.hosting.deleteFiles({
54
+ cloudPath,
55
+ isDir
124
56
  });
125
- }); });
57
+ return {
58
+ content: [
59
+ {
60
+ type: "text",
61
+ text: JSON.stringify(result, null, 2)
62
+ }
63
+ ]
64
+ };
65
+ });
126
66
  // findFiles - 搜索文件
127
67
  server.tool("findFiles", "搜索静态网站托管的文件", {
128
68
  prefix: z.string().describe("匹配前缀"),
129
69
  marker: z.string().optional().describe("起始对象键标记"),
130
70
  maxKeys: z.number().optional().describe("单次返回最大条目数")
131
- }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
132
- var result;
133
- var prefix = _b.prefix, marker = _b.marker, maxKeys = _b.maxKeys;
134
- return __generator(this, function (_c) {
135
- switch (_c.label) {
136
- case 0: return [4 /*yield*/, cloudbase.hosting.findFiles({
137
- prefix: prefix,
138
- marker: marker,
139
- maxKeys: maxKeys
140
- })];
141
- case 1:
142
- result = _c.sent();
143
- return [2 /*return*/, {
144
- content: [
145
- {
146
- type: "text",
147
- text: JSON.stringify(result, null, 2)
148
- }
149
- ]
150
- }];
151
- }
71
+ }, async ({ prefix, marker, maxKeys }) => {
72
+ const result = await cloudbase.hosting.findFiles({
73
+ prefix,
74
+ marker,
75
+ maxKeys
152
76
  });
153
- }); });
77
+ return {
78
+ content: [
79
+ {
80
+ type: "text",
81
+ text: JSON.stringify(result, null, 2)
82
+ }
83
+ ]
84
+ };
85
+ });
154
86
  // // setWebsiteDocument - 配置静态网站文档
155
87
  // server.tool(
156
88
  // "setWebsiteDocument",
@@ -185,95 +117,64 @@ export function registerHostingTools(server) {
185
117
  server.tool("createHostingDomain", "绑定自定义域名", {
186
118
  domain: z.string().describe("自定义域名"),
187
119
  certId: z.string().describe("证书ID")
188
- }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
189
- var result;
190
- var domain = _b.domain, certId = _b.certId;
191
- return __generator(this, function (_c) {
192
- switch (_c.label) {
193
- case 0: return [4 /*yield*/, cloudbase.hosting.CreateHostingDomain({
194
- domain: domain,
195
- certId: certId
196
- })];
197
- case 1:
198
- result = _c.sent();
199
- return [2 /*return*/, {
200
- content: [
201
- {
202
- type: "text",
203
- text: JSON.stringify(result, null, 2)
204
- }
205
- ]
206
- }];
207
- }
120
+ }, async ({ domain, certId }) => {
121
+ const result = await cloudbase.hosting.CreateHostingDomain({
122
+ domain,
123
+ certId
208
124
  });
209
- }); });
125
+ return {
126
+ content: [
127
+ {
128
+ type: "text",
129
+ text: JSON.stringify(result, null, 2)
130
+ }
131
+ ]
132
+ };
133
+ });
210
134
  // deleteHostingDomain - 解绑自定义域名
211
135
  server.tool("deleteHostingDomain", "解绑自定义域名", {
212
136
  domain: z.string().describe("自定义域名")
213
- }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
214
- var result;
215
- var domain = _b.domain;
216
- return __generator(this, function (_c) {
217
- switch (_c.label) {
218
- case 0: return [4 /*yield*/, cloudbase.hosting.deleteHostingDomain({
219
- domain: domain
220
- })];
221
- case 1:
222
- result = _c.sent();
223
- return [2 /*return*/, {
224
- content: [
225
- {
226
- type: "text",
227
- text: JSON.stringify(result, null, 2)
228
- }
229
- ]
230
- }];
231
- }
137
+ }, async ({ domain }) => {
138
+ const result = await cloudbase.hosting.deleteHostingDomain({
139
+ domain
232
140
  });
233
- }); });
141
+ return {
142
+ content: [
143
+ {
144
+ type: "text",
145
+ text: JSON.stringify(result, null, 2)
146
+ }
147
+ ]
148
+ };
149
+ });
234
150
  // getWebsiteConfig - 获取静态网站配置
235
- server.tool("getWebsiteConfig", "获取静态网站配置", {}, function () { return __awaiter(_this, void 0, void 0, function () {
236
- var result;
237
- return __generator(this, function (_a) {
238
- switch (_a.label) {
239
- case 0: return [4 /*yield*/, cloudbase.hosting.getWebsiteConfig()];
240
- case 1:
241
- result = _a.sent();
242
- return [2 /*return*/, {
243
- content: [
244
- {
245
- type: "text",
246
- text: JSON.stringify(result, null, 2)
247
- }
248
- ]
249
- }];
250
- }
251
- });
252
- }); });
151
+ server.tool("getWebsiteConfig", "获取静态网站配置", {}, async () => {
152
+ const result = await cloudbase.hosting.getWebsiteConfig();
153
+ return {
154
+ content: [
155
+ {
156
+ type: "text",
157
+ text: JSON.stringify(result, null, 2)
158
+ }
159
+ ]
160
+ };
161
+ });
253
162
  // tcbCheckResource - 获取域名配置
254
163
  server.tool("tcbCheckResource", "获取域名配置", {
255
164
  domains: z.array(z.string()).describe("域名列表")
256
- }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
257
- var result;
258
- var domains = _b.domains;
259
- return __generator(this, function (_c) {
260
- switch (_c.label) {
261
- case 0: return [4 /*yield*/, cloudbase.hosting.tcbCheckResource({
262
- domains: domains
263
- })];
264
- case 1:
265
- result = _c.sent();
266
- return [2 /*return*/, {
267
- content: [
268
- {
269
- type: "text",
270
- text: JSON.stringify(result, null, 2)
271
- }
272
- ]
273
- }];
274
- }
165
+ }, async ({ domains }) => {
166
+ const result = await cloudbase.hosting.tcbCheckResource({
167
+ domains
275
168
  });
276
- }); });
169
+ return {
170
+ content: [
171
+ {
172
+ type: "text",
173
+ text: JSON.stringify(result, null, 2)
174
+ }
175
+ ]
176
+ };
177
+ });
277
178
  // tcbModifyAttribute - 修改域名配置
278
179
  server.tool("tcbModifyAttribute", "修改域名配置", {
279
180
  domain: z.string().describe("域名"),
@@ -302,27 +203,19 @@ export function registerHostingTools(server) {
302
203
  Qps: z.number().optional()
303
204
  }).optional()
304
205
  }).describe("域名配置")
305
- }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
306
- var result;
307
- var domain = _b.domain, domainId = _b.domainId, domainConfig = _b.domainConfig;
308
- return __generator(this, function (_c) {
309
- switch (_c.label) {
310
- case 0: return [4 /*yield*/, cloudbase.hosting.tcbModifyAttribute({
311
- domain: domain,
312
- domainId: domainId,
313
- domainConfig: domainConfig
314
- })];
315
- case 1:
316
- result = _c.sent();
317
- return [2 /*return*/, {
318
- content: [
319
- {
320
- type: "text",
321
- text: JSON.stringify(result, null, 2)
322
- }
323
- ]
324
- }];
325
- }
206
+ }, async ({ domain, domainId, domainConfig }) => {
207
+ const result = await cloudbase.hosting.tcbModifyAttribute({
208
+ domain,
209
+ domainId,
210
+ domainConfig
326
211
  });
327
- }); });
212
+ return {
213
+ content: [
214
+ {
215
+ type: "text",
216
+ text: JSON.stringify(result, null, 2)
217
+ }
218
+ ]
219
+ };
220
+ });
328
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cloudbase-mcp",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "腾讯云开发 MCP Server,支持静态托管/环境查询/",
5
5
  "main": "index.js",
6
6
  "type": "module",