@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.
- package/dist/index.js +7 -53
- package/dist/tools/database.js +405 -558
- package/dist/tools/env.js +67 -149
- package/dist/tools/file.js +147 -208
- package/dist/tools/functions.js +109 -218
- package/dist/tools/hosting.js +116 -223
- package/package.json +1 -1
package/dist/tools/functions.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
},
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
},
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
},
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
-
},
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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(
|