@cloudbase/cloudbase-mcp 1.0.1 → 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.
- package/dist/index.js +79 -0
- package/dist/tools/database.js +810 -0
- package/dist/tools/env.js +248 -0
- package/dist/tools/file.js +251 -0
- package/dist/tools/functions.js +491 -0
- package/dist/tools/hosting.js +328 -0
- package/dist/types.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,491 @@
|
|
|
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
|
+
import { z } from "zod";
|
|
38
|
+
import CloudBase from "@cloudbase/manager-node";
|
|
39
|
+
// 初始化CloudBase
|
|
40
|
+
var cloudbase = new CloudBase({
|
|
41
|
+
secretId: process.env.TENCENTCLOUD_SECRETID,
|
|
42
|
+
secretKey: process.env.TENCENTCLOUD_SECRETKEY,
|
|
43
|
+
envId: process.env.CLOUDBASE_ENV_ID,
|
|
44
|
+
token: process.env.TENCENTCLOUD_SESSIONTOKEN
|
|
45
|
+
});
|
|
46
|
+
export function registerFunctionTools(server) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
// getFunctionList - 获取云函数列表(推荐)
|
|
49
|
+
server.tool("getFunctionList", "获取云函数列表", {
|
|
50
|
+
limit: z.number().optional().describe("范围"),
|
|
51
|
+
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
|
+
}); });
|
|
71
|
+
// createFunction - 创建云函数
|
|
72
|
+
server.tool("createFunction", "创建云函数", {
|
|
73
|
+
func: z.object({
|
|
74
|
+
name: z.string().describe("函数名称"),
|
|
75
|
+
timeout: z.number().optional().describe("函数超时时间"),
|
|
76
|
+
envVariables: z.record(z.string()).optional().describe("环境变量"),
|
|
77
|
+
vpc: z.object({
|
|
78
|
+
vpcId: z.string(),
|
|
79
|
+
subnetId: z.string()
|
|
80
|
+
}).optional().describe("私有网络配置"),
|
|
81
|
+
runtime: z.string().optional().describe("运行时环境"),
|
|
82
|
+
installDependency: z.boolean().optional().describe("是否安装依赖"),
|
|
83
|
+
triggers: z.array(z.object({
|
|
84
|
+
name: z.string(),
|
|
85
|
+
type: z.string(),
|
|
86
|
+
config: z.string()
|
|
87
|
+
})).optional().describe("触发器配置"),
|
|
88
|
+
handler: z.string().optional().describe("函数入口"),
|
|
89
|
+
ignore: z.union([z.string(), z.array(z.string())]).optional().describe("忽略文件"),
|
|
90
|
+
isWaitInstall: z.boolean().optional().describe("是否等待依赖安装"),
|
|
91
|
+
layers: z.array(z.object({
|
|
92
|
+
name: z.string(),
|
|
93
|
+
version: z.number()
|
|
94
|
+
})).optional().describe("Layer配置")
|
|
95
|
+
}).describe("函数配置"),
|
|
96
|
+
functionRootPath: z.string().optional().describe("函数根目录"),
|
|
97
|
+
force: z.boolean().describe("是否覆盖"),
|
|
98
|
+
base64Code: z.string().optional().describe("base64编码的代码"),
|
|
99
|
+
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
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); });
|
|
125
|
+
// updateFunctionCode - 更新函数代码
|
|
126
|
+
server.tool("updateFunctionCode", "更新云函数代码", {
|
|
127
|
+
func: z.object({
|
|
128
|
+
name: z.string().describe("函数名称")
|
|
129
|
+
}).describe("函数配置"),
|
|
130
|
+
functionRootPath: z.string().optional().describe("函数根目录"),
|
|
131
|
+
base64Code: z.string().optional().describe("base64编码的代码"),
|
|
132
|
+
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
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}); });
|
|
157
|
+
// updateFunctionConfig - 更新函数配置
|
|
158
|
+
server.tool("updateFunctionConfig", "更新云函数配置", {
|
|
159
|
+
funcParam: z.object({
|
|
160
|
+
name: z.string().describe("函数名称"),
|
|
161
|
+
timeout: z.number().optional().describe("超时时间"),
|
|
162
|
+
envVariables: z.record(z.string()).optional().describe("环境变量"),
|
|
163
|
+
vpc: z.object({
|
|
164
|
+
vpcId: z.string(),
|
|
165
|
+
subnetId: z.string()
|
|
166
|
+
}).optional().describe("VPC配置"),
|
|
167
|
+
runtime: z.string().optional().describe("运行时")
|
|
168
|
+
}).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
|
+
}); });
|
|
188
|
+
// getFunctionDetail - 获取函数详情
|
|
189
|
+
server.tool("getFunctionDetail", "获取云函数详情", {
|
|
190
|
+
name: z.string().describe("函数名称"),
|
|
191
|
+
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
|
+
}); });
|
|
211
|
+
// invokeFunction - 调用函数
|
|
212
|
+
server.tool("invokeFunction", "调用云函数", {
|
|
213
|
+
name: z.string().describe("函数名称"),
|
|
214
|
+
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
|
+
}); });
|
|
234
|
+
// getFunctionLogs - 获取函数日志
|
|
235
|
+
server.tool("getFunctionLogs", "获取云函数日志", {
|
|
236
|
+
options: z.object({
|
|
237
|
+
name: z.string().describe("函数名称"),
|
|
238
|
+
offset: z.number().optional().describe("偏移量"),
|
|
239
|
+
limit: z.number().optional().describe("返回数量"),
|
|
240
|
+
order: z.string().optional().describe("排序方式"),
|
|
241
|
+
orderBy: z.string().optional().describe("排序字段"),
|
|
242
|
+
startTime: z.string().optional().describe("开始时间"),
|
|
243
|
+
endTime: z.string().optional().describe("结束时间"),
|
|
244
|
+
requestId: z.string().optional().describe("请求ID")
|
|
245
|
+
}).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
|
+
}); });
|
|
265
|
+
// createFunctionTriggers - 创建函数触发器
|
|
266
|
+
server.tool("createFunctionTriggers", "创建云函数触发器", {
|
|
267
|
+
name: z.string().describe("函数名"),
|
|
268
|
+
triggers: z.array(z.object({
|
|
269
|
+
name: z.string().describe("触发器名称"),
|
|
270
|
+
type: z.string().describe("触发器类型"),
|
|
271
|
+
config: z.string().describe("触发器配置")
|
|
272
|
+
})).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
|
+
}); });
|
|
292
|
+
// deleteFunctionTrigger - 删除函数触发器
|
|
293
|
+
server.tool("deleteFunctionTrigger", "删除云函数触发器", {
|
|
294
|
+
name: z.string().describe("函数名"),
|
|
295
|
+
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
|
+
}); });
|
|
315
|
+
// // Layer相关功能
|
|
316
|
+
// // createLayer - 创建Layer
|
|
317
|
+
// server.tool(
|
|
318
|
+
// "createLayer",
|
|
319
|
+
// "创建Layer",
|
|
320
|
+
// {
|
|
321
|
+
// options: z.object({
|
|
322
|
+
// contentPath: z.string().optional().describe("Layer内容路径"),
|
|
323
|
+
// base64Content: z.string().optional().describe("base64编码的内容"),
|
|
324
|
+
// name: z.string().describe("Layer名称"),
|
|
325
|
+
// runtimes: z.array(z.string()).describe("运行时列表"),
|
|
326
|
+
// description: z.string().optional().describe("描述"),
|
|
327
|
+
// licenseInfo: z.string().optional().describe("许可证信息")
|
|
328
|
+
// }).describe("Layer配置")
|
|
329
|
+
// },
|
|
330
|
+
// async ({ options }) => {
|
|
331
|
+
// const result = await cloudbase.functions.createLayer(options);
|
|
332
|
+
// return {
|
|
333
|
+
// content: [
|
|
334
|
+
// {
|
|
335
|
+
// type: "text",
|
|
336
|
+
// text: JSON.stringify(result, null, 2)
|
|
337
|
+
// }
|
|
338
|
+
// ]
|
|
339
|
+
// };
|
|
340
|
+
// }
|
|
341
|
+
// );
|
|
342
|
+
// // listLayers - 获取Layer列表
|
|
343
|
+
// server.tool(
|
|
344
|
+
// "listLayers",
|
|
345
|
+
// "获取Layer列表",
|
|
346
|
+
// {
|
|
347
|
+
// options: z.object({
|
|
348
|
+
// offset: z.number().optional().describe("偏移"),
|
|
349
|
+
// limit: z.number().optional().describe("数量限制"),
|
|
350
|
+
// runtime: z.string().optional().describe("运行时"),
|
|
351
|
+
// searchKey: z.string().optional().describe("搜索关键字")
|
|
352
|
+
// }).optional().describe("查询选项")
|
|
353
|
+
// },
|
|
354
|
+
// async ({ options }) => {
|
|
355
|
+
// const result = await cloudbase.functions.listLayers(options || {});
|
|
356
|
+
// return {
|
|
357
|
+
// content: [
|
|
358
|
+
// {
|
|
359
|
+
// type: "text",
|
|
360
|
+
// text: JSON.stringify(result, null, 2)
|
|
361
|
+
// }
|
|
362
|
+
// ]
|
|
363
|
+
// };
|
|
364
|
+
// }
|
|
365
|
+
// );
|
|
366
|
+
// // getLayerVersion - 获取Layer版本详情
|
|
367
|
+
// server.tool(
|
|
368
|
+
// "getLayerVersion",
|
|
369
|
+
// "获取Layer版本详情",
|
|
370
|
+
// {
|
|
371
|
+
// options: z.object({
|
|
372
|
+
// name: z.string().describe("Layer名称"),
|
|
373
|
+
// version: z.number().describe("版本号")
|
|
374
|
+
// }).describe("查询选项")
|
|
375
|
+
// },
|
|
376
|
+
// async ({ options }) => {
|
|
377
|
+
// const result = await cloudbase.functions.getLayerVersion(options);
|
|
378
|
+
// return {
|
|
379
|
+
// content: [
|
|
380
|
+
// {
|
|
381
|
+
// type: "text",
|
|
382
|
+
// text: JSON.stringify(result, null, 2)
|
|
383
|
+
// }
|
|
384
|
+
// ]
|
|
385
|
+
// };
|
|
386
|
+
// }
|
|
387
|
+
// );
|
|
388
|
+
// // 版本管理相关功能
|
|
389
|
+
// // publishVersion - 发布新版本
|
|
390
|
+
// server.tool(
|
|
391
|
+
// "publishVersion",
|
|
392
|
+
// "发布函数新版本",
|
|
393
|
+
// {
|
|
394
|
+
// options: z.object({
|
|
395
|
+
// functionName: z.string().describe("函数名称"),
|
|
396
|
+
// description: z.string().optional().describe("版本描述")
|
|
397
|
+
// }).describe("发布选项")
|
|
398
|
+
// },
|
|
399
|
+
// async ({ options }) => {
|
|
400
|
+
// const result = await cloudbase.functions.publishVersion(options);
|
|
401
|
+
// return {
|
|
402
|
+
// content: [
|
|
403
|
+
// {
|
|
404
|
+
// type: "text",
|
|
405
|
+
// text: JSON.stringify(result, null, 2)
|
|
406
|
+
// }
|
|
407
|
+
// ]
|
|
408
|
+
// };
|
|
409
|
+
// }
|
|
410
|
+
// );
|
|
411
|
+
// // listVersionByFunction - 获取版本列表
|
|
412
|
+
// server.tool(
|
|
413
|
+
// "listVersionByFunction",
|
|
414
|
+
// "获取函数版本列表",
|
|
415
|
+
// {
|
|
416
|
+
// options: z.object({
|
|
417
|
+
// functionName: z.string().describe("函数名称"),
|
|
418
|
+
// offset: z.number().optional().describe("偏移"),
|
|
419
|
+
// limit: z.number().optional().describe("数量限制"),
|
|
420
|
+
// order: z.string().optional().describe("排序方式"),
|
|
421
|
+
// orderBy: z.string().optional().describe("排序字段")
|
|
422
|
+
// }).describe("查询选项")
|
|
423
|
+
// },
|
|
424
|
+
// async ({ options }) => {
|
|
425
|
+
// const result = await cloudbase.functions.listVersionByFunction(options);
|
|
426
|
+
// return {
|
|
427
|
+
// content: [
|
|
428
|
+
// {
|
|
429
|
+
// type: "text",
|
|
430
|
+
// text: JSON.stringify(result, null, 2)
|
|
431
|
+
// }
|
|
432
|
+
// ]
|
|
433
|
+
// };
|
|
434
|
+
// }
|
|
435
|
+
// );
|
|
436
|
+
// // 别名配置相关功能
|
|
437
|
+
// // updateFunctionAliasConfig - 更新别名配置
|
|
438
|
+
// server.tool(
|
|
439
|
+
// "updateFunctionAliasConfig",
|
|
440
|
+
// "更新函数别名配置",
|
|
441
|
+
// {
|
|
442
|
+
// options: z.object({
|
|
443
|
+
// functionName: z.string().describe("函数名称"),
|
|
444
|
+
// name: z.string().describe("别名名称"),
|
|
445
|
+
// functionVersion: z.string().describe("函数版本"),
|
|
446
|
+
// description: z.string().optional().describe("描述"),
|
|
447
|
+
// routingConfig: z.object({
|
|
448
|
+
// AddtionVersionMatchs: z.array(z.object({
|
|
449
|
+
// Version: z.string(),
|
|
450
|
+
// Key: z.string(),
|
|
451
|
+
// Method: z.string(),
|
|
452
|
+
// Expression: z.string()
|
|
453
|
+
// }))
|
|
454
|
+
// }).optional().describe("路由配置")
|
|
455
|
+
// }).describe("别名配置")
|
|
456
|
+
// },
|
|
457
|
+
// async ({ options }) => {
|
|
458
|
+
// const result = await cloudbase.functions.updateFunctionAliasConfig(options);
|
|
459
|
+
// return {
|
|
460
|
+
// content: [
|
|
461
|
+
// {
|
|
462
|
+
// type: "text",
|
|
463
|
+
// text: JSON.stringify(result, null, 2)
|
|
464
|
+
// }
|
|
465
|
+
// ]
|
|
466
|
+
// };
|
|
467
|
+
// }
|
|
468
|
+
// );
|
|
469
|
+
// // getFunctionAlias - 获取别名配置
|
|
470
|
+
// server.tool(
|
|
471
|
+
// "getFunctionAlias",
|
|
472
|
+
// "获取函数别名配置",
|
|
473
|
+
// {
|
|
474
|
+
// options: z.object({
|
|
475
|
+
// functionName: z.string().describe("函数名称"),
|
|
476
|
+
// name: z.string().describe("别名名称")
|
|
477
|
+
// }).describe("查询选项")
|
|
478
|
+
// },
|
|
479
|
+
// async ({ options }) => {
|
|
480
|
+
// const result = await cloudbase.functions.getFunctionAlias(options);
|
|
481
|
+
// return {
|
|
482
|
+
// content: [
|
|
483
|
+
// {
|
|
484
|
+
// type: "text",
|
|
485
|
+
// text: JSON.stringify(result, null, 2)
|
|
486
|
+
// }
|
|
487
|
+
// ]
|
|
488
|
+
// };
|
|
489
|
+
// }
|
|
490
|
+
// );
|
|
491
|
+
}
|