@cloudbase/cloudbase-mcp 1.7.7 → 1.7.9
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 +77 -35
- package/dist/cloudbase-manager.js +5 -1
- package/dist/index.js +66 -2
- package/dist/interactive-server.js +1 -1
- package/dist/tools/database.js +599 -1
- package/dist/tools/env.js +2 -2
- package/dist/tools/functions.js +8 -8
- package/dist/tools/rag.js +0 -1
- package/dist/utils/logger.js +6 -6
- package/dist/utils/telemetry.js +287 -0
- package/dist/utils/tool-wrapper.js +89 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
[](https://opensource.org/licenses/MIT)
|
|
15
|
-
[](https://
|
|
16
|
-

|
|
15
|
+
[](https://www.npmjs.com/package/@cloudbase/cloudbase-mcp)
|
|
16
|
+
[](https://www.npmjs.com/package/@cloudbase/cloudbase-mcp)
|
|
17
17
|
[](https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/stargazers)
|
|
18
18
|
[](https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/network/members)
|
|
19
19
|
|
|
@@ -21,42 +21,32 @@
|
|
|
21
21
|
[](https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/pulls)
|
|
22
22
|
[](https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/commits)
|
|
23
23
|
[](https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/graphs/contributors)
|
|
24
|
-
|
|
25
|
-
|
|
26
24
|
[](https://cnb.cool/tencent/cloud/cloudbase/CloudBase-AI-ToolKit)
|
|
27
25
|
|
|
28
26
|
当你在**Cursor/ VSCode GitHub Copilot/WinSurf/CodeBuddy/Augment Code**等AI编程工具里写代码时,它能自动帮你生成可直接部署的前后端应用+小程序,并一键发布到腾讯云开发 CloudBase。
|
|
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-ai-tookit" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=971451&theme=light&t=1748519563832" alt="CloudBase AI Tookit - Prompt to Production: Full-stack, DB & functions—zero setup. | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
|
31
|
-
|
|
32
|
-
[](https://cursor.com/install-mcp?name=CloudBase&config=eyJjb21tYW5kIjoibnB4IEBjbG91ZGJhc2UvY2xvdWRiYXNlLW1jcEBsYXRlc3QiLCJlbnYiOnsiQ0xPVURCQVNFX0VOVl9JRCI6IllPVVJfRU5WX0lEIn0sImRpc2FibGVkIjpmYWxzZX0%3D)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### 🚀 三大核心能力
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
### 🛠️ 支持平台
|
|
29
|
+
**📹 完整视频演示 ⬇️**
|
|
40
30
|
|
|
41
|
-
|
|
31
|
+
<a href="https://www.bilibili.com/video/BV1hpjvzGESg/" target="_blank">
|
|
32
|
+
<img style="max-width: 600px; height: auto;" src="https://7463-tcb-advanced-a656fc-1257967285.tcb.qcloud.la/mcp/video-banner.png" alt="视频演示" />
|
|
33
|
+
</a>
|
|
42
34
|
|
|
35
|
+
| 🚀 **核心能力** | 🛠️ **支持平台** |
|
|
36
|
+
|---|---|
|
|
37
|
+
| 🤖 **AI智能开发**: AI自动生成代码和架构设计<br>☁️ **云开发集成**: 一键接入数据库、云函数、静态托管<br>⚡ **快速部署**: 几分钟内完成全栈应用上线 | **Web应用**: 现代化前端 + 静态托管<br>**微信小程序**: 云开发小程序解决方案<br>**后端服务**: 云数据库 + 无服务器函数+云托管 |
|
|
43
38
|
|
|
44
39
|
|
|
45
|
-
**完整视频演示**
|
|
46
|
-
|
|
47
|
-
https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
|
|
48
40
|
</div>
|
|
49
41
|
|
|
50
42
|
## ✨ 核心特性
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
| **⚡ 极速体验** | 国内 CDN 加速 | 比海外平台访问速度更快 |
|
|
59
|
-
| **📚 知识检索** | 内置支持云开发、微信小程序等专业知识 |专业知识库的智能向量检索
|
|
44
|
+
- **🤖 AI 原生** - 专为 AI 编程工具设计的规则库,生成代码符合云开发最佳实践
|
|
45
|
+
- **🚀 一键部署** - MCP 自动化部署到腾讯云开发 CloudBase 平台,Serverless 架构无需购买服务器
|
|
46
|
+
- **📱 全栈应用** - Web + 小程序 + 数据库 + 后端一体化,支持多种应用形式和后端托管
|
|
47
|
+
- **🔧 智能修复** - AI 自动查看日志并修复问题,降低运维成本
|
|
48
|
+
- **⚡ 极速体验** - 国内 CDN 加速,比海外平台访问速度更快
|
|
49
|
+
- **📚 知识检索** - 内置云开发、微信小程序等专业知识库的智能向量检索
|
|
60
50
|
|
|
61
51
|
|
|
62
52
|
## 🚀 快速开始
|
|
@@ -64,12 +54,49 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
|
|
|
64
54
|
|
|
65
55
|
### 0. 前置条件
|
|
66
56
|
|
|
67
|
-
|
|
57
|
+
<details>
|
|
58
|
+
<summary>安装 AI 开发工具</summary>
|
|
59
|
+
|
|
68
60
|
例如 [Cursor](https://www.cursor.com/) | [WindSurf](https://windsurf.com/editor) | [CodeBuddy](https://copilot.tencent.com/) 等,点击查看 [支持的 AI 开发工具列表](#2-配置你的-ai-ide)
|
|
69
61
|
|
|
70
|
-
|
|
62
|
+
</details>
|
|
63
|
+
|
|
64
|
+
<details>
|
|
65
|
+
<summary>开通云开发环境</summary>
|
|
66
|
+
|
|
71
67
|
访问 [腾讯云开发控制台](https://tcb.cloud.tencent.com/dev)开通环境,新用户可以免费开通体验。
|
|
72
68
|
|
|
69
|
+
</details>
|
|
70
|
+
|
|
71
|
+
<details>
|
|
72
|
+
<summary>安装 Node.js v18及以上版本</summary>
|
|
73
|
+
|
|
74
|
+
确保您的计算机上安装了 Node.js v18 及以上版本。您可以从 [Node.js 官网](https://nodejs.org/) 下载并安装最新版本。
|
|
75
|
+
|
|
76
|
+
</details>
|
|
77
|
+
|
|
78
|
+
<details>
|
|
79
|
+
<summary>可选:设置 npm 源</summary>
|
|
80
|
+
|
|
81
|
+
为了提高依赖包的下载速度,建议将 npm 源设置为腾讯镜像源。您可以在**终端命令行**中运行以下命令:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm config set registry https://mirrors.cloud.tencent.com/npm/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
这样可以加快依赖包的下载速度,特别是在中国大陆地区。
|
|
88
|
+
</details>
|
|
89
|
+
|
|
90
|
+
<details>
|
|
91
|
+
<summary>可选:清理 npx 缓存</summary>
|
|
92
|
+
由于 npx 这个工具本身存在一个缓存的 bug,可能导致 CloudBase AI ToolKit 安装问题,您可以尝试清理 npx 缓存。
|
|
93
|
+
|
|
94
|
+
在**终端命令行**中运行以下命令:
|
|
95
|
+
```
|
|
96
|
+
npx -y clear-npx-cache
|
|
97
|
+
```
|
|
98
|
+
</details>
|
|
99
|
+
|
|
73
100
|
### 1. 快速初始化或增强你的项目
|
|
74
101
|
|
|
75
102
|
我们为你准备了内置云开发最佳实践和 AI IDE 规则的项目模板,推荐如下两种方式:
|
|
@@ -78,11 +105,14 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
|
|
|
78
105
|
|
|
79
106
|
选择适合你的模板,一键初始化:
|
|
80
107
|
|
|
108
|
+
- **微信小程序 + 云开发模板**
|
|
109
|
+
[下载代码包](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)
|
|
110
|
+
|
|
81
111
|
- **React Web 应用 + 云开发模板**
|
|
82
112
|
[下载代码包](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)
|
|
83
113
|
|
|
84
|
-
-
|
|
85
|
-
[下载代码包](https://static.cloudbase.net/cloudbase-examples/
|
|
114
|
+
- **Vue Web 应用 + 云开发模板**
|
|
115
|
+
[下载代码包](https://static.cloudbase.net/cloudbase-examples/web-cloudbase-vue-template.zip?v=2025053001) | [开源代码地址](https://github.com/TencentCloudBase/awesome-cloudbase-examples/tree/master/web/cloudbase-vue-template)
|
|
86
116
|
|
|
87
117
|
- **AI 规则通用云开发模板** :不限定语言和框架,内置 CloudBase AI 规则和MCP,适用于任意云开发项目
|
|
88
118
|
|
|
@@ -95,6 +125,9 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
|
|
|
95
125
|
|
|
96
126
|
### 2. 配置你的 AI IDE
|
|
97
127
|
|
|
128
|
+
> [!TIP]
|
|
129
|
+
> 温馨提示:如果你使用的是模板项目,所有配置都已经预置完成,请按照指引进行检查和开启工具。如果不是从模板开始,需要按具体的说明手动添加相应配置:
|
|
130
|
+
|
|
98
131
|
以下工具均支持 CloudBase AI ToolKit,选择合适的工具并按说明配置:
|
|
99
132
|
|
|
100
133
|
| 工具 | 支持平台 |
|
|
@@ -110,7 +143,6 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
|
|
|
110
143
|
| [文心快码](https://comate.baidu.com/) | VS Code、JetBrains插件|
|
|
111
144
|
| [Augment Code](https://www.augmentcode.com/) | VS Code、JetBrains 插件 |
|
|
112
145
|
|
|
113
|
-
如果你使用的是模板项目,所有配置都已经预置完成,请按照指引进行检查和开启工具。如果不是从模板开始,需要按具体的说明手动添加相应配置:
|
|
114
146
|
|
|
115
147
|
<details>
|
|
116
148
|
<summary><strong>🔧 Cursor 配置</strong></summary>
|
|
@@ -123,7 +155,7 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
|
|
|
123
155
|
|
|
124
156
|
如果使用模板项目,MCP 配置已经预置完成。如果不是从模板开始,可以点击下方按钮安装到 Cursor 中:
|
|
125
157
|
|
|
126
|
-
[](https://cursor.com/install-mcp?name=CloudBase&config=
|
|
158
|
+
[](https://cursor.com/install-mcp?name=CloudBase&config=eyJjb21tYW5kIjoibnB4IEBjbG91ZGJhc2UvY2xvdWRiYXNlLW1jcEBsYXRlc3QiLCJkaXNhYmxlZCI6ZmFsc2V9)
|
|
127
159
|
|
|
128
160
|
或手动添加配置到 `.cursor/mcp.json`:
|
|
129
161
|
|
|
@@ -183,12 +215,12 @@ https://github.com/user-attachments/assets/2b402fa6-c5c4-495a-b85b-f5d4a25daa4a
|
|
|
183
215
|
|
|
184
216
|
#### 步骤2:配置 MCP
|
|
185
217
|
|
|
186
|
-
|
|
218
|
+
点开 CodeBuddy 右上角的 MCP 按钮,点击右侧的添加,在 MCP 配置中添加云开发的 MCP
|
|
187
219
|
|
|
188
220
|
```json
|
|
189
221
|
{
|
|
190
222
|
"mcpServers": {
|
|
191
|
-
"cloudbase
|
|
223
|
+
"cloudbase": {
|
|
192
224
|
"command": "npx",
|
|
193
225
|
"args": ["-y", "@cloudbase/cloudbase-mcp@latest"]
|
|
194
226
|
}
|
|
@@ -580,7 +612,7 @@ AI 会自动:
|
|
|
580
612
|
|
|
581
613
|
## 📋 常见问题 FAQ
|
|
582
614
|
|
|
583
|
-
如有迁移、集成等常见疑问,请查阅 [FAQ 常见问题](
|
|
615
|
+
如有迁移、集成等常见疑问,请查阅 [FAQ 常见问题](https://docs.cloudbase.net/ai/cloudbase-ai-toolkit/faq)。
|
|
584
616
|
|
|
585
617
|
## 💬 技术交流群
|
|
586
618
|
|
|
@@ -639,6 +671,7 @@ AI 会自动:
|
|
|
639
671
|
| queryDocuments | 查询集合中的文档 |
|
|
640
672
|
| updateDocuments | 更新集合中的文档 |
|
|
641
673
|
| deleteDocuments | 删除集合中的文档 |
|
|
674
|
+
| manageDataModel | 数据模型查询工具,支持查询和列表数据模型(只读操作)。list操作返回基础信息,get操作返回详细信息含Schema(字段列表、格式、关联关系等),docs操作生成SDK使用文档 |
|
|
642
675
|
| uploadFiles | 上传文件到静态网站托管 |
|
|
643
676
|
| listFiles | 获取静态网站托管的文件列表 |
|
|
644
677
|
| deleteFiles | 删除静态网站托管的文件或文件夹 |
|
|
@@ -656,7 +689,7 @@ AI 会自动:
|
|
|
656
689
|
| deleteFunctionTrigger | 删除云函数触发器 |
|
|
657
690
|
| downloadRemoteFile | 下载远程文件到本地临时文件 |
|
|
658
691
|
| uploadFile | 上传文件到云存储(适合存储业务数据文件) |
|
|
659
|
-
| searchKnowledgeBase |
|
|
692
|
+
| searchKnowledgeBase | 智能检索云开发知识库(支持云开发与云函数以及小程序知识),通过向量搜索快速获取专业文档与答案。|
|
|
660
693
|
| interactiveDialog | 统一的交互式对话工具,支持需求澄清和任务确认 |
|
|
661
694
|
|
|
662
695
|
## 🏗️ 架构原理
|
|
@@ -676,6 +709,15 @@ graph TD
|
|
|
676
709
|
J --> K[Web/小程序/API]
|
|
677
710
|
```
|
|
678
711
|
|
|
712
|
+
## 🔒 数据统计说明
|
|
713
|
+
|
|
714
|
+
为了改进产品体验,CloudBase AI ToolKit 会收集匿名使用统计信息:
|
|
715
|
+
|
|
716
|
+
- **收集内容**:工具调用情况、基础环境信息(操作系统、Node.js版本等)
|
|
717
|
+
- **隐私保护**:不收集代码内容、文件路径等敏感信息,仅用于产品改进
|
|
718
|
+
|
|
719
|
+
可通过环境变量 `CLOUDBASE_MCP_TELEMETRY_DISABLED` 设置为 `true` 禁用数据统计
|
|
720
|
+
|
|
679
721
|
## 🤝 贡献指南
|
|
680
722
|
|
|
681
723
|
欢迎提交 Issue 和 Pull Request!请查看我们的[贡献指南](CONTRIBUTING.md)了解如何参与项目开发。
|
|
@@ -2,7 +2,7 @@ import { getLoginState } from './auth.js';
|
|
|
2
2
|
import { loadEnvIdFromUserConfig, saveEnvIdToUserConfig, autoSetupEnvironmentId } from './tools/interactive.js';
|
|
3
3
|
import CloudBase from "@cloudbase/manager-node";
|
|
4
4
|
import { debug, error } from './utils/logger.js';
|
|
5
|
-
const ENV_ID_TIMEOUT =
|
|
5
|
+
const ENV_ID_TIMEOUT = 300000; // 300 seconds
|
|
6
6
|
// 统一的环境ID管理类
|
|
7
7
|
class EnvironmentManager {
|
|
8
8
|
cachedEnvId = null;
|
|
@@ -87,6 +87,10 @@ class EnvironmentManager {
|
|
|
87
87
|
}
|
|
88
88
|
// 全局实例
|
|
89
89
|
const envManager = new EnvironmentManager();
|
|
90
|
+
// 导出环境ID获取函数
|
|
91
|
+
export async function getEnvId() {
|
|
92
|
+
return envManager.getEnvId();
|
|
93
|
+
}
|
|
90
94
|
// 导出函数保持兼容性
|
|
91
95
|
export function resetCloudBaseManagerCache() {
|
|
92
96
|
envManager.reset();
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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";
|
|
5
6
|
import { registerFunctionTools } from "./tools/functions.js";
|
|
6
7
|
import { registerDatabaseTools } from "./tools/database.js";
|
|
7
8
|
import { registerHostingTools } from "./tools/hosting.js";
|
|
@@ -10,6 +11,11 @@ import { registerStorageTools } from "./tools/storage.js";
|
|
|
10
11
|
import { registerRagTools } from './tools/rag.js';
|
|
11
12
|
import { registerSetupTools } from "./tools/setup.js";
|
|
12
13
|
import { registerInteractiveTools } from "./tools/interactive.js";
|
|
14
|
+
import { wrapServerWithTelemetry } from "./utils/tool-wrapper.js";
|
|
15
|
+
import { telemetryReporter, reportToolkitLifecycle } from "./utils/telemetry.js";
|
|
16
|
+
import { info } from "./utils/logger.js";
|
|
17
|
+
// 记录启动时间
|
|
18
|
+
const startTime = Date.now();
|
|
13
19
|
// Create server instance
|
|
14
20
|
const server = new McpServer({
|
|
15
21
|
name: "cloudbase-mcp",
|
|
@@ -19,6 +25,8 @@ const server = new McpServer({
|
|
|
19
25
|
tools: {},
|
|
20
26
|
},
|
|
21
27
|
});
|
|
28
|
+
// 启用数据上报功能(包装工具调用)
|
|
29
|
+
wrapServerWithTelemetry(server);
|
|
22
30
|
// Register environment management tools
|
|
23
31
|
registerEnvTools(server);
|
|
24
32
|
// Register RAG tools
|
|
@@ -42,9 +50,65 @@ registerInteractiveTools(server);
|
|
|
42
50
|
async function main() {
|
|
43
51
|
const transport = new StdioServerTransport();
|
|
44
52
|
await server.connect(transport);
|
|
45
|
-
|
|
53
|
+
info("TencentCloudBase MCP Server running on stdio");
|
|
54
|
+
// 上报启动信息
|
|
55
|
+
if (telemetryReporter.isEnabled()) {
|
|
56
|
+
await reportToolkitLifecycle({
|
|
57
|
+
event: 'start'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
46
60
|
}
|
|
47
|
-
|
|
61
|
+
// 设置进程退出处理
|
|
62
|
+
function setupExitHandlers() {
|
|
63
|
+
const handleExit = async (exitCode, signal) => {
|
|
64
|
+
if (telemetryReporter.isEnabled()) {
|
|
65
|
+
const duration = Date.now() - startTime;
|
|
66
|
+
await reportToolkitLifecycle({
|
|
67
|
+
event: 'exit',
|
|
68
|
+
duration,
|
|
69
|
+
exitCode,
|
|
70
|
+
error: signal ? `Process terminated by signal: ${signal}` : undefined
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
// 正常退出
|
|
75
|
+
process.on('exit', (code) => {
|
|
76
|
+
// 注意:exit 事件中不能使用异步操作,所以这里只能同步处理
|
|
77
|
+
// 异步上报在其他信号处理中完成
|
|
78
|
+
});
|
|
79
|
+
// 异常退出处理
|
|
80
|
+
process.on('SIGINT', async () => {
|
|
81
|
+
await handleExit(0, 'SIGINT');
|
|
82
|
+
process.exit(0);
|
|
83
|
+
});
|
|
84
|
+
process.on('SIGTERM', async () => {
|
|
85
|
+
await handleExit(0, 'SIGTERM');
|
|
86
|
+
process.exit(0);
|
|
87
|
+
});
|
|
88
|
+
process.on('uncaughtException', async (error) => {
|
|
89
|
+
console.error('Uncaught Exception:', error);
|
|
90
|
+
await handleExit(1, `uncaughtException: ${error.message}`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
process.on('unhandledRejection', async (reason) => {
|
|
94
|
+
console.error('Unhandled Rejection:', reason);
|
|
95
|
+
await handleExit(1, `unhandledRejection: ${String(reason)}`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
// 设置退出处理器
|
|
100
|
+
setupExitHandlers();
|
|
101
|
+
main().catch(async (error) => {
|
|
48
102
|
console.error("Fatal error in main():", error);
|
|
103
|
+
// 上报启动失败
|
|
104
|
+
if (telemetryReporter.isEnabled()) {
|
|
105
|
+
const duration = Date.now() - startTime;
|
|
106
|
+
await reportToolkitLifecycle({
|
|
107
|
+
event: 'exit',
|
|
108
|
+
duration,
|
|
109
|
+
exitCode: 1,
|
|
110
|
+
error: `Startup failed: ${error.message}`
|
|
111
|
+
});
|
|
112
|
+
}
|
|
49
113
|
process.exit(1);
|
|
50
114
|
});
|