@cloudbase/cloudbase-mcp 2.0.0 → 2.0.1
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/cli.cjs +390 -12
- package/dist/index.cjs +390 -12
- package/dist/index.js +389 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2471,12 +2471,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
2471
2471
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2472
2472
|
};
|
|
2473
2473
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2474
|
+
exports.downloadWebTemplate = downloadWebTemplate;
|
|
2475
|
+
exports.getClaudePrompt = getClaudePrompt;
|
|
2474
2476
|
exports.registerRagTools = registerRagTools;
|
|
2475
|
-
const
|
|
2477
|
+
const adm_zip_1 = __importDefault(__webpack_require__(872));
|
|
2478
|
+
const fs = __importStar(__webpack_require__(932));
|
|
2476
2479
|
const os = __importStar(__webpack_require__(116));
|
|
2477
2480
|
const path = __importStar(__webpack_require__(521));
|
|
2478
|
-
const
|
|
2479
|
-
const
|
|
2481
|
+
const zod_1 = __webpack_require__(971);
|
|
2482
|
+
const claude_prompt_js_1 = __webpack_require__(359);
|
|
2480
2483
|
const logger_js_1 = __webpack_require__(39);
|
|
2481
2484
|
// 1. 枚举定义
|
|
2482
2485
|
const KnowledgeBaseEnum = zod_1.z.enum(["cloudbase", "scf", "miniprogram"]);
|
|
@@ -2512,26 +2515,71 @@ function safeStringify(obj) {
|
|
|
2512
2515
|
return "";
|
|
2513
2516
|
}
|
|
2514
2517
|
}
|
|
2515
|
-
|
|
2518
|
+
// Download and extract web template, return extract directory path
|
|
2519
|
+
// Implements caching: only downloads if extractDir doesn't exist
|
|
2520
|
+
async function downloadWebTemplate() {
|
|
2516
2521
|
const baseDir = path.join(os.homedir(), ".cloudbase-mcp");
|
|
2517
2522
|
const zipPath = path.join(baseDir, "web-cloudbase-project.zip");
|
|
2518
2523
|
const extractDir = path.join(baseDir, "web-template");
|
|
2519
2524
|
const url = "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-project.zip";
|
|
2520
2525
|
await fs.mkdir(baseDir, { recursive: true });
|
|
2521
|
-
//
|
|
2526
|
+
// Check if extractDir already exists (cache hit)
|
|
2527
|
+
try {
|
|
2528
|
+
const stats = await fs.stat(extractDir);
|
|
2529
|
+
if (stats.isDirectory()) {
|
|
2530
|
+
// Directory exists, return it directly (use cache)
|
|
2531
|
+
return extractDir;
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
catch (error) {
|
|
2535
|
+
// Directory doesn't exist, proceed with download
|
|
2536
|
+
}
|
|
2537
|
+
// Download zip to specified path (overwrite)
|
|
2522
2538
|
const response = await fetch(url);
|
|
2523
2539
|
if (!response.ok) {
|
|
2524
2540
|
throw new Error(`下载模板失败,状态码: ${response.status}`);
|
|
2525
2541
|
}
|
|
2526
2542
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
2527
2543
|
await fs.writeFile(zipPath, buffer);
|
|
2528
|
-
//
|
|
2544
|
+
// Clean and recreate extract directory
|
|
2529
2545
|
await fs.rm(extractDir, { recursive: true, force: true });
|
|
2530
2546
|
await fs.mkdir(extractDir, { recursive: true });
|
|
2531
2547
|
const zip = new adm_zip_1.default(zipPath);
|
|
2532
2548
|
zip.extractAllTo(extractDir, true);
|
|
2549
|
+
return extractDir;
|
|
2550
|
+
}
|
|
2551
|
+
async function prepareKnowledgeBaseWebTemplate() {
|
|
2552
|
+
const extractDir = await downloadWebTemplate();
|
|
2533
2553
|
return collectSkillDescriptions(path.join(extractDir, ".claude", "skills"));
|
|
2534
2554
|
}
|
|
2555
|
+
// Get CLAUDE.md prompt content
|
|
2556
|
+
// Priority: 1. From downloaded template, 2. Fallback to embedded constant
|
|
2557
|
+
async function getClaudePrompt() {
|
|
2558
|
+
try {
|
|
2559
|
+
// Try to get from downloaded template
|
|
2560
|
+
const extractDir = await downloadWebTemplate();
|
|
2561
|
+
const claudePath = path.join(extractDir, "CLAUDE.md");
|
|
2562
|
+
try {
|
|
2563
|
+
const content = await fs.readFile(claudePath, "utf8");
|
|
2564
|
+
return content;
|
|
2565
|
+
}
|
|
2566
|
+
catch (error) {
|
|
2567
|
+
// CLAUDE.md not found in template, use fallback
|
|
2568
|
+
(0, logger_js_1.warn)("[getClaudePrompt] CLAUDE.md not found in template, using fallback", {
|
|
2569
|
+
error,
|
|
2570
|
+
path: claudePath,
|
|
2571
|
+
});
|
|
2572
|
+
return claude_prompt_js_1.FALLBACK_CLAUDE_PROMPT;
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
catch (error) {
|
|
2576
|
+
// Template download failed, use fallback
|
|
2577
|
+
(0, logger_js_1.warn)("[getClaudePrompt] Template download failed, using fallback", {
|
|
2578
|
+
error,
|
|
2579
|
+
});
|
|
2580
|
+
return claude_prompt_js_1.FALLBACK_CLAUDE_PROMPT;
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2535
2583
|
async function registerRagTools(server) {
|
|
2536
2584
|
// 联网搜索
|
|
2537
2585
|
server.registerTool?.("searchWeb", {
|
|
@@ -2809,6 +2857,7 @@ const auth_js_1 = __webpack_require__(291);
|
|
|
2809
2857
|
const cloudbase_manager_js_1 = __webpack_require__(431);
|
|
2810
2858
|
const logger_js_1 = __webpack_require__(39);
|
|
2811
2859
|
const interactive_js_1 = __webpack_require__(461);
|
|
2860
|
+
const rag_js_1 = __webpack_require__(215);
|
|
2812
2861
|
function registerEnvTools(server) {
|
|
2813
2862
|
// 获取 cloudBaseOptions,如果没有则为 undefined
|
|
2814
2863
|
const cloudBaseOptions = server.cloudBaseOptions;
|
|
@@ -2816,7 +2865,7 @@ function registerEnvTools(server) {
|
|
|
2816
2865
|
// login - 登录云开发环境
|
|
2817
2866
|
server.registerTool?.("login", {
|
|
2818
2867
|
title: "登录云开发",
|
|
2819
|
-
description: "
|
|
2868
|
+
description: "登录云开发环境,在生成包含云开发 CloudBase 相关功能前**必须**先调用此工具进行登录。登录云开发环境并选择要使用的环境。",
|
|
2820
2869
|
inputSchema: {
|
|
2821
2870
|
forceUpdate: zod_1.z.boolean().optional().describe("是否强制重新选择环境")
|
|
2822
2871
|
},
|
|
@@ -2838,10 +2887,23 @@ function registerEnvTools(server) {
|
|
|
2838
2887
|
return { content: [{ type: "text", text: "用户取消了登录" }] };
|
|
2839
2888
|
}
|
|
2840
2889
|
if (selectedEnvId) {
|
|
2890
|
+
// Get CLAUDE.md prompt content
|
|
2891
|
+
let promptContent = "";
|
|
2892
|
+
try {
|
|
2893
|
+
promptContent = await (0, rag_js_1.getClaudePrompt)();
|
|
2894
|
+
}
|
|
2895
|
+
catch (promptError) {
|
|
2896
|
+
(0, logger_js_1.debug)("Failed to get CLAUDE prompt", { error: promptError });
|
|
2897
|
+
// Continue with login success even if prompt fetch fails
|
|
2898
|
+
}
|
|
2899
|
+
const successMessage = `✅ 登录成功,当前环境: ${selectedEnvId}`;
|
|
2900
|
+
const promptMessage = promptContent
|
|
2901
|
+
? `\n\n⚠️ 重要提示:后续所有云开发相关的开发工作必须严格遵循以下开发规范和最佳实践:\n\n${promptContent}`
|
|
2902
|
+
: "";
|
|
2841
2903
|
return {
|
|
2842
2904
|
content: [{
|
|
2843
2905
|
type: "text",
|
|
2844
|
-
text:
|
|
2906
|
+
text: successMessage + promptMessage
|
|
2845
2907
|
}]
|
|
2846
2908
|
};
|
|
2847
2909
|
}
|
|
@@ -2963,10 +3025,24 @@ function registerEnvTools(server) {
|
|
|
2963
3025
|
default:
|
|
2964
3026
|
throw new Error(`不支持的查询类型: ${action}`);
|
|
2965
3027
|
}
|
|
3028
|
+
let responseText = JSON.stringify(result, null, 2);
|
|
3029
|
+
// For info action, append CLAUDE.md prompt content
|
|
3030
|
+
if (action === "info") {
|
|
3031
|
+
try {
|
|
3032
|
+
const promptContent = await (0, rag_js_1.getClaudePrompt)();
|
|
3033
|
+
if (promptContent) {
|
|
3034
|
+
responseText += `\n\n⚠️ 重要提示:后续所有云开发相关的开发工作必须严格遵循以下开发规范和最佳实践:\n\n${promptContent}`;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
catch (promptError) {
|
|
3038
|
+
(0, logger_js_1.debug)("Failed to get CLAUDE prompt in envQuery", { error: promptError });
|
|
3039
|
+
// Continue without prompt if fetch fails
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
2966
3042
|
return {
|
|
2967
3043
|
content: [{
|
|
2968
3044
|
type: "text",
|
|
2969
|
-
text:
|
|
3045
|
+
text: responseText
|
|
2970
3046
|
}]
|
|
2971
3047
|
};
|
|
2972
3048
|
}
|
|
@@ -5596,6 +5672,305 @@ async function getInteractiveServerSafe(mcpServer) {
|
|
|
5596
5672
|
|
|
5597
5673
|
module.exports = __WEBPACK_EXTERNAL_MODULE_net__;
|
|
5598
5674
|
|
|
5675
|
+
/***/ }),
|
|
5676
|
+
|
|
5677
|
+
/***/ 359:
|
|
5678
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
5679
|
+
|
|
5680
|
+
|
|
5681
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5682
|
+
exports.FALLBACK_CLAUDE_PROMPT = void 0;
|
|
5683
|
+
// Fallback CLAUDE.md prompt content
|
|
5684
|
+
// This is used when template download fails or CLAUDE.md is not found in the template
|
|
5685
|
+
exports.FALLBACK_CLAUDE_PROMPT = `---
|
|
5686
|
+
description: CloudBase AI Development Rules Guide - Provides scenario-based best practices to ensure development quality
|
|
5687
|
+
globs: *
|
|
5688
|
+
alwaysApply: true
|
|
5689
|
+
---
|
|
5690
|
+
|
|
5691
|
+
# CloudBase AI Development Rules Guide
|
|
5692
|
+
|
|
5693
|
+
## Quick Reference for AI
|
|
5694
|
+
|
|
5695
|
+
**⚠️ CRITICAL: Read this section first based on your project type**
|
|
5696
|
+
|
|
5697
|
+
### When Developing a Web Project:
|
|
5698
|
+
1. **Environment Check**: Call \`envQuery\` tool first (applies to all interactions)
|
|
5699
|
+
2. **⚠️ Template Download (MANDATORY for New Projects)**: **MUST call \`downloadTemplate\` tool FIRST when starting a new project** - Do NOT create files manually. Use \`downloadTemplate\` with \`template="react"\` or \`template="vue"\` to get the complete project structure. Only proceed with manual file creation if template download fails or user explicitly requests it.
|
|
5700
|
+
3. **⚠️ UI Design (CRITICAL)**: **MUST read \`rules/ui-design/rule.md\` FIRST before generating any page, interface, component, or style** - This is NOT optional. You MUST explicitly read this file and output the design specification before writing any UI code.
|
|
5701
|
+
4. **Core Capabilities**: Read Core Capabilities section below (especially UI Design and Database + Authentication for Web)
|
|
5702
|
+
5. **Platform Rules**: Read \`rules/web-development/rule.md\` for platform-specific rules (SDK integration, static hosting, build configuration)
|
|
5703
|
+
6. **Authentication**: Read \`rules/auth-web/rule.md\` - **MUST use Web SDK built-in authentication**
|
|
5704
|
+
7. **Database**:
|
|
5705
|
+
- NoSQL: \`rules/no-sql-web-sdk/rule.md\`
|
|
5706
|
+
- MySQL: \`rules/relational-database-web/rule.md\` + \`rules/relational-database-mcp/rule.md\`
|
|
5707
|
+
|
|
5708
|
+
### When Developing a Mini Program Project:
|
|
5709
|
+
1. **Environment Check**: Call \`envQuery\` tool first (applies to all interactions)
|
|
5710
|
+
2. **⚠️ Template Download (MANDATORY for New Projects)**: **MUST call \`downloadTemplate\` tool FIRST when starting a new project** - Do NOT create files manually. Use \`downloadTemplate\` with \`template="miniprogram"\` to get the complete project structure. Only proceed with manual file creation if template download fails or user explicitly requests it.
|
|
5711
|
+
3. **⚠️ UI Design (CRITICAL)**: **MUST read \`rules/ui-design/rule.md\` FIRST before generating any page, interface, component, or style** - This is NOT optional. You MUST explicitly read this file and output the design specification before writing any UI code.
|
|
5712
|
+
4. **Core Capabilities**: Read Core Capabilities section below (especially UI Design and Database + Authentication for Mini Program)
|
|
5713
|
+
5. **Platform Rules**: Read \`rules/miniprogram-development/rule.md\` for platform-specific rules (project structure, WeChat Developer Tools, wx.cloud usage)
|
|
5714
|
+
6. **Authentication**: Read \`rules/auth-wechat/rule.md\` - **Naturally login-free, get OPENID in cloud functions**
|
|
5715
|
+
7. **Database**:
|
|
5716
|
+
- NoSQL: \`rules/no-sql-wx-mp-sdk/rule.md\`
|
|
5717
|
+
- MySQL: \`rules/relational-database-mcp/rule.md\` (via MCP tools)
|
|
5718
|
+
|
|
5719
|
+
---
|
|
5720
|
+
|
|
5721
|
+
## Core Capabilities (Must Be Done Well)
|
|
5722
|
+
|
|
5723
|
+
As the most important part of application development, the following four core capabilities must be done well, without needing to read different rules for different platforms:
|
|
5724
|
+
|
|
5725
|
+
### 1. ⚠️ UI Design (CRITICAL - Highest Priority)
|
|
5726
|
+
**⚠️ MANDATORY: Must strictly follow \`rules/ui-design/rule.md\` rules for ALL design work**
|
|
5727
|
+
|
|
5728
|
+
**🚨 CRITICAL ENFORCEMENT: You MUST explicitly read the file \`rules/ui-design/rule.md\` before generating ANY UI code. This is NOT a suggestion - it is a MANDATORY requirement.**
|
|
5729
|
+
|
|
5730
|
+
**Before generating ANY page, interface, component, or style:**
|
|
5731
|
+
1. **MUST FIRST explicitly read \`rules/ui-design/rule.md\` file** - Use file reading tools to read this file, do NOT skip this step
|
|
5732
|
+
2. **MUST complete design specification output** before writing any code:
|
|
5733
|
+
- Purpose Statement
|
|
5734
|
+
- Aesthetic Direction (choose from specific options, NOT generic terms)
|
|
5735
|
+
- Color Palette (with hex codes, avoid forbidden colors)
|
|
5736
|
+
- Typography (specific font names, avoid forbidden fonts)
|
|
5737
|
+
- Layout Strategy (asymmetric/creative approach, avoid centered templates)
|
|
5738
|
+
3. **MUST ensure** generated interfaces have distinctive aesthetic styles and high-quality visual design
|
|
5739
|
+
4. **MUST avoid** generic AI aesthetics (common fonts, clichéd color schemes, templated designs)
|
|
5740
|
+
|
|
5741
|
+
**This applies to ALL tasks involving:**
|
|
5742
|
+
- Page generation
|
|
5743
|
+
- Interface creation
|
|
5744
|
+
- Component design
|
|
5745
|
+
- Style/visual effects
|
|
5746
|
+
- Any frontend visual elements
|
|
5747
|
+
|
|
5748
|
+
**⚠️ VIOLATION DETECTION: If you find yourself writing UI code without first reading \`rules/ui-design/rule.md\`, STOP immediately and read the file first.**
|
|
5749
|
+
|
|
5750
|
+
### 2. Database + Authentication
|
|
5751
|
+
**Strengthen database and authentication capabilities**
|
|
5752
|
+
|
|
5753
|
+
**Authentication**:
|
|
5754
|
+
- **Web Projects**:
|
|
5755
|
+
- Must use CloudBase Web SDK built-in authentication, refer to \`rules/auth-web/rule.md\`
|
|
5756
|
+
- Platform development rules: Refer to \`rules/web-development/rule.md\` for Web SDK integration, static hosting deployment, and build configuration
|
|
5757
|
+
- **Mini Program Projects**:
|
|
5758
|
+
- Naturally login-free, get \`wxContext.OPENID\` in cloud functions, refer to \`rules/auth-wechat/rule.md\`
|
|
5759
|
+
- Platform development rules: Refer to \`rules/miniprogram-development/rule.md\` for mini program project structure, WeChat Developer Tools integration, and CloudBase capabilities
|
|
5760
|
+
- **Node.js Backend**: Refer to \`rules/auth-nodejs/rule.md\`
|
|
5761
|
+
|
|
5762
|
+
**Database Operations**:
|
|
5763
|
+
- **Web Projects**:
|
|
5764
|
+
- NoSQL Database: Refer to \`rules/no-sql-web-sdk/rule.md\`
|
|
5765
|
+
- MySQL Relational Database: Refer to \`rules/relational-database-web/rule.md\` (Web application development) and \`rules/relational-database-mcp/rule.md\` (Management via MCP tools)
|
|
5766
|
+
- Platform development rules: Refer to \`rules/web-development/rule.md\` for Web SDK database integration patterns
|
|
5767
|
+
- **Mini Program Projects**:
|
|
5768
|
+
- NoSQL Database: Refer to \`rules/no-sql-wx-mp-sdk/rule.md\`
|
|
5769
|
+
- MySQL Relational Database: Refer to \`rules/relational-database-mcp/rule.md\` (via MCP tools)
|
|
5770
|
+
- Platform development rules: Refer to \`rules/miniprogram-development/rule.md\` for mini program database integration and wx.cloud usage
|
|
5771
|
+
- **Data Model Creation** (Universal): Refer to \`rules/data-model-creation/rule.md\`
|
|
5772
|
+
|
|
5773
|
+
### 3. Static Hosting Deployment (Web)
|
|
5774
|
+
**Refer to deployment process in \`rules/web-development/rule.md\`**
|
|
5775
|
+
- Use CloudBase static hosting after build completion
|
|
5776
|
+
- Deploy using \`uploadFiles\` tool
|
|
5777
|
+
- Remind users that CDN has a few minutes of cache after deployment
|
|
5778
|
+
- Generate markdown format access links with random queryString
|
|
5779
|
+
|
|
5780
|
+
### 4. Backend Deployment (Cloud Functions or CloudRun)
|
|
5781
|
+
**Refer to \`rules/cloudrun-development/rule.md\`**
|
|
5782
|
+
- **Cloud Function Deployment**: Use \`getFunctionList\` to query, then call \`createFunction\` or \`updateFunctionCode\` to deploy
|
|
5783
|
+
- **CloudRun Deployment**: Use \`manageCloudRun\` tool for containerized deployment
|
|
5784
|
+
- Ensure backend code supports CORS, prepare Dockerfile (for container type)
|
|
5785
|
+
|
|
5786
|
+
## Development Process Standards
|
|
5787
|
+
|
|
5788
|
+
**Important: To ensure development quality, AI must complete the following steps before starting work:**
|
|
5789
|
+
|
|
5790
|
+
### 0. Environment Check (First Step)
|
|
5791
|
+
After user inputs any content, first check CloudBase environment status:
|
|
5792
|
+
- Ensure current CloudBase environment ID is known
|
|
5793
|
+
- If not present in conversation history, must call \`envQuery\` tool with parameter \`action=info\` to query current environment information and environment ID
|
|
5794
|
+
- **Important**: When environment ID configuration is involved in code later, automatically use the queried environment ID, no need for manual user input
|
|
5795
|
+
|
|
5796
|
+
### 1. Scenario Identification
|
|
5797
|
+
Identify current development scenario type, mainly for understanding project type, but core capabilities apply to all projects:
|
|
5798
|
+
- **Web Projects**: React/Vue/native JS frontend projects
|
|
5799
|
+
- **WeChat Mini Programs**: Mini program CloudBase projects
|
|
5800
|
+
- **CloudRun Projects**: CloudBase Run backend service projects (supports any language: Java/Go/Python/Node.js/PHP/.NET, etc.)
|
|
5801
|
+
- **Database Related**: Projects involving data operations
|
|
5802
|
+
- **UI Design/Interface Generation**: Projects requiring interface design, page generation, prototype creation, component design, etc.
|
|
5803
|
+
|
|
5804
|
+
### 2. Platform-Specific Quick Guide
|
|
5805
|
+
|
|
5806
|
+
**Web Projects - Required Rule Files:**
|
|
5807
|
+
- \`rules/web-development/rule.md\` - Platform development rules (SDK integration, static hosting, build configuration)
|
|
5808
|
+
- \`rules/auth-web/rule.md\` - Authentication (MUST use Web SDK built-in authentication)
|
|
5809
|
+
- \`rules/no-sql-web-sdk/rule.md\` - NoSQL database operations
|
|
5810
|
+
- \`rules/relational-database-web/rule.md\` - MySQL database operations (Web)
|
|
5811
|
+
- \`rules/relational-database-mcp/rule.md\` - MySQL database management (MCP tools)
|
|
5812
|
+
- \`rules/cloudbase-platform/rule.md\` - Universal CloudBase platform knowledge
|
|
5813
|
+
|
|
5814
|
+
**Mini Program Projects - Required Rule Files:**
|
|
5815
|
+
- \`rules/miniprogram-development/rule.md\` - Platform development rules (project structure, WeChat Developer Tools, wx.cloud)
|
|
5816
|
+
- \`rules/auth-wechat/rule.md\` - Authentication (naturally login-free, get OPENID in cloud functions)
|
|
5817
|
+
- \`rules/no-sql-wx-mp-sdk/rule.md\` - NoSQL database operations
|
|
5818
|
+
- \`rules/relational-database-mcp/rule.md\` - MySQL database operations (via MCP tools)
|
|
5819
|
+
- \`rules/cloudbase-platform/rule.md\` - Universal CloudBase platform knowledge
|
|
5820
|
+
|
|
5821
|
+
**Universal Rule Files (All Projects):**
|
|
5822
|
+
- **⚠️ \`rules/ui-design/rule.md\`** - **MANDATORY - HIGHEST PRIORITY** - Must read FIRST before any UI/page/component/style generation
|
|
5823
|
+
- \`rules/data-model-creation/rule.md\` - Data model creation and MySQL modeling
|
|
5824
|
+
- \`rules/spec-workflow/rule.md\` - Standard software engineering process (if needed)
|
|
5825
|
+
|
|
5826
|
+
### 3. Development Confirmation
|
|
5827
|
+
Before starting work, suggest confirming with user:
|
|
5828
|
+
1. "I identify this as a [scenario type] project"
|
|
5829
|
+
2. "I will strictly follow core capability requirements and refer to relevant rule files"
|
|
5830
|
+
3. "Please confirm if my understanding is correct"
|
|
5831
|
+
|
|
5832
|
+
## Core Behavior Rules
|
|
5833
|
+
1. **Tool Priority**: For Tencent CloudBase operations, must prioritize using CloudBase MCP tools
|
|
5834
|
+
2. **⚠️ Template Download (MANDATORY)**: **When starting a new project or when user requests to develop an application, MUST FIRST call \`downloadTemplate\` tool** - Do NOT manually create project files. Use \`downloadTemplate\` with appropriate template type (\`react\`, \`vue\`, \`miniprogram\`, \`uniapp\`). Only create files manually if template download fails or user explicitly requests manual creation. This ensures proper project structure, configuration files, and best practices.
|
|
5835
|
+
3. **Project Understanding**: First read current project's README.md, follow project instructions for development
|
|
5836
|
+
4. **Directory Standards**: Before outputting project code in current directory, first check current directory files
|
|
5837
|
+
5. **Development Order**: When developing, prioritize frontend first, then backend, ensuring frontend interface and interaction logic are completed first, then implement backend business logic
|
|
5838
|
+
6. **⚠️ UI Design Rules Mandatory Application**: When tasks involve generating pages, interfaces, components, styles, or any frontend visual elements, **MUST FIRST explicitly read the file \`rules/ui-design/rule.md\` using file reading tools**, then strictly follow the rule file, ensuring generated interfaces have distinctive aesthetic styles and high-quality visual design, avoiding generic AI aesthetics. **You MUST output the design specification before writing any UI code.**
|
|
5839
|
+
7. **Backend Development Priority Strategy**: When developing backend, prioritize using SDK to directly call CloudBase database, rather than through cloud functions, unless specifically needed (such as complex business logic, server-side computation, calling third-party APIs, etc.)
|
|
5840
|
+
8. **Deployment Order**: When there are backend dependencies, prioritize deploying backend before previewing frontend
|
|
5841
|
+
9. **Interactive Confirmation**: Use interactiveDialog to clarify when requirements are unclear, must confirm before executing high-risk operations
|
|
5842
|
+
10. **Real-time Communication**: Use CloudBase real-time database watch capability
|
|
5843
|
+
11. **⚠️ Authentication Rules**: When users develop projects, if user login authentication is needed, must use built-in authentication functions, must strictly distinguish authentication methods by platform
|
|
5844
|
+
- **Web Projects**: **MUST use CloudBase Web SDK built-in authentication** (e.g., \`auth.toDefaultLoginPage()\`), refer to \`rules/auth-web/rule.md\`
|
|
5845
|
+
- **Mini Program Projects**: **Naturally login-free**, get \`wxContext.OPENID\` in cloud functions, refer to \`rules/auth-wechat/rule.md\`
|
|
5846
|
+
|
|
5847
|
+
## Development Workflow
|
|
5848
|
+
|
|
5849
|
+
### Development
|
|
5850
|
+
|
|
5851
|
+
1. **⚠️ Download CloudBase Templates (MANDATORY for New Projects)**:
|
|
5852
|
+
- **MUST call \`downloadTemplate\` tool FIRST when starting a new project** - Do NOT manually create project files
|
|
5853
|
+
- For Web projects: Use \`downloadTemplate\` with \`template="react"\` or \`template="vue"\`
|
|
5854
|
+
- For Mini Program projects: Use \`downloadTemplate\` with \`template="miniprogram"\`
|
|
5855
|
+
- For UniApp projects: Use \`downloadTemplate\` with \`template="uniapp"\`
|
|
5856
|
+
- **Only proceed with manual file creation if template download fails or user explicitly requests manual creation**
|
|
5857
|
+
- If unable to download to current directory, can use scripts to copy, note that hidden files also need to be copied
|
|
5858
|
+
|
|
5859
|
+
2. **⚠️ UI Design Document Reading (MANDATORY)**:
|
|
5860
|
+
- **Before generating ANY page, interface, component, or style, MUST FIRST explicitly read the file \`rules/ui-design/rule.md\` using file reading tools**
|
|
5861
|
+
- **MUST output the design specification** (Purpose Statement, Aesthetic Direction, Color Palette, Typography, Layout Strategy) before writing any UI code
|
|
5862
|
+
- This is NOT optional - you MUST read the file and follow the design thinking framework and frontend aesthetics guidelines
|
|
5863
|
+
- Avoid generating generic AI aesthetic style interfaces
|
|
5864
|
+
|
|
5865
|
+
3. **Mini Program TabBar Material Download - Download Remote Material Links**: Mini program Tabbar and other material images must use **png** format, must use downloadRemoteFile tool to download files locally. Can select from Unsplash, wikimedia (generally choose 500 size), Pexels, Apple official UI and other resources
|
|
5866
|
+
|
|
5867
|
+
If remote links are needed in the application, can continue to call uploadFile to upload and obtain temporary access links and cloud storage cloudId
|
|
5868
|
+
|
|
5869
|
+
3. **Query Professional Knowledge from Knowledge Base**: If uncertain about any CloudBase knowledge, can use searchKnowledgeBase tool to intelligently search CloudBase knowledge base (supports CloudBase and cloud functions, mini program frontend knowledge, etc.), quickly obtain professional documents and answers through vector search
|
|
5870
|
+
|
|
5871
|
+
4. **WeChat Developer Tools Open Project Workflow**:
|
|
5872
|
+
- When detecting current project is a mini program project, suggest user to use WeChat Developer Tools for preview, debugging, and publishing
|
|
5873
|
+
- Before opening, confirm project.config.json has appid field configured. If not configured, must ask user to provide it
|
|
5874
|
+
- Use WeChat Developer built-in CLI command to open project (pointing to directory containing project.config.json):
|
|
5875
|
+
- Windows: \`"C:\\Program Files (x86)\\Tencent\\微信web开发者工具\\cli.bat" open --project "项目根目录路径"\`
|
|
5876
|
+
- macOS: \`/Applications/wechatwebdevtools.app/Contents/MacOS/cli open --project "/path/to/project/root"\`
|
|
5877
|
+
- Project root directory path is the directory containing project.config.json file
|
|
5878
|
+
|
|
5879
|
+
### Deployment Process
|
|
5880
|
+
|
|
5881
|
+
1. **Cloud Function Deployment Process**: Can use getFunctionList MCP tool to query if there are cloud functions, then directly call createFunction or updateFunctionCode to update cloud function code. Only need to point functionRootPath to parent directory of cloud function directory (e.g., absolute path of cloudfunctions directory). No need for code compression and other operations. The above tools will automatically read files from cloud function subdirectories with same name under parent directory and automatically deploy
|
|
5882
|
+
|
|
5883
|
+
2. **CloudRun Deployment Process**: For non-cloud function backend services (Java, Go, PHP, Python, Node.js, etc.), use manageCloudRun tool for deployment. Ensure backend code supports CORS, prepare Dockerfile, then call manageCloudRun for containerized deployment. For details, refer to \`rules/cloudrun-development/rule.md\`
|
|
5884
|
+
|
|
5885
|
+
3. **Static Hosting Deployment Process**: Deploy using uploadFiles tool. After deployment, remind users that CDN has a few minutes of cache. Can generate markdown format access links with random queryString. For details, refer to \`rules/web-development/rule.md\`
|
|
5886
|
+
|
|
5887
|
+
### Documentation Generation Rules
|
|
5888
|
+
|
|
5889
|
+
1. You will generate a README.md file after generating the project, containing basic project information, such as project name, project description. Most importantly, clearly explain the project architecture and involved CloudBase resources, so maintainers can refer to it for modification and maintenance
|
|
5890
|
+
2. After deployment, if it's a web project, can write the official deployment access address in the documentation
|
|
5891
|
+
|
|
5892
|
+
### Configuration File Rules
|
|
5893
|
+
|
|
5894
|
+
1. To help others who don't use AI understand what resources are available, can generate a cloudbaserc.json file after generation
|
|
5895
|
+
|
|
5896
|
+
### MCP Interface Call Rules
|
|
5897
|
+
When calling MCP services, you need to fully understand the data types of all interfaces to be called, as well as return value types. If you're not sure which interface to call, first check the documentation and tool descriptions, then determine which interface and parameters to call based on the documentation and tool descriptions. Do not have incorrect method parameters or parameter type errors.
|
|
5898
|
+
|
|
5899
|
+
For example, many interfaces require a confirm parameter, which is a boolean type. If you don't provide this parameter, or provide incorrect data type, the interface will return an error.
|
|
5900
|
+
|
|
5901
|
+
### Environment ID Auto-Configuration Rules
|
|
5902
|
+
- When generating project configuration files (such as \`cloudbaserc.json\`, \`project.config.json\`, etc.), automatically use the environment ID queried by \`envQuery\`
|
|
5903
|
+
- In code examples involving environment ID, automatically fill in current environment ID, no need for manual user replacement
|
|
5904
|
+
- In deployment and preview related operations, prioritize using already queried environment information
|
|
5905
|
+
|
|
5906
|
+
## Professional Rule File Reference
|
|
5907
|
+
|
|
5908
|
+
**Note**: For detailed information, refer to the specific skill files. This section provides quick reference only.
|
|
5909
|
+
|
|
5910
|
+
### Platform Development Skills
|
|
5911
|
+
- **Web**: \`rules/web-development/rule.md\` - SDK integration, static hosting, build configuration
|
|
5912
|
+
- **Mini Program**: \`rules/miniprogram-development/rule.md\` - Project structure, WeChat Developer Tools, wx.cloud
|
|
5913
|
+
- **CloudRun**: \`rules/cloudrun-development/rule.md\` - Backend deployment (functions/containers)
|
|
5914
|
+
- **Platform (Universal)**: \`rules/cloudbase-platform/rule.md\` - Environment, authentication, services
|
|
5915
|
+
|
|
5916
|
+
### Authentication Skills
|
|
5917
|
+
- **Web**: \`rules/auth-web/rule.md\` - **MUST use Web SDK built-in authentication**
|
|
5918
|
+
- **Mini Program**: \`rules/auth-wechat/rule.md\` - **Naturally login-free, get OPENID in cloud functions**
|
|
5919
|
+
- **Node.js**: \`rules/auth-nodejs/rule.md\`
|
|
5920
|
+
- **HTTP API**: \`rules/auth-http-api/rule.md\`
|
|
5921
|
+
|
|
5922
|
+
### Database Skills
|
|
5923
|
+
- **NoSQL (Web)**: \`rules/no-sql-web-sdk/rule.md\`
|
|
5924
|
+
- **NoSQL (Mini Program)**: \`rules/no-sql-wx-mp-sdk/rule.md\`
|
|
5925
|
+
- **MySQL (Web)**: \`rules/relational-database-web/rule.md\`
|
|
5926
|
+
- **MySQL (MCP)**: \`rules/relational-database-mcp/rule.md\`
|
|
5927
|
+
- **Data Model Creation**: \`rules/data-model-creation/rule.md\`
|
|
5928
|
+
|
|
5929
|
+
### 🎨 ⚠️ UI Design Skill (CRITICAL - Read FIRST)
|
|
5930
|
+
- **\`rules/ui-design/rule.md\`** - **MANDATORY - HIGHEST PRIORITY**
|
|
5931
|
+
- **MUST read FIRST before generating ANY interface/page/component/style**
|
|
5932
|
+
- Design thinking framework, complete design process, frontend aesthetics guidelines
|
|
5933
|
+
- **NO EXCEPTIONS**: All UI work requires reading this file first
|
|
5934
|
+
|
|
5935
|
+
### Workflow Skills
|
|
5936
|
+
- **Spec Workflow**: \`rules/spec-workflow/rule.md\` - Standard software engineering process (requirements, design, tasks)
|
|
5937
|
+
|
|
5938
|
+
## Development Quality Checklist
|
|
5939
|
+
|
|
5940
|
+
To ensure development quality, recommend completing the following checks before starting tasks:
|
|
5941
|
+
|
|
5942
|
+
### Recommended Steps
|
|
5943
|
+
0. **[ ] Environment Check**: Call \`envQuery\` tool to check CloudBase environment status (applies to all interactions)
|
|
5944
|
+
1. **[ ] Template Download Check (MANDATORY for New Projects)**: If starting a new project, have you called \`downloadTemplate\` tool FIRST? Do NOT manually create project files - use templates.
|
|
5945
|
+
2. **[ ] Scenario Identification**: Clearly identify what type of project this is (Web/Mini Program/Database/UI)
|
|
5946
|
+
3. **[ ] Core Capability Confirmation**: Confirm all four core capabilities have been considered
|
|
5947
|
+
- UI Design: Have you explicitly read the file \`rules/ui-design/rule.md\` using file reading tools?
|
|
5948
|
+
- Database + Authentication: Have you referred to corresponding authentication and database skills?
|
|
5949
|
+
- Static Hosting Deployment: Have you understood the deployment process?
|
|
5950
|
+
- Backend Deployment: Have you understood cloud function or CloudRun deployment process?
|
|
5951
|
+
4. **[ ] UI Design Rules Check (MANDATORY)**: If task involves generating pages, interfaces, components, or styles:
|
|
5952
|
+
- Have you explicitly read the file \`rules/ui-design/rule.md\` using file reading tools? (Required: YES)
|
|
5953
|
+
- Have you output the design specification before writing code? (Required: YES)
|
|
5954
|
+
- Have you understood and will follow the design thinking framework? (Required: YES)
|
|
5955
|
+
5. **[ ] User Confirmation**: Confirm with user whether scenario identification and core capability understanding are correct
|
|
5956
|
+
6. **[ ] Rule Execution**: Strictly follow core capability requirements and relevant rule files for development
|
|
5957
|
+
|
|
5958
|
+
### ⚠️ Common Issues to Avoid
|
|
5959
|
+
- **❌ DO NOT manually create project files** - Always use \`downloadTemplate\` tool first for new projects
|
|
5960
|
+
- **❌ DO NOT skip reading UI design document** - Must explicitly read \`rules/ui-design/rule.md\` file before generating any UI code
|
|
5961
|
+
- Avoid skipping core capabilities and starting development directly
|
|
5962
|
+
- Avoid mixing APIs and authentication methods from different platforms
|
|
5963
|
+
- Avoid ignoring UI design rules: All tasks involving interfaces, pages, components, styles must explicitly read and strictly follow \`rules/ui-design/rule.md\`
|
|
5964
|
+
- Avoid ignoring database and authentication standards: Must use correct authentication methods and database operation methods
|
|
5965
|
+
- Important technical solutions should be confirmed with users
|
|
5966
|
+
|
|
5967
|
+
### Quality Assurance
|
|
5968
|
+
If development is found to not comply with standards, can:
|
|
5969
|
+
- Point out specific issues
|
|
5970
|
+
- Require re-execution of rule check process
|
|
5971
|
+
- Clearly specify rule files that need to be followed`;
|
|
5972
|
+
|
|
5973
|
+
|
|
5599
5974
|
/***/ }),
|
|
5600
5975
|
|
|
5601
5976
|
/***/ 363:
|
|
@@ -5652,7 +6027,7 @@ ${envIdSection}
|
|
|
5652
6027
|
## 环境信息
|
|
5653
6028
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
5654
6029
|
- Node.js版本: ${process.version}
|
|
5655
|
-
- MCP 版本:${process.env.npm_package_version || "2.0.
|
|
6030
|
+
- MCP 版本:${process.env.npm_package_version || "2.0.1" || 0}
|
|
5656
6031
|
- 系统架构: ${os_1.default.arch()}
|
|
5657
6032
|
- 时间: ${new Date().toISOString()}
|
|
5658
6033
|
- 请求ID: ${requestId}
|
|
@@ -6839,7 +7214,9 @@ function registerSetupTools(server) {
|
|
|
6839
7214
|
// downloadTemplate - 下载项目模板 (cloud-incompatible)
|
|
6840
7215
|
server.registerTool("downloadTemplate", {
|
|
6841
7216
|
title: "下载项目模板",
|
|
6842
|
-
description: `自动下载并部署CloudBase
|
|
7217
|
+
description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
|
|
7218
|
+
|
|
7219
|
+
**CRITICAL**: This tool MUST be called FIRST when starting a new project.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置(默认)\n- cursor: Cursor AI编辑器\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.0.1" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
6843
7220
|
inputSchema: {
|
|
6844
7221
|
template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
|
|
6845
7222
|
ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
|
|
@@ -7878,7 +8255,7 @@ class TelemetryReporter {
|
|
|
7878
8255
|
const nodeVersion = process.version; // Node.js版本
|
|
7879
8256
|
const arch = os_1.default.arch(); // 系统架构
|
|
7880
8257
|
// 从构建时注入的版本号获取MCP版本信息
|
|
7881
|
-
const mcpVersion = process.env.npm_package_version || "2.0.
|
|
8258
|
+
const mcpVersion = process.env.npm_package_version || "2.0.1" || 0;
|
|
7882
8259
|
return {
|
|
7883
8260
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
7884
8261
|
deviceId: this.deviceId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cloudbase-mcp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "腾讯云开发 MCP Server,通过AI提示词和MCP协议+云开发,让开发更智能、更高效,当你在Cursor/ VSCode GitHub Copilot/WinSurf/CodeBuddy/Augment Code/Claude Code等AI编程工具里写代码时,它能自动帮你生成可直接部署的前后端应用+小程序,并一键发布到腾讯云开发 CloudBase。",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|