@cloudbase/cloudbase-mcp 1.5.0 → 1.7.0

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/README.md CHANGED
@@ -22,10 +22,15 @@
22
22
  [![GitHub last commit](https://img.shields.io/github/last-commit/TencentCloudBase/CloudBase-AI-ToolKit)](https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/commits)
23
23
  [![GitHub contributors](https://img.shields.io/github/contributors/TencentCloudBase/CloudBase-AI-ToolKit)](https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/graphs/contributors)
24
24
 
25
+
26
+ [![CNB 镜像](https://img.shields.io/badge/CNB-CloudBase--AI--ToolKit-blue?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAxMiAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHJ4PSIyIiBmaWxsPSIjM0I4MkY2Ii8+PHBhdGggZD0iTTUgM0g3VjVINSIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxLjUiLz48cGF0aCBkPSJNNSA3SDdWOUg1IiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjEuNSIvPjwvc3ZnPg==)](https://cnb.cool/tencent/cloud/cloudbase/CloudBase-AI-ToolKit)
27
+
25
28
  当你在**Cursor/ VSCode GitHub Copilot/WinSurf/CodeBuddy**等AI编程工具里写代码时,它能自动帮你生成可直接部署的前后端应用+小程序,并一键发布到腾讯云开发 CloudBase。
26
29
 
27
30
  <a href="https://www.producthunt.com/posts/cloudbase-ai-tookit?embed=true&utm_source=badge-featured&utm_medium=badge&utm_source=badge-cloudbase&#0045;ai&#0045;tookit" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=971451&theme=light&t=1748519563832" alt="CloudBase&#0032;AI&#0032;Tookit - Prompt&#0032;to&#0032;Production&#0058;&#0032;Full&#0045;stack&#0044;&#0032;DB&#0032;&#0038;&#0032;functions—zero&#0032;setup&#0046; | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
28
31
 
32
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=CloudBase&config=eyJjb21tYW5kIjoibnB4IEBjbG91ZGJhc2UvY2xvdWRiYXNlLW1jcEBsYXRlc3QiLCJlbnYiOnsiQ0xPVURCQVNFX0VOVl9JRCI6IllPVVJfRU5WX0lEIn0sImRpc2FibGVkIjpmYWxzZX0%3D)
33
+
29
34
 
30
35
 
31
36
  ### 🚀 三大核心能力
@@ -51,12 +56,13 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
51
56
  | **📱 全栈应用支持** | Web + 小程序 + 数据库 + 后端一体化 | 支持小程序/web 等多种应用形式,提供后端托管和数据库 |
52
57
  | **🔧 智能修复** | AI 自动查看日志并修复问题 | 降低运维成本 |
53
58
  | **⚡ 极速体验** | 国内 CDN 加速 | 比海外平台访问速度更快 |
59
+ | **📚 智能知识库检索** | 内置支持云开发、微信小程序等专业知识库的智能向量检索 |
54
60
 
55
61
 
56
62
  ## 🚀 快速开始
57
63
 
58
64
 
59
- ### 0.前置条件
65
+ ### 0. 前置条件
60
66
 
61
67
  #### 安装 AI 开发工具
62
68
  例如 [Cursor](https://www.cursor.com/) | [WindSurf](https://windsurf.com/editor) | [CodeBuddy](https://copilot.tencent.com/) 等
@@ -66,29 +72,57 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
66
72
  2. 在控制台「概览」页面右侧获取 **环境ID**
67
73
  (后续部署需要此 ID)
68
74
 
69
- ### 1. 使用模板创建项目
75
+ ### 1. 快速初始化或增强你的项目
76
+
77
+ 我们为你准备了内置云开发最佳实践和 AI IDE 规则的项目模板,推荐如下两种方式:
78
+
79
+ #### 🚀 新项目推荐
80
+
81
+ 选择适合你的模板,一键初始化:
82
+
83
+ - **React Web 应用 + 云开发模板**
84
+ [下载代码包](https://static.cloudbase.net/cloudbase-examples/web-cloudbase-react-template.zip?v=2025053001) | [开源代码地址](https://github.com/TencentCloudBase/awesome-cloudbase-examples/tree/master/web/cloudbase-react-template)
85
+
86
+ - **微信小程序 + 云开发模板**
87
+ [下载代码包](https://static.cloudbase.net/cloudbase-examples/miniprogram-cloudbase-miniprogram-template.zip?v=2025053001) | [开源代码地址](https://github.com/TencentCloudBase/awesome-cloudbase-examples/tree/master/miniprogram/cloudbase-miniprogram-template)
88
+
89
+ - **通用云开发模板**
90
+ [下载代码包](https://static.cloudbase.net/cloudbase-examples/web-cloudbase-project.zip) | [开源代码地址](https://github.com/TencentCloudBase/awesome-cloudbase-examples/tree/master/web/cloudbase-project)
70
91
 
71
- 以下模板已经内置了云开发面向 AI IDE 的规则配置
92
+ #### 🛠️ 已有项目增强
72
93
 
73
- 建议选择适合你的项目模板快速开始:
94
+ 如果你已经有自己的项目,只需在配置好 MCP 后,让 AI 调用 `downloadTemplate` 工具,选择 `rules` 模板,即可一键下载并补全 AI 编辑器规则配置到当前项目目录,无需手动操作。
74
95
 
75
- - React Web应用+云开发模板:[下载代码包](https://static.cloudbase.net/cloudbase-examples/web-cloudbase-react-template.zip?v=2025053001) | [开源代码地址](https://github.com/TencentCloudBase/awesome-cloudbase-examples/tree/master/web/cloudbase-react-template)
76
- - 小程序+云开发模板:[下载代码包](https://static.cloudbase.net/cloudbase-examples/miniprogram-cloudbase-miniprogram-template.zip?v=2025053001) | [开源代码地址](https://github.com/TencentCloudBase/awesome-cloudbase-examples/tree/master/miniprogram/cloudbase-miniprogram-template)
77
96
 
78
97
  ### 2. 配置你的 AI IDE
79
98
 
99
+ > 💡 **使用提示**:如果你在 Cursor 等工具中开启了自动执行(auto-run)模式,建议在"Command denylist"中添加敏感命令,避免自动运行如删除数据等敏感的操作
100
+ >
101
+ > 默认模式下需要手动确认执行,较为安全。
102
+
103
+ #### 环境登录
104
+
105
+ CloudBase AI ToolKit 提供了简单的环境登录管理:
106
+
107
+ - **登录环境**: 使用 `login` 工具登录并选择云开发环境
108
+ - **退出登录**: 使用 `logout` 工具退出当前环境
109
+
110
+ 登录成功后会自动保存环境配置,无需重启服务即可生效。
111
+
80
112
  以下工具均支持 CloudBase AI ToolKit,可根据你的开发环境选择合适的工具:
81
113
 
82
114
  | 工具 | 支持平台 |
83
115
  |------|----------|
84
116
  | [Cursor](https://cursor.com/) | 独立 IDE|
85
117
  | [WindSurf](https://windsurf.com/editor) | 独立 IDE,VSCode、JetBrains 插件 |
86
- | [CodeBuddy](https://copilot.tencent.com/) | VS Code, JetBrains、微信开发者工具插件 |
118
+ | [CodeBuddy](https://copilot.tencent.com/) | VS CodeJetBrains、微信开发者工具插件 |
87
119
  | [CLINE](https://cline.so/) | VS Code 插件 |
88
120
  | [GitHub Copilot](https://github.com/features/copilot) | VS Code 插件 |
89
121
  | [Trae](https://www.trae.ai/) | 独立 IDE |
90
- | [通义灵码](https://tongyi.aliyun.com/lingma) | 独立 IDE,VS Code, JetBrains插件 |
122
+ | [通义灵码](https://tongyi.aliyun.com/lingma) | 独立 IDE,VS Code JetBrains插件 |
91
123
  | [RooCode](https://roocode.com/) | VS Code插件 |
124
+ | [文心快码](https://comate.baidu.com/) | VS Code、JetBrains插件|
125
+
92
126
 
93
127
  选择工具后,请按照下方对应的配置说明进行设置。每个工具都需要配置云开发环境 ID 才能使用 MCP 功能。如果你还没有云开发环境,请先[开通云开发环境](#0前置条件)。
94
128
 
@@ -102,6 +136,10 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
102
136
 
103
137
  #### 步骤2:配置 MCP
104
138
 
139
+ 模板中已经包含 mcp 配置,如果不是从模板开始,可以点击下方按钮安装到 Cursor 中
140
+
141
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=CloudBase&config=eyJjb21tYW5kIjoibnB4IEBjbG91ZGJhc2UvY2xvdWRiYXNlLW1jcEBsYXRlc3QiLCJlbnYiOnsiQ0xPVURCQVNFX0VOVl9JRCI6IllPVVJfRU5WX0lEIn0sImRpc2FibGVkIjpmYWxzZX0%3D)
142
+
105
143
  1. 请修改项目中的 `.cursor/mcp.json` ,填写你的云开发环境 ID
106
144
 
107
145
  ```json
@@ -399,6 +437,46 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
399
437
 
400
438
  </details>
401
439
 
440
+ <details>
441
+ <summary><strong>🤖 文心快码(Baidu Comate) 配置</strong></summary>
442
+
443
+ #### 步骤1:自动应用 AI 规则
444
+
445
+ 模板中已包含 `.comate/rules` 目录,文心快码会自动识别云开发最佳实践
446
+
447
+ #### 步骤2:配置 MCP
448
+
449
+ 模板中已包含 `.comate/mcp.json` 目录,文心快码会自动识别项目中的 MCP
450
+
451
+ **配置云开发 MCP Server**
452
+
453
+ 在文心快码的 Zulu 模式中,选择 MCP 配置-设置,在打开的文件中修改 MCP 配置
454
+
455
+ 其中 CLOUDBASE_ENV_ID 填写你的云开发环境 ID
456
+
457
+ ```json
458
+ {
459
+ "mcpServers": {
460
+ "cloudbase": {
461
+ "command": "npx",
462
+ "args": [
463
+ "@cloudbase/cloudbase-mcp@latest"
464
+ ],
465
+ "env": {
466
+ "CLOUDBASE_ENV_ID": "你的云开发环境ID"
467
+ },
468
+ "disabled": false
469
+ }
470
+ }
471
+ }
472
+ ```
473
+
474
+ #### 步骤3:使用 AI 对话
475
+
476
+ 在对话窗口中切换到 Zulu 模式,然后使用 AI 进行代码生成和自动化操作
477
+
478
+ </details>
479
+
402
480
  ### 3. 开始开发
403
481
 
404
482
  确认 AI 已经连接到云开发
@@ -505,11 +583,58 @@ AI 会自动:
505
583
 
506
584
  ---
507
585
 
586
+ ## 🌟 为什么选择 CloudBase?
587
+
588
+ - **⚡ 极速部署**:国内节点,访问速度比海外更快
589
+ - **🛡️ 稳定可靠**:330 万开发者选择的 Serverless 平台
590
+ - **🔧 开发友好**:专为AI时代设计的全栈平台
591
+ - **💰 成本优化**:Serverless 架构更具弹性,新用户开发期间可以免费体验
592
+
593
+
594
+ ## 📋 常见问题 FAQ
595
+
596
+ 如有迁移、集成等常见疑问,请查阅 [FAQ 常见问题](./FAQ.md)。
597
+
598
+ ## 💬 技术交流群
599
+
600
+ 遇到问题或想要交流经验?加入我们的技术社区!
601
+
602
+ ### 🔥 微信交流群
603
+
604
+ <div align="center">
605
+ <img src="https://7463-tcb-advanced-a656fc-1257967285.tcb.qcloud.la/mcp/toolkit-qrcode.png" width="200" alt="微信群二维码">
606
+ <br>
607
+ <i>扫码加入微信技术交流群</i>
608
+ </div>
609
+
610
+ **群内你可以:**
611
+ - 💡 分享你的 AI + 云开发项目
612
+ - 🤝 技术交流和开发问题沟通
613
+ - 📢 获取最新功能更新和最佳实践
614
+ - 🎯 参与产品功能讨论和建议
615
+
616
+ ### 📱 其他交流方式
617
+
618
+ | 平台 | 链接 | 说明 |
619
+ |------|------|------|
620
+ | **官方文档** | [📖 查看文档](https://docs.cloudbase.net/) | 完整的云开发文档 |
621
+ | **Issue 反馈** | [🐛 提交问题](https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/issues) | Bug 反馈和功能请求 |
622
+
623
+ ### 🎉 社区活动
624
+
625
+ - **每周技术分享**:群内定期分享 AI + 云开发最佳实践
626
+ - **项目展示**:展示你用 AI 开发的精彩项目
627
+ - **问题答疑**:腾讯云开发团队成员在线答疑
628
+ - **新功能预览**:第一时间体验最新功能
629
+
630
+
508
631
  ## 🛠️ 云开发 MCP 工具一览
509
632
 
510
633
  | 工具名称 | 功能简介 |
511
634
  |----------|----------|
635
+ | login | 登录并选择云开发环境 |
512
636
  | logout | 登出当前云开发账户 |
637
+ | downloadTemplate | 下载CloudBase项目模板(React、小程序、AI编辑器配置等) |
513
638
  | listEnvs | 获取所有云开发环境信息 |
514
639
  | getEnvAuthDomains | 获取云开发环境的合法域名列表 |
515
640
  | createEnvDomain | 为云开发环境添加安全域名 |
@@ -566,45 +691,6 @@ graph TD
566
691
  J --> K[Web/小程序/API]
567
692
  ```
568
693
 
569
- ## 🌟 为什么选择 CloudBase?
570
-
571
- - **⚡ 极速部署**:国内节点,访问速度比海外更快
572
- - **🛡️ 稳定可靠**:330 万开发者选择的 Serverless 平台
573
- - **🔧 开发友好**:专为AI时代设计的全栈平台
574
- - **💰 成本优化**:Serverless 架构更具弹性,新用户开发期间可以免费体验
575
-
576
- ## 💬 技术交流群
577
-
578
- 遇到问题或想要交流经验?加入我们的技术社区!
579
-
580
- ### 🔥 微信交流群
581
-
582
- <div align="center">
583
- <img src="https://7463-tcb-advanced-a656fc-1257967285.tcb.qcloud.la/mcp/toolkit-qrcode.png" width="200" alt="微信群二维码">
584
- <br>
585
- <i>扫码加入微信技术交流群</i>
586
- </div>
587
-
588
- **群内你可以:**
589
- - 💡 分享你的 AI + 云开发项目
590
- - 🤝 技术交流和开发问题沟通
591
- - 📢 获取最新功能更新和最佳实践
592
- - 🎯 参与产品功能讨论和建议
593
-
594
- ### 📱 其他交流方式
595
-
596
- | 平台 | 链接 | 说明 |
597
- |------|------|------|
598
- | **官方文档** | [📖 查看文档](https://docs.cloudbase.net/) | 完整的云开发文档 |
599
- | **Issue 反馈** | [🐛 提交问题](https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/issues) | Bug 反馈和功能请求 |
600
-
601
- ### 🎉 社区活动
602
-
603
- - **每周技术分享**:群内定期分享 AI + 云开发最佳实践
604
- - **项目展示**:展示你用 AI 开发的精彩项目
605
- - **问题答疑**:腾讯云开发团队成员在线答疑
606
- - **新功能预览**:第一时间体验最新功能
607
-
608
694
  ## 🤝 贡献指南
609
695
 
610
696
  欢迎提交 Issue 和 Pull Request!请查看我们的[贡献指南](CONTRIBUTING.md)了解如何参与项目开发。
@@ -617,6 +703,3 @@ graph TD
617
703
 
618
704
  ⭐ 如果这个项目对你有帮助,请给我们一个 Star!
619
705
 
620
- ## 📋 [常见问题 FAQ](./FAQ.md)
621
-
622
- 如有迁移、集成等常见疑问,请查阅 [FAQ 常见问题](./FAQ.md)。
package/dist/auth.js CHANGED
@@ -1,12 +1,16 @@
1
1
  import { AuthSupevisor } from '@cloudbase/toolbox';
2
+ import { debug } from './utils/logger.js';
2
3
  const auth = AuthSupevisor.getInstance({});
3
4
  export async function getLoginState() {
4
5
  const { TENCENTCLOUD_SECRETID, TENCENTCLOUD_SECRETKEY, TENCENTCLOUD_SESSIONTOKEN } = process.env;
6
+ debug('TENCENTCLOUD_SECRETID', TENCENTCLOUD_SECRETID);
5
7
  if (TENCENTCLOUD_SECRETID && TENCENTCLOUD_SECRETKEY) {
8
+ debug('loginByApiSecret');
6
9
  await auth.loginByApiSecret(TENCENTCLOUD_SECRETID, TENCENTCLOUD_SECRETKEY, TENCENTCLOUD_SESSIONTOKEN);
7
10
  }
8
11
  const loginState = await auth.getLoginState();
9
12
  if (!loginState) {
13
+ debug('loginByApiSecret');
10
14
  await auth.loginByWebAuth({});
11
15
  const loginState = await auth.getLoginState();
12
16
  return loginState;
@@ -1,13 +1,84 @@
1
- import CloudBase from "@cloudbase/manager-node";
2
1
  import { getLoginState } from './auth.js';
3
- export async function getCloudBaseManager() {
4
- const loginState = await getLoginState();
5
- const { envId, secretId, secretKey, token } = loginState;
6
- const cloudbase = new CloudBase({
7
- envId: process.env.CLOUDBASE_ENV_ID || envId,
8
- secretId,
9
- secretKey,
10
- token
2
+ import { ensureEnvId, autoSetupEnvironmentId } from './tools/interactive.js';
3
+ import CloudBase from "@cloudbase/manager-node";
4
+ import { debug, error } from './utils/logger.js';
5
+ let initializationPromise = null;
6
+ let noEnvIdInitializationPromise = null;
7
+ const INITIALIZATION_TIMEOUT = 30000; // 30 seconds
8
+ export function getCloudBaseManager(options = {}) {
9
+ const { requireEnvId = true } = options;
10
+ if (requireEnvId) {
11
+ if (initializationPromise) {
12
+ return initializationPromise;
13
+ }
14
+ const executor = async () => {
15
+ try {
16
+ // 检查并确保环境ID已配置
17
+ let userEnvId = await ensureEnvId();
18
+ if (!userEnvId) {
19
+ debug("未找到环境ID,尝试自动设置...");
20
+ userEnvId = await autoSetupEnvironmentId();
21
+ if (!userEnvId) {
22
+ throw new Error("CloudBase Environment ID not found after auto setup. Please set CLOUDBASE_ENV_ID or run setupEnvironmentId tool.");
23
+ }
24
+ }
25
+ const loginState = await getLoginState();
26
+ const { envId, secretId, secretKey, token } = loginState;
27
+ const manager = new CloudBase({
28
+ secretId,
29
+ secretKey,
30
+ envId: userEnvId,
31
+ token,
32
+ proxy: process.env.http_proxy
33
+ });
34
+ return manager;
35
+ }
36
+ catch (err) {
37
+ error('Failed to initialize CloudBase Manager:', err);
38
+ throw err;
39
+ }
40
+ };
41
+ const timeoutPromise = new Promise((_, reject) => {
42
+ const id = setTimeout(() => {
43
+ clearTimeout(id);
44
+ reject(new Error(`CloudBase Manager initialization timed out after ${INITIALIZATION_TIMEOUT / 1000} seconds.`));
45
+ }, INITIALIZATION_TIMEOUT);
46
+ });
47
+ initializationPromise = Promise.race([executor(), timeoutPromise]);
48
+ initializationPromise.catch(() => {
49
+ initializationPromise = null;
50
+ });
51
+ return initializationPromise;
52
+ }
53
+ if (noEnvIdInitializationPromise) {
54
+ return noEnvIdInitializationPromise;
55
+ }
56
+ const noEnvIdExecutor = async () => {
57
+ try {
58
+ const loginState = await getLoginState();
59
+ const { secretId, secretKey, token } = loginState;
60
+ const manager = new CloudBase({
61
+ secretId,
62
+ secretKey,
63
+ token,
64
+ proxy: process.env.http_proxy
65
+ });
66
+ return manager;
67
+ }
68
+ catch (err) {
69
+ error('Failed to initialize CloudBase Manager (no envId):', err instanceof Error ? err.message : String(err));
70
+ throw err;
71
+ }
72
+ };
73
+ const timeoutPromise = new Promise((_, reject) => {
74
+ const id = setTimeout(() => {
75
+ clearTimeout(id);
76
+ reject(new Error(`CloudBase Manager (no envId) initialization timed out after ${INITIALIZATION_TIMEOUT / 1000} seconds.`));
77
+ }, INITIALIZATION_TIMEOUT);
78
+ });
79
+ noEnvIdInitializationPromise = Promise.race([noEnvIdExecutor(), timeoutPromise]);
80
+ noEnvIdInitializationPromise.catch(() => {
81
+ noEnvIdInitializationPromise = null;
11
82
  });
12
- return cloudbase;
83
+ return noEnvIdInitializationPromise;
13
84
  }
package/dist/index.js CHANGED
@@ -8,6 +8,8 @@ import { registerHostingTools } from "./tools/hosting.js";
8
8
  import { registerDownloadTools } from "./tools/download.js";
9
9
  import { registerStorageTools } from "./tools/storage.js";
10
10
  import { registerRagTools } from './tools/rag.js';
11
+ import { registerSetupTools } from "./tools/setup.js";
12
+ import { registerInteractiveTools } from "./tools/interactive.js";
11
13
  // Create server instance
12
14
  const server = new McpServer({
13
15
  name: "cloudbase-mcp",
@@ -33,10 +35,14 @@ registerFunctionTools(server);
33
35
  registerDownloadTools(server);
34
36
  // Register storage tools
35
37
  registerStorageTools(server);
38
+ // Register setup tools
39
+ registerSetupTools(server);
40
+ // Register interactive tools
41
+ registerInteractiveTools(server);
36
42
  async function main() {
37
43
  const transport = new StdioServerTransport();
38
44
  await server.connect(transport);
39
- console.error("TencentCloudBase MCP Server running on stdio");
45
+ console.log("TencentCloudBase MCP Server running on stdio");
40
46
  }
41
47
  main().catch((error) => {
42
48
  console.error("Fatal error in main():", error);