@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,328 @@
|
|
|
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 registerHostingTools(server) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
// uploadFiles - 上传文件到静态网站托管
|
|
49
|
+
server.tool("uploadFiles", "上传文件到静态网站托管", {
|
|
50
|
+
localPath: z.string().optional().describe("本地文件或文件夹路径"),
|
|
51
|
+
cloudPath: z.string().optional().describe("云端文件或文件夹路径"),
|
|
52
|
+
files: z.array(z.object({
|
|
53
|
+
localPath: z.string(),
|
|
54
|
+
cloudPath: z.string()
|
|
55
|
+
})).default([]).describe("多文件上传配置"),
|
|
56
|
+
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
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}); });
|
|
81
|
+
// 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
|
+
}); });
|
|
100
|
+
// deleteFiles - 删除文件
|
|
101
|
+
server.tool("deleteFiles", "删除静态网站托管的文件或文件夹", {
|
|
102
|
+
cloudPath: z.string().describe("云端文件或文件夹路径"),
|
|
103
|
+
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
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}); });
|
|
126
|
+
// findFiles - 搜索文件
|
|
127
|
+
server.tool("findFiles", "搜索静态网站托管的文件", {
|
|
128
|
+
prefix: z.string().describe("匹配前缀"),
|
|
129
|
+
marker: z.string().optional().describe("起始对象键标记"),
|
|
130
|
+
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
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}); });
|
|
154
|
+
// // setWebsiteDocument - 配置静态网站文档
|
|
155
|
+
// server.tool(
|
|
156
|
+
// "setWebsiteDocument",
|
|
157
|
+
// "配置静态网站的错误文档、索引文档和重定向规则",
|
|
158
|
+
// {
|
|
159
|
+
// indexDocument: z.string().describe("索引文档路径"),
|
|
160
|
+
// errorDocument: z.string().optional().describe("错误文档路径"),
|
|
161
|
+
// routingRules: z.array(z.object({
|
|
162
|
+
// keyPrefixEquals: z.string().optional(),
|
|
163
|
+
// httpErrorCodeReturnedEquals: z.string().optional(),
|
|
164
|
+
// replaceKeyWith: z.string().optional(),
|
|
165
|
+
// replaceKeyPrefixWith: z.string().optional()
|
|
166
|
+
// })).optional().describe("重定向规则")
|
|
167
|
+
// },
|
|
168
|
+
// async ({ indexDocument, errorDocument, routingRules }) => {
|
|
169
|
+
// const result = await cloudbase.hosting.setWebsiteDocument({
|
|
170
|
+
// indexDocument,
|
|
171
|
+
// errorDocument,
|
|
172
|
+
// routingRules
|
|
173
|
+
// });
|
|
174
|
+
// return {
|
|
175
|
+
// content: [
|
|
176
|
+
// {
|
|
177
|
+
// type: "text",
|
|
178
|
+
// text: JSON.stringify(result, null, 2)
|
|
179
|
+
// }
|
|
180
|
+
// ]
|
|
181
|
+
// };
|
|
182
|
+
// }
|
|
183
|
+
// );
|
|
184
|
+
// createHostingDomain - 绑定自定义域名
|
|
185
|
+
server.tool("createHostingDomain", "绑定自定义域名", {
|
|
186
|
+
domain: z.string().describe("自定义域名"),
|
|
187
|
+
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
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}); });
|
|
210
|
+
// deleteHostingDomain - 解绑自定义域名
|
|
211
|
+
server.tool("deleteHostingDomain", "解绑自定义域名", {
|
|
212
|
+
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
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}); });
|
|
234
|
+
// 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
|
+
}); });
|
|
253
|
+
// tcbCheckResource - 获取域名配置
|
|
254
|
+
server.tool("tcbCheckResource", "获取域名配置", {
|
|
255
|
+
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
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}); });
|
|
277
|
+
// tcbModifyAttribute - 修改域名配置
|
|
278
|
+
server.tool("tcbModifyAttribute", "修改域名配置", {
|
|
279
|
+
domain: z.string().describe("域名"),
|
|
280
|
+
domainId: z.number().describe("域名ID"),
|
|
281
|
+
domainConfig: z.object({
|
|
282
|
+
Refer: z.object({
|
|
283
|
+
Switch: z.string(),
|
|
284
|
+
RefererRules: z.array(z.object({
|
|
285
|
+
RefererType: z.string(),
|
|
286
|
+
Referers: z.array(z.string()),
|
|
287
|
+
AllowEmpty: z.boolean()
|
|
288
|
+
})).optional()
|
|
289
|
+
}).optional(),
|
|
290
|
+
Cache: z.array(z.object({
|
|
291
|
+
RuleType: z.string(),
|
|
292
|
+
RuleValue: z.string(),
|
|
293
|
+
CacheTtl: z.number()
|
|
294
|
+
})).optional(),
|
|
295
|
+
IpFilter: z.object({
|
|
296
|
+
Switch: z.string(),
|
|
297
|
+
FilterType: z.string().optional(),
|
|
298
|
+
Filters: z.array(z.string()).optional()
|
|
299
|
+
}).optional(),
|
|
300
|
+
IpFreqLimit: z.object({
|
|
301
|
+
Switch: z.string(),
|
|
302
|
+
Qps: z.number().optional()
|
|
303
|
+
}).optional()
|
|
304
|
+
}).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
|
+
}
|
|
326
|
+
});
|
|
327
|
+
}); });
|
|
328
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cloudbase-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "腾讯云开发 MCP Server,支持静态托管/环境查询/",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"clean": "rm -rf dist",
|
|
12
12
|
"prebuild": "npm run clean",
|
|
13
|
-
"build": "tsc && chmod 755
|
|
13
|
+
"build": "tsc && chmod 755 dist/index.js",
|
|
14
14
|
"prepublishOnly": "npm run build"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|