@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,73 +1,28 @@
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 registerFunctionTools(server) {
47
- var _this = this;
48
11
  // getFunctionList - 获取云函数列表(推荐)
49
12
  server.tool("getFunctionList", "获取云函数列表", {
50
13
  limit: z.number().optional().describe("范围"),
51
14
  offset: z.number().optional().describe("偏移")
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
- }); });
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
+ });
71
26
  // createFunction - 创建云函数
72
27
  server.tool("createFunction", "创建云函数", {
73
28
  func: z.object({
@@ -97,31 +52,23 @@ export function registerFunctionTools(server) {
97
52
  force: z.boolean().describe("是否覆盖"),
98
53
  base64Code: z.string().optional().describe("base64编码的代码"),
99
54
  codeSecret: z.string().optional().describe("代码保护密钥")
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
- }
55
+ }, async ({ func, functionRootPath, force, base64Code, codeSecret }) => {
56
+ const result = await cloudbase.functions.createFunction({
57
+ func,
58
+ functionRootPath,
59
+ force,
60
+ base64Code,
61
+ codeSecret
123
62
  });
124
- }); });
63
+ return {
64
+ content: [
65
+ {
66
+ type: "text",
67
+ text: JSON.stringify(result, null, 2)
68
+ }
69
+ ]
70
+ };
71
+ });
125
72
  // updateFunctionCode - 更新函数代码
126
73
  server.tool("updateFunctionCode", "更新云函数代码", {
127
74
  func: z.object({
@@ -130,30 +77,22 @@ export function registerFunctionTools(server) {
130
77
  functionRootPath: z.string().optional().describe("函数根目录"),
131
78
  base64Code: z.string().optional().describe("base64编码的代码"),
132
79
  codeSecret: z.string().optional().describe("代码保护密钥")
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
- }
80
+ }, async ({ func, functionRootPath, base64Code, codeSecret }) => {
81
+ const result = await cloudbase.functions.updateFunctionCode({
82
+ func,
83
+ functionRootPath,
84
+ base64Code,
85
+ codeSecret
155
86
  });
156
- }); });
87
+ return {
88
+ content: [
89
+ {
90
+ type: "text",
91
+ text: JSON.stringify(result, null, 2)
92
+ }
93
+ ]
94
+ };
95
+ });
157
96
  // updateFunctionConfig - 更新函数配置
158
97
  server.tool("updateFunctionConfig", "更新云函数配置", {
159
98
  funcParam: z.object({
@@ -166,71 +105,47 @@ export function registerFunctionTools(server) {
166
105
  }).optional().describe("VPC配置"),
167
106
  runtime: z.string().optional().describe("运行时")
168
107
  }).describe("函数配置")
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
- }); });
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
+ });
188
119
  // getFunctionDetail - 获取函数详情
189
120
  server.tool("getFunctionDetail", "获取云函数详情", {
190
121
  name: z.string().describe("函数名称"),
191
122
  codeSecret: z.string().optional().describe("代码保护密钥")
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
- }); });
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
+ });
211
134
  // invokeFunction - 调用函数
212
135
  server.tool("invokeFunction", "调用云函数", {
213
136
  name: z.string().describe("函数名称"),
214
137
  params: z.record(z.any()).optional().describe("调用参数")
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
- }); });
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
+ });
234
149
  // getFunctionLogs - 获取函数日志
235
150
  server.tool("getFunctionLogs", "获取云函数日志", {
236
151
  options: z.object({
@@ -243,25 +158,17 @@ export function registerFunctionTools(server) {
243
158
  endTime: z.string().optional().describe("结束时间"),
244
159
  requestId: z.string().optional().describe("请求ID")
245
160
  }).describe("日志查询选项")
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
- }); });
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
+ });
265
172
  // createFunctionTriggers - 创建函数触发器
266
173
  server.tool("createFunctionTriggers", "创建云函数触发器", {
267
174
  name: z.string().describe("函数名"),
@@ -270,48 +177,32 @@ export function registerFunctionTools(server) {
270
177
  type: z.string().describe("触发器类型"),
271
178
  config: z.string().describe("触发器配置")
272
179
  })).describe("触发器配置数组")
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
- }); });
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
+ });
292
191
  // deleteFunctionTrigger - 删除函数触发器
293
192
  server.tool("deleteFunctionTrigger", "删除云函数触发器", {
294
193
  name: z.string().describe("函数名"),
295
194
  triggerName: z.string().describe("触发器名称")
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
- }); });
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
+ });
315
206
  // // Layer相关功能
316
207
  // // createLayer - 创建Layer
317
208
  // server.tool(