@cloudbase/cloudbase-mcp 1.0.2 → 1.0.3

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,28 +1,73 @@
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
+ };
1
37
  import { z } from "zod";
2
38
  import CloudBase from "@cloudbase/manager-node";
3
39
  // 初始化CloudBase
4
- const cloudbase = new CloudBase({
40
+ var cloudbase = new CloudBase({
5
41
  secretId: process.env.TENCENTCLOUD_SECRETID,
6
42
  secretKey: process.env.TENCENTCLOUD_SECRETKEY,
7
43
  envId: process.env.CLOUDBASE_ENV_ID,
8
44
  token: process.env.TENCENTCLOUD_SESSIONTOKEN
9
45
  });
10
46
  export function registerFunctionTools(server) {
47
+ var _this = this;
11
48
  // getFunctionList - 获取云函数列表(推荐)
12
49
  server.tool("getFunctionList", "获取云函数列表", {
13
50
  limit: z.number().optional().describe("范围"),
14
51
  offset: z.number().optional().describe("偏移")
15
- }, async ({ limit, offset }) => {
16
- const result = await cloudbase.functions.getFunctionList(limit, offset);
17
- return {
18
- content: [
19
- {
20
- type: "text",
21
- text: JSON.stringify(result, null, 2)
22
- }
23
- ]
24
- };
25
- });
52
+ }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
53
+ var result;
54
+ var limit = _b.limit, offset = _b.offset;
55
+ return __generator(this, function (_c) {
56
+ switch (_c.label) {
57
+ case 0: return [4 /*yield*/, cloudbase.functions.getFunctionList(limit, offset)];
58
+ case 1:
59
+ result = _c.sent();
60
+ return [2 /*return*/, {
61
+ content: [
62
+ {
63
+ type: "text",
64
+ text: JSON.stringify(result, null, 2)
65
+ }
66
+ ]
67
+ }];
68
+ }
69
+ });
70
+ }); });
26
71
  // createFunction - 创建云函数
27
72
  server.tool("createFunction", "创建云函数", {
28
73
  func: z.object({
@@ -52,23 +97,31 @@ export function registerFunctionTools(server) {
52
97
  force: z.boolean().describe("是否覆盖"),
53
98
  base64Code: z.string().optional().describe("base64编码的代码"),
54
99
  codeSecret: z.string().optional().describe("代码保护密钥")
55
- }, async ({ func, functionRootPath, force, base64Code, codeSecret }) => {
56
- const result = await cloudbase.functions.createFunction({
57
- func,
58
- functionRootPath,
59
- force,
60
- base64Code,
61
- codeSecret
100
+ }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
101
+ var result;
102
+ var func = _b.func, functionRootPath = _b.functionRootPath, force = _b.force, base64Code = _b.base64Code, codeSecret = _b.codeSecret;
103
+ return __generator(this, function (_c) {
104
+ switch (_c.label) {
105
+ case 0: return [4 /*yield*/, cloudbase.functions.createFunction({
106
+ func: func,
107
+ functionRootPath: functionRootPath,
108
+ force: force,
109
+ base64Code: base64Code,
110
+ codeSecret: codeSecret
111
+ })];
112
+ case 1:
113
+ result = _c.sent();
114
+ return [2 /*return*/, {
115
+ content: [
116
+ {
117
+ type: "text",
118
+ text: JSON.stringify(result, null, 2)
119
+ }
120
+ ]
121
+ }];
122
+ }
62
123
  });
63
- return {
64
- content: [
65
- {
66
- type: "text",
67
- text: JSON.stringify(result, null, 2)
68
- }
69
- ]
70
- };
71
- });
124
+ }); });
72
125
  // updateFunctionCode - 更新函数代码
