@cloudbase/cloudbase-mcp 1.0.9 → 1.0.10

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/auth.js ADDED
@@ -0,0 +1,17 @@
1
+ import { AuthSupevisor } from '@cloudbase/toolbox';
2
+ const auth = AuthSupevisor.getInstance({});
3
+ export async function getCreatial() {
4
+ const { TENCENTCLOUD_SECRETID, TENCENTCLOUD_SECRETKEY, TENCENTCLOUD_SESSIONTOKEN } = process.env;
5
+ if (TENCENTCLOUD_SECRETID && TENCENTCLOUD_SECRETKEY) {
6
+ await auth.loginByApiSecret(TENCENTCLOUD_SECRETID, TENCENTCLOUD_SECRETKEY, TENCENTCLOUD_SESSIONTOKEN);
7
+ }
8
+ const loginState = await auth.getLoginState();
9
+ if (!loginState) {
10
+ await auth.loginByWebAuth({});
11
+ const loginState = await auth.getLoginState();
12
+ return loginState;
13
+ }
14
+ else {
15
+ return loginState;
16
+ }
17
+ }
@@ -0,0 +1,13 @@
1
+ import CloudBase from "@cloudbase/manager-node";
2
+ import { getCreatial } from './auth.js';
3
+ export async function getCloudBaseManager() {
4
+ const loginState = await getCreatial();
5
+ const { envId, secretId, secretKey, token } = loginState;
6
+ const cloudbase = new CloudBase({
7
+ envId,
8
+ secretId,
9
+ secretKey,
10
+ token
11
+ });
12
+ return cloudbase;
13
+ }
package/dist/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { registerEnvTools } from "./tools/env.js";
5
- import { registerFileTools } from "./tools/file.js";
6
5
  import { registerFunctionTools } from "./tools/functions.js";
7
6
  import { registerDatabaseTools } from "./tools/database.js";
8
7
  import { registerHostingTools } from "./tools/hosting.js";
@@ -19,8 +18,8 @@ const server = new McpServer({
19
18
  });
20
19
  // Register environment management tools
21
20
  registerEnvTools(server);
22
- // Register file management tools
23
- registerFileTools(server);
21
+ // // Register file management tools
22
+ // registerFileTools(server);
24
23
  // Register database management tools
25
24
  registerDatabaseTools(server);
26
25
  // Register hosting management tools
@@ -1,14 +1,8 @@
1
1
  import { z } from "zod";
2
- import CloudBase from "@cloudbase/manager-node";
3
- // 初始化CloudBase
4
- const cloudbase = new CloudBase({
5
- secretId: process.env.TENCENTCLOUD_SECRETID,
6
- secretKey: process.env.TENCENTCLOUD_SECRETKEY,
7
- envId: process.env.CLOUDBASE_ENV_ID,
8
- token: process.env.TENCENTCLOUD_SESSIONTOKEN
9
- });
2
+ import { getCloudBaseManager } from '../cloudbase-manager.js';
10
3
  // 获取数据库实例ID
11
4
  async function getDatabaseInstanceId() {
5
+ const cloudbase = await getCloudBaseManager();
12
6
  const { EnvInfo } = await cloudbase.env.getEnvInfo();
13
7
  if (!EnvInfo?.Databases?.[0]?.InstanceId) {
14
8
  throw new Error("无法获取数据库实例ID");
@@ -21,6 +15,7 @@ export function registerDatabaseTools(server) {
21
15
  collectionName: z.string().describe("云开发数据库集合名称")
22
16
  }, async ({ collectionName }) => {
23
17
  try {
18
+ const cloudbase = await getCloudBaseManager();
24
19
  const result = await cloudbase.database.createCollection(collectionName);
25
20
  return {
26
21
  content: [
@@ -55,6 +50,7 @@ export function registerDatabaseTools(server) {
55
50
  collectionName: z.string().describe("云开发数据库集合名称")
56
51
  }, async ({ collectionName }) => {
57
52
  try {
53
+ const cloudbase = await getCloudBaseManager();
58
54
  const result = await cloudbase.database.checkCollectionExists(collectionName);
59
55
  return {
60
56
  content: [
@@ -144,6 +140,7 @@ export function registerDatabaseTools(server) {
144
140
  }).describe("更新选项,支持创建和删除索引")
145
141
  }, async ({ collectionName, options }) => {
146
142
  try {
143
+ const cloudbase = await getCloudBaseManager();
147
144
  const result = await cloudbase.database.updateCollection(collectionName, options);
148
145
  return {
149
146
  content: [
@@ -178,6 +175,7 @@ export function registerDatabaseTools(server) {
178
175
  collectionName: z.string().describe("云开发数据库集合名称")
179
176
  }, async ({ collectionName }) => {
180
177
  try {
178
+ const cloudbase = await getCloudBaseManager();
181
179
  const result = await cloudbase.database.describeCollection(collectionName);
182
180
  return {
183
181
  content: [
@@ -215,6 +213,7 @@ export function registerDatabaseTools(server) {
215
213
  limit: z.number().optional().describe("返回数量限制")
216
214
  }, async ({ offset, limit }) => {
217
215
  try {
216
+ const cloudbase = await getCloudBaseManager();
218
217
  const result = await cloudbase.database.listCollections({
219
218
  MgoOffset: offset,
220
219
  MgoLimit: limit
@@ -255,6 +254,7 @@ export function registerDatabaseTools(server) {
255
254
  indexName: z.string().describe("索引名称")
256
255
  }, async ({ collectionName, indexName }) => {
257
256
  try {
257
+ const cloudbase = await getCloudBaseManager();
258
258
  const result = await cloudbase.database.checkIndexExists(collectionName, indexName);
259
259
  return {
260
260
  content: [
@@ -429,6 +429,7 @@ export function registerDatabaseTools(server) {
429
429
  // 查询数据分布
430
430
  server.tool("distribution", "查询数据库中云开发数据库集合的数据分布情况", {}, async () => {
431
431
  try {
432
+ const cloudbase = await getCloudBaseManager();
432
433
  const result = await cloudbase.database.distribution();
433
434
  return {
434
435
  content: [
@@ -465,6 +466,7 @@ export function registerDatabaseTools(server) {
465
466
  documents: z.array(z.string()).describe("要插入的文档JSON 字符串数组,每个文档都是 JSON字符串,注意不是JSON对象")
466
467
  }, async ({ collectionName, documents }) => {
467
468
  try {
469
+ const cloudbase = await getCloudBaseManager();
468
470
  const instanceId = await getDatabaseInstanceId();
469
471
  const result = await cloudbase.commonService('flexdb').call({
470
472
  Action: 'PutItem',
@@ -513,6 +515,7 @@ export function registerDatabaseTools(server) {
513
515
  offset: z.number().optional().describe("跳过的记录数")
514
516
  }, async ({ collectionName, query, projection, sort, limit, offset }) => {
515
517
  try {
518
+ const cloudbase = await getCloudBaseManager();
516
519
  const instanceId = await getDatabaseInstanceId();
517
520
  const result = await cloudbase.commonService('flexdb').call({
518
521
  Action: 'Query',
@@ -565,6 +568,7 @@ export function registerDatabaseTools(server) {
565
568
  upsert: z.boolean().optional().describe("是否在不存在时插入")
566
569
  }, async ({ collectionName, query, update, isMulti, upsert }) => {
567
570
  try {
571
+ const cloudbase = await getCloudBaseManager();
568
572
  const instanceId = await getDatabaseInstanceId();
569
573
  const result = await cloudbase.commonService('flexdb').call({
570
574
  Action: 'UpdateItem',
@@ -615,6 +619,7 @@ export function registerDatabaseTools(server) {
615
619
  isMulti: z.boolean().optional().describe("是否删除多条记录")
616
620
  }, async ({ collectionName, query, isMulti }) => {
617
621
  try {
622
+ const cloudbase = await getCloudBaseManager();
618
623
  const instanceId = await getDatabaseInstanceId();
619
624
  const result = await cloudbase.commonService('flexdb').call({
620
625
  Action: 'DeleteItem',
package/dist/tools/env.js CHANGED
@@ -1,15 +1,9 @@
1
1
  import { z } from "zod";
2
- import CloudBase from "@cloudbase/manager-node";
3
- // 初始化CloudBase
4
- const cloudbase = new CloudBase({
5
- secretId: process.env.TENCENTCLOUD_SECRETID,
6
- secretKey: process.env.TENCENTCLOUD_SECRETKEY,
7
- envId: process.env.CLOUDBASE_ENV_ID,
8
- token: process.env.TENCENTCLOUD_SESSIONTOKEN
9
- });
2
+ import { getCloudBaseManager } from '../cloudbase-manager.js';
10
3
  export function registerEnvTools(server) {
11
4
  // listEnvs
12
5
  server.tool("listEnvs", "获取所有云开发环境信息", {}, async () => {
6
+ const cloudbase = await getCloudBaseManager();
13
7
  const result = await cloudbase.env.listEnvs();
14
8
  return {
15
9
  content: [
@@ -22,6 +16,7 @@ export function registerEnvTools(server) {
22
16
  });
23
17
  // getEnvAuthDomains
24
18
  server.tool("getEnvAuthDomains", "获取云开发环境的合法域名列表", {}, async () => {
19
+ const cloudbase = await getCloudBaseManager();
25
20
  const result = await cloudbase.env.getEnvAuthDomains();
26
21
  return {
27
22
  content: [
@@ -36,6 +31,7 @@ export function registerEnvTools(server) {
36
31
  server.tool("createEnvDomain", "为云开发环境添加安全域名", {
37
32
  domains: z.array(z.string()).describe("安全域名数组")
38
33
  }, async ({ domains }) => {
34
+ const cloudbase = await getCloudBaseManager();
39
35
  const result = await cloudbase.env.createEnvDomain(domains);
40
36
  return {
41
37
  content: [
@@ -50,6 +46,7 @@ export function registerEnvTools(server) {
50
46
  server.tool("deleteEnvDomain", "删除云开发环境的指定安全域名", {
51
47
  domains: z.array(z.string()).describe("安全域名数组")
52
48
  }, async ({ domains }) => {
49
+ const cloudbase = await getCloudBaseManager();
53
50
  const result = await cloudbase.env.deleteEnvDomain(domains);
54
51
  return {
55
52
  content: [
@@ -62,6 +59,7 @@ export function registerEnvTools(server) {
62
59
  });
63
60
  // getEnvInfo
64
61
  server.tool("getEnvInfo", "获取当前云开发环境信息", {}, async () => {
62
+ const cloudbase = await getCloudBaseManager();
65
63
  const result = await cloudbase.env.getEnvInfo();
66
64
  return {
67
65
  content: [
@@ -76,6 +74,7 @@ export function registerEnvTools(server) {
76
74
  server.tool("updateEnvInfo", "修改云开发环境别名", {
77
75
  alias: z.string().describe("环境别名")
78
76
  }, async ({ alias }) => {
77
+ const cloudbase = await getCloudBaseManager();
79
78
  const result = await cloudbase.env.updateEnvInfo(alias);
80
79
  return {
81
80
  content: [
@@ -92,6 +91,7 @@ export function registerEnvTools(server) {
92
91
  // "拉取登录配置列表",
93
92
  // {},
94
93
  // async () => {
94
+ // const cloudbase = await getCloudBaseManager()
95
95
  // const result = await cloudbase.env.getLoginConfigList();
96
96
  // return {
97
97
  // content: [
@@ -113,6 +113,7 @@ export function registerEnvTools(server) {
113
113
  // appSecret: z.string().optional().describe("第三方平台的AppSecret")
114
114
  // },
115
115
  // async ({ platform, appId, appSecret }) => {
116
+ // const cloudbase = await getCloudBaseManager()
116
117
  // const result = await cloudbase.env.createLoginConfig(platform, appId, appSecret);
117
118
  // return {
118
119
  // content: [
@@ -135,6 +136,7 @@ export function registerEnvTools(server) {
135
136
  // appSecret: z.string().optional().describe("第三方平台的AppSecret")
136
137
  // },
137
138
  // async ({ configId, status, appId, appSecret }) => {
139
+ // const cloudbase = await getCloudBaseManager()
138
140
  // const result = await cloudbase.env.updateLoginConfig(configId, status, appId, appSecret);
139
141
  // return {
140
142
  // content: [
@@ -152,6 +154,7 @@ export function registerEnvTools(server) {
152
154
  // "创建自定义登录密钥",
153
155
  // {},
154
156
  // async () => {
157
+ // const cloudbase = await getCloudBaseManager()
155
158
  // const result = await cloudbase.env.createCustomLoginKeys();
156
159
  // return {
157
160
  // content: [
@@ -1,18 +1,12 @@
1
1
  import { z } from "zod";
2
- import CloudBase from "@cloudbase/manager-node";
3
- // 初始化CloudBase
4
- const cloudbase = new CloudBase({
5
- secretId: process.env.TENCENTCLOUD_SECRETID,
6
- secretKey: process.env.TENCENTCLOUD_SECRETKEY,
7
- envId: process.env.CLOUDBASE_ENV_ID,
8
- token: process.env.TENCENTCLOUD_SESSIONTOKEN
9
- });
2
+ import { getCloudBaseManager } from '../cloudbase-manager.js';
10
3
  export function registerFunctionTools(server) {
11
4
  // getFunctionList - 获取云函数列表(推荐)
12
5
  server.tool("getFunctionList", "获取云函数列表", {
13
6
  limit: z.number().optional().describe("范围"),
14
7
  offset: z.number().optional().describe("偏移")
15
8
  }, async ({ limit, offset }) => {
9
+ const cloudbase = await getCloudBaseManager();
16
10
  const result = await cloudbase.functions.getFunctionList(limit, offset);
17
11
  return {
18
12
  content: [
@@ -53,6 +47,7 @@ export function registerFunctionTools(server) {
53
47
  base64Code: z.string().optional().describe("base64编码的代码,一般不采用这种方式"),
54
48
  codeSecret: z.string().optional().describe("代码保护密钥,一般无需配置")
55
49
  }, async ({ func, functionRootPath, force, base64Code, codeSecret }) => {
50
+ const cloudbase = await getCloudBaseManager();
56
51
  const result = await cloudbase.functions.createFunction({
57
52
  func,
58
53
  functionRootPath,
@@ -78,6 +73,7 @@ export function registerFunctionTools(server) {
78
73
  base64Code: z.string().optional().describe("base64编码的代码,这种方式也可以更新代码,不推荐使用"),
79
74
  codeSecret: z.string().optional().describe("代码保护密钥,一般无需配置")
80
75
  }, async ({ func, functionRootPath, base64Code, codeSecret }) => {
76
+ const cloudbase = await getCloudBaseManager();
81
77
  const result = await cloudbase.functions.updateFunctionCode({
82
78
  func,
83
79
  functionRootPath,
@@ -106,6 +102,7 @@ export function registerFunctionTools(server) {
106
102
  runtime: z.string().optional().describe("运行时")
107
103
  }).describe("函数配置")
108
104
  }, async ({ funcParam }) => {
105
+ const cloudbase = await getCloudBaseManager();
109
106
  const result = await cloudbase.functions.updateFunctionConfig(funcParam);
110
107
  return {
111
108
  content: [
@@ -121,6 +118,7 @@ export function registerFunctionTools(server) {
121
118
  name: z.string().describe("函数名称"),
122
119
  codeSecret: z.string().optional().describe("代码保护密钥")
123
120
  }, async ({ name, codeSecret }) => {
121
+ const cloudbase = await getCloudBaseManager();
124
122
  const result = await cloudbase.functions.getFunctionDetail(name, codeSecret);
125
123
  return {
126
124
  content: [
@@ -136,6 +134,7 @@ export function registerFunctionTools(server) {
136
134
  name: z.string().describe("函数名称"),
137
135
  params: z.record(z.any()).optional().describe("调用参数")
138
136
  }, async ({ name, params }) => {
137
+ const cloudbase = await getCloudBaseManager();
139
138
  const result = await cloudbase.functions.invokeFunction(name, params);
140
139
  return {
141
140
  content: [
@@ -159,6 +158,7 @@ export function registerFunctionTools(server) {
159
158
  requestId: z.string().optional().describe("请求ID")
160
159
  }).describe("日志查询选项")
161
160
  }, async ({ options }) => {
161
+ const cloudbase = await getCloudBaseManager();
162
162
  const result = await cloudbase.functions.getFunctionLogs(options);
163
163
  return {
164
164
  content: [
@@ -178,6 +178,7 @@ export function registerFunctionTools(server) {
178
178
  config: z.string().describe("触发器配置")
179
179
  })).describe("触发器配置数组")
180
180
  }, async ({ name, triggers }) => {
181
+ const cloudbase = await getCloudBaseManager();
181
182
  const result = await cloudbase.functions.createFunctionTriggers(name, triggers);
182
183
  return {
183
184
  content: [
@@ -193,6 +194,7 @@ export function registerFunctionTools(server) {
193
194
  name: z.string().describe("函数名"),
194
195
  triggerName: z.string().describe("触发器名称")
195
196
  }, async ({ name, triggerName }) => {
197
+ const cloudbase = await getCloudBaseManager();
196
198
  const result = await cloudbase.functions.deleteFunctionTrigger(name, triggerName);
197
199
  return {
198
200
  content: [
@@ -219,6 +221,7 @@ export function registerFunctionTools(server) {
219
221
  // }).describe("Layer配置")
220
222
  // },
221
223
  // async ({ options }) => {
224
+ // const cloudbase = await getCloudBaseManager()
222
225
  // const result = await cloudbase.functions.createLayer(options);
223
226
  // return {
224
227
  // content: [
@@ -243,6 +246,7 @@ export function registerFunctionTools(server) {
243
246
  // }).optional().describe("查询选项")
244
247
  // },
245
248
  // async ({ options }) => {
249
+ // const cloudbase = await getCloudBaseManager()
246
250
  // const result = await cloudbase.functions.listLayers(options || {});
247
251
  // return {
248
252
  // content: [
@@ -265,6 +269,7 @@ export function registerFunctionTools(server) {
265
269
  // }).describe("查询选项")
266
270
  // },
267
271
  // async ({ options }) => {
272
+ // const cloudbase = await getCloudBaseManager()
268
273
  // const result = await cloudbase.functions.getLayerVersion(options);
269
274
  // return {
270
275
  // content: [
@@ -288,6 +293,7 @@ export function registerFunctionTools(server) {
288
293
  // }).describe("发布选项")
289
294
  // },
290
295
  // async ({ options }) => {
296
+ // const cloudbase = await getCloudBaseManager()
291
297
  // const result = await cloudbase.functions.publishVersion(options);
292
298
  // return {
293
299
  // content: [
@@ -313,6 +319,7 @@ export function registerFunctionTools(server) {
313
319
  // }).describe("查询选项")
314
320
  // },
315
321
  // async ({ options }) => {
322
+ // const cloudbase = await getCloudBaseManager()
316
323
  // const result = await cloudbase.functions.listVersionByFunction(options);
317
324
  // return {
318
325
  // content: [
@@ -346,6 +353,7 @@ export function registerFunctionTools(server) {
346
353
  // }).describe("别名配置")
347
354
  // },
348
355
  // async ({ options }) => {
356
+ // const cloudbase = await getCloudBaseManager()
349
357
  // const result = await cloudbase.functions.updateFunctionAliasConfig(options);
350
358
  // return {
351
359
  // content: [
@@ -368,6 +376,7 @@ export function registerFunctionTools(server) {
368
376
  // }).describe("查询选项")
369
377
  // },
370
378
  // async ({ options }) => {
379
+ // const cloudbase = await getCloudBaseManager()
371
380
  // const result = await cloudbase.functions.getFunctionAlias(options);
372
381
  // return {
373
382
  // content: [
@@ -1,12 +1,5 @@
1
1
  import { z } from "zod";
2
- import CloudBase from "@cloudbase/manager-node";
3
- // 初始化CloudBase
4
- const cloudbase = new CloudBase({
5
- secretId: process.env.TENCENTCLOUD_SECRETID,
6
- secretKey: process.env.TENCENTCLOUD_SECRETKEY,
7
- envId: process.env.CLOUDBASE_ENV_ID,
8
- token: process.env.TENCENTCLOUD_SESSIONTOKEN
9
- });
2
+ import { getCloudBaseManager } from '../cloudbase-manager.js';
10
3
  export function registerHostingTools(server) {
11
4
  // uploadFiles - 上传文件到静态网站托管
12
5
  server.tool("uploadFiles", "上传文件到静态网站托管", {
@@ -18,6 +11,7 @@ export function registerHostingTools(server) {
18
11
  })).default([]).describe("多文件上传配置"),
19
12
  ignore: z.union([z.string(), z.array(z.string())]).optional().describe("忽略文件模式")
20
13
  }, async ({ localPath, cloudPath, files, ignore }) => {
14
+ const cloudbase = await getCloudBaseManager();
21
15
  const result = await cloudbase.hosting.uploadFiles({
22
16
  localPath,
23
17
  cloudPath,
@@ -49,6 +43,7 @@ export function registerHostingTools(server) {
49
43
  });
50
44
  // listFiles - 获取文件列表
51
45
  server.tool("listFiles", "获取静态网站托管的文件列表", {}, async () => {
46
+ const cloudbase = await getCloudBaseManager();
52
47
  const result = await cloudbase.hosting.listFiles();
53
48
  return {
54
49
  content: [
@@ -64,6 +59,7 @@ export function registerHostingTools(server) {
64
59
  cloudPath: z.string().describe("云端文件或文件夹路径"),
65
60
  isDir: z.boolean().default(false).describe("是否为文件夹")
66
61
  }, async ({ cloudPath, isDir }) => {
62
+ const cloudbase = await getCloudBaseManager();
67
63
  const result = await cloudbase.hosting.deleteFiles({
68
64
  cloudPath,
69
65
  isDir
@@ -83,6 +79,7 @@ export function registerHostingTools(server) {
83
79
  marker: z.string().optional().describe("起始对象键标记"),
84
80
  maxKeys: z.number().optional().describe("单次返回最大条目数")
85
81
  }, async ({ prefix, marker, maxKeys }) => {
82
+ const cloudbase = await getCloudBaseManager();
86
83
  const result = await cloudbase.hosting.findFiles({
87
84
  prefix,
88
85
  marker,
@@ -112,6 +109,7 @@ export function registerHostingTools(server) {
112
109
  // })).optional().describe("重定向规则")
113
110
  // },
114
111
  // async ({ indexDocument, errorDocument, routingRules }) => {
112
+ // const cloudbase = await getCloudBaseManager()
115
113
  // const result = await cloudbase.hosting.setWebsiteDocument({
116
114
  // indexDocument,
117
115
  // errorDocument,
@@ -132,6 +130,7 @@ export function registerHostingTools(server) {
132
130
  domain: z.string().describe("自定义域名"),
133
131
  certId: z.string().describe("证书ID")
134
132
  }, async ({ domain, certId }) => {
133
+ const cloudbase = await getCloudBaseManager();
135
134
  const result = await cloudbase.hosting.CreateHostingDomain({
136
135
  domain,
137
136
  certId
@@ -149,6 +148,7 @@ export function registerHostingTools(server) {
149
148
  server.tool("deleteHostingDomain", "解绑自定义域名", {
150
149
  domain: z.string().describe("自定义域名")
151
150
  }, async ({ domain }) => {
151
+ const cloudbase = await getCloudBaseManager();
152
152
  const result = await cloudbase.hosting.deleteHostingDomain({
153
153
  domain
154
154
  });
@@ -163,6 +163,7 @@ export function registerHostingTools(server) {
163
163
  });
164
164
  // getWebsiteConfig - 获取静态网站配置
165
165
  server.tool("getWebsiteConfig", "获取静态网站配置", {}, async () => {
166
+ const cloudbase = await getCloudBaseManager();
166
167
  const result = await cloudbase.hosting.getWebsiteConfig();
167
168
  return {
168
169
  content: [
@@ -177,6 +178,7 @@ export function registerHostingTools(server) {
177
178
  server.tool("tcbCheckResource", "获取域名配置", {
178
179
  domains: z.array(z.string()).describe("域名列表")
179
180
  }, async ({ domains }) => {
181
+ const cloudbase = await getCloudBaseManager();
180
182
  const result = await cloudbase.hosting.tcbCheckResource({
181
183
  domains
182
184
  });
@@ -218,6 +220,7 @@ export function registerHostingTools(server) {
218
220
  }).optional()
219
221
  }).describe("域名配置")
220
222
  }, async ({ domain, domainId, domainConfig }) => {
223
+ const cloudbase = await getCloudBaseManager();
221
224
  const result = await cloudbase.hosting.tcbModifyAttribute({
222
225
  domain,
223
226
  domainId,
@@ -1,18 +1,12 @@
1
1
  import { z } from "zod";
2
- import CloudBase from "@cloudbase/manager-node";
3
- // 初始化CloudBase
4
- const cloudbase = new CloudBase({
5
- secretId: process.env.TENCENTCLOUD_SECRETID,
6
- secretKey: process.env.TENCENTCLOUD_SECRETKEY,
7
- envId: process.env.CLOUDBASE_ENV_ID,
8
- token: process.env.TENCENTCLOUD_SESSIONTOKEN
9
- });
2
+ import { getCloudBaseManager } from '../cloudbase-manager.js';
10
3
  export function registerStorageTools(server) {
11
4
  // uploadFile - 上传文件到云存储
12
5
  server.tool("uploadFile", "上传文件到云存储(区别于静态网站托管,云存储更适合存储业务数据文件)", {
13
6
  localPath: z.string().describe("本地文件路径,建议传入绝对路径,例如 /tmp/files/data.txt"),
14
7
  cloudPath: z.string().describe("云端文件路径,例如 files/data.txt"),
15
8
  }, async ({ localPath, cloudPath }) => {
9
+ const cloudbase = await getCloudBaseManager();
16
10
  // 上传文件
17
11
  await cloudbase.storage.uploadFile({
18
12
  localPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cloudbase-mcp",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "腾讯云开发 MCP Server,支持静态托管/环境查询/",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -21,6 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@cloudbase/manager-node": "^4.2.10",
24
+ "@cloudbase/toolbox": "^0.7.5",
24
25
  "@modelcontextprotocol/sdk": "^1.9.0",
25
26
  "zod": "^3.24.3"
26
27
  },