73
126
  server.tool("updateFunctionCode", "更新云函数代码", {
74
127
  func: z.object({
@@ -77,22 +130,30 @@ export function registerFunctionTools(server) {
77
130
  functionRootPath: z.string().optional().describe("函数根目录"),
78
131
  base64Code: z.string().optional().describe("base64编码的代码"),
79
132
  codeSecret: z.string().optional().describe("代码保护密钥")
80
- }, async ({ func, functionRootPath, base64Code, codeSecret }) => {
81
- const result = await cloudbase.functions.updateFunctionCode({
82
- func,
83
- functionRootPath,
84
- base64Code,
85
- codeSecret
133
+ }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
134
+ var result;
135
+ var func = _b.func, functionRootPath = _b.functionRootPath, base64Code = _b.base64Code, codeSecret = _b.codeSecret;
136
+ return __generator(this, function (_c) {
137
+ switch (_c.label) {
138
+ case 0: return [4 /*yield*/, cloudbase.functions.updateFunctionCode({
139
+ func: func,
140
+ functionRootPath: functionRootPath,
141
+ base64Code: base64Code,
142
+ codeSecret: codeSecret
143
+ })];
144
+ case 1:
145
+ result = _c.sent();
146
+ return [2 /*return*/, {
147
+ content: [
148
+ {
149
+ type: "text",
150
+ text: JSON.stringify(result, null, 2)
151
+ }
152
+ ]
153
+ }];
154
+ }
86
155
  });
87
- return {
88
- content: [
89
- {
90
- type: "text",
91
- text: JSON.stringify(result, null, 2)
92
- }
93
- ]
94
- };
95
- });
156
+ }); });
96
157
  // updateFunctionConfig - 更新函数配置
97
158
  server.tool("updateFunctionConfig", "更新云函数配置", {
98
159
  funcParam: z.object({
@@ -105,47 +166,71 @@ export function registerFunctionTools(server) {
105
166
  }).optional().describe("VPC配置"),
106
167
  runtime: z.string().optional().describe("运行时")
107
168
  }).describe("函数配置")
108
- }, async ({ funcParam }) => {
109
- const result = await cloudbase.functions.updateFunctionConfig(funcParam);
110
- return {
111
- content: [
112
- {
113
- type: "text",
114
- text: JSON.stringify(result, null, 2)
115
- }
116
- ]
117
- };
118
- });
169
+ }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
170
+ var result;
171
+ var funcParam = _b.funcParam;
172
+ return __generator(this, function (_c) {
173
+ switch (_c.label) {
174
+ case 0: return [4 /*yield*/, cloudbase.functions.updateFunctionConfig(funcParam)];
175
+ case 1:
176
+ result = _c.sent();
177
+ return [2 /*return*/, {
178
+ content: [
179
+ {
180
+ type: "text",
181
+ text: JSON.stringify(result, null, 2)
182
+ }
183
+ ]
184
+ }];
185
+ }
186
+ });
187
+ }); });
119
188
  // getFunctionDetail - 获取函数详情
120
189
  server.tool("getFunctionDetail", "获取云函数详情", {
121
190
  name: z.string().describe("函数名称"),
122
191
  codeSecret: z.string().optional().describe("代码保护密钥")
123
- }, async ({ name, codeSecret }) => {
124
- const result = await cloudbase.functions.getFunctionDetail(name, codeSecret);
125
- return {
126
- content: [
127
- {
128
- type: "text",
129
- text: JSON.stringify(result, null, 2)
130
- }
131
- ]
132
- };
133
- });
192
+ }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
193
+ var result;
194
+ var name = _b.name, codeSecret = _b.codeSecret;
195
+ return __generator(this, function (_c) {
196
+ switch (_c.label) {
197
+ case 0: return [4 /*yield*/, cloudbase.functions.getFunctionDetail(name, codeSecret)];
198
+ case 1:
199
+ result = _c.sent();
200
+ return [2 /*return*/, {
201
+ content: [
202
+ {
203
+ type: "text",
204
+ text: JSON.stringify(result, null, 2)
205
+ }
206
+ ]
207
+ }];
208
+ }
209
+ });
210
+ }); });
134
211
  // invokeFunction - 调用函数
135
212
  server.tool("invokeFunction", "调用云函数", {
136
213
  name: z.string().describe("函数名称"),
137
214
  params: z.record(z.any()).optional().describe("调用参数")
138
- }, async ({ name, params }) => {
139
- const result = await cloudbase.functions.invokeFunction(name, params);
140
- return {
141
- content: [
142
- {
143
- type: "text",
144
- text: JSON.stringify(result, null, 2)
145
- }
146
- ]
147
- };
148
- });
215
+ }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
216
+ var result;
217
+ var name = _b.name, params = _b.params;
218
+ return __generator(this, function (_c) {
219
+ switch (_c.label) {
220
+ case 0: return [4 /*yield*/, cloudbase.functions.invokeFunction(name, params)];
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
+ }
232
+ });
233
+ }); });
149
234
  // getFunctionLogs - 获取函数日志
150
235
  server.tool("getFunctionLogs", "获取云函数日志", {
151
236
  options: z.object({
@@ -158,17 +243,25 @@ export function registerFunctionTools(server) {
158
243
  endTime: z.string().optional().describe("结束时间"),
159
244
  requestId: z.string().optional().describe("请求ID")
160
245
  }).describe("日志查询选项")
161
- }, async ({ options }) => {
162
- const result = await cloudbase.functions.getFunctionLogs(options);
163
- return {
164
- content: [
165
- {
166
- type: "text",
167
- text: JSON.stringify(result, null, 2)
168
- }
169
- ]
170
- };
171
- });
246
+ }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
247
+ var result;
248
+ var options = _b.options;
249
+ return __generator(this, function (_c) {
250
+ switch (_c.label) {
251
+ case 0: return [4 /*yield*/, cloudbase.functions.getFunctionLogs(options)];
252
+ case 1:
253
+ result = _c.sent();
254
+ return [2 /*return*/, {
255
+ content: [
256
+ {
257
+ type: "text",
258
+ text: JSON.stringify(result, null, 2)
259
+ }
260
+ ]
261
+ }];
262
+ }
263
+ });
264
+ }); });
172
265
  // createFunctionTriggers - 创建函数触发器
173
266
  server.tool("createFunctionTriggers", "创建云函数触发器", {
174
267
  name: z.string().describe("函数名"),
@@ -177,32 +270,48 @@ export function registerFunctionTools(server) {
177
270
  type: z.string().describe("触发器类型"),
178
271
  config: z.string().describe("触发器配置")
179
272
  })).describe("触发器配置数组")
180
- }, async ({ name, triggers }) => {
181
- const result = await cloudbase.functions.createFunctionTriggers(name, triggers);
182
- return {
183
- content: [
184
- {
185
- type: "text",
186
- text: JSON.stringify(result, null, 2)
187
- }
188
- ]
189
- };
190
- });
273
+ }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
274
+ var result;
275
+ var name = _b.name, triggers = _b.triggers;
276
+ return __generator(this, function (_c) {
277
+ switch (_c.label) {
278
+ case 0: return [4 /*yield*/, cloudbase.functions.createFunctionTriggers(name, triggers)];
279
+ case 1:
280
+ result = _c.sent();
281
+ return [2 /*return*/, {
282
+ content: [
283
+ {
284
+ type: "text",
285
+ text: JSON.stringify(result, null, 2)
286
+ }
287
+ ]
288
+ }];
289
+ }
290
+ });
291
+ }); });
191
292
  // deleteFunctionTrigger - 删除函数触发器
192
293
  server.tool("deleteFunctionTrigger", "删除云函数触发器", {
193
294
  name: z.string().describe("函数名"),
194
295
  triggerName: z.string().describe("触发器名称")
195
- }, async ({ name, triggerName }) => {
196
- const result = await cloudbase.functions.deleteFunctionTrigger(name, triggerName);
197
- return {
198
- content: [
199
- {
200
- type: "text",
201
- text: JSON.stringify(result, null, 2)
202
- }
203
- ]
204
- };
205
- });
296
+ }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
297
+ var result;
298
+ var name = _b.name, triggerName = _b.triggerName;
299
+ return __generator(this, function (_c) {
300
+ switch (_c.label) {
301
+ case 0: return [4 /*yield*/, cloudbase.functions.deleteFunctionTrigger(name, triggerName)];
302
+ case 1:
303
+ result = _c.sent();
304
+ return [2 /*return*/, {
305
+ content: [
306
+ {
307
+ type: "text",
308
+ text: JSON.stringify(result, null, 2)
309
+ }
310
+ ]
311
+ }];
312
+ }
313
+ });
314
+ }); });
206
315
  // // Layer相关功能
207
316
  // // createLayer - 创建Layer
208
317
  // server.tool(