@cloudbase/cloudbase-mcp 2.0.5 → 2.1.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 +1 -5
- package/dist/cli.cjs +281 -15
- package/dist/index.cjs +281 -15
- package/dist/index.js +288 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -38330,7 +38330,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
38330
38330
|
// executeReadOnlySQL
|
|
38331
38331
|
server.registerTool?.("executeReadOnlySQL", {
|
|
38332
38332
|
title: "Execute read-only SQL query",
|
|
38333
|
-
description: "Execute a read-only SQL query on the SQL database. Note: For per-user ACL, each table should contain a fixed `_openid` column that represents the user and is used for access control.",
|
|
38333
|
+
description: "Execute a read-only SQL query on the SQL database. Note: For per-user ACL, each table should contain a fixed `_openid` column defined as `_openid VARCHAR(64) DEFAULT '' NOT NULL` that represents the user and is used for access control.",
|
|
38334
38334
|
inputSchema: {
|
|
38335
38335
|
sql: zod_1.z.string().describe("SQL query statement (SELECT queries only)"),
|
|
38336
38336
|
},
|
|
@@ -38389,7 +38389,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
38389
38389
|
// executeWriteSQL
|
|
38390
38390
|
server.registerTool?.("executeWriteSQL", {
|
|
38391
38391
|
title: "Execute write SQL statement",
|
|
38392
|
-
description: "Execute a write SQL statement on the SQL database (INSERT, UPDATE, DELETE, etc.). Whenever you create a new table, you **must**
|
|
38392
|
+
description: "Execute a write SQL statement on the SQL database (INSERT, UPDATE, DELETE, etc.). Whenever you create a new table, you **must** include a fixed `_openid` column defined as `_openid VARCHAR(64) DEFAULT '' NOT NULL` that represents the user and is used for access control.",
|
|
38393
38393
|
inputSchema: {
|
|
38394
38394
|
sql: zod_1.z
|
|
38395
38395
|
.string()
|
|
@@ -100306,12 +100306,14 @@ const rag_js_1 = __webpack_require__(64215);
|
|
|
100306
100306
|
const setup_js_1 = __webpack_require__(76556);
|
|
100307
100307
|
const storage_js_1 = __webpack_require__(94848);
|
|
100308
100308
|
// import { registerMiniprogramTools } from "./tools/miniprogram.js";
|
|
100309
|
+
const types_js_1 = __webpack_require__(1294);
|
|
100309
100310
|
const cloudrun_js_1 = __webpack_require__(35023);
|
|
100310
100311
|
const dataModel_js_1 = __webpack_require__(34052);
|
|
100311
100312
|
const gateway_js_1 = __webpack_require__(84319);
|
|
100312
100313
|
const invite_code_js_1 = __webpack_require__(44760);
|
|
100313
100314
|
const security_rule_js_1 = __webpack_require__(7862);
|
|
100314
100315
|
const cloud_mode_js_1 = __webpack_require__(89684);
|
|
100316
|
+
const logger_js_1 = __webpack_require__(13039);
|
|
100315
100317
|
const tool_wrapper_js_1 = __webpack_require__(71363);
|
|
100316
100318
|
// 默认插件列表
|
|
100317
100319
|
const DEFAULT_PLUGINS = [
|
|
@@ -100412,6 +100414,13 @@ async function createCloudBaseMcpServer(options) {
|
|
|
100412
100414
|
...(ide === "CodeBuddy" ? { logging: {} } : {}),
|
|
100413
100415
|
},
|
|
100414
100416
|
});
|
|
100417
|
+
// Only set logging handler if logging capability is declared
|
|
100418
|
+
if (ide === "CodeBuddy") {
|
|
100419
|
+
server.server.setRequestHandler(types_js_1.SetLevelRequestSchema, (request, extra) => {
|
|
100420
|
+
(0, logger_js_1.info)(`--- Logging level: ${request.params.level}`);
|
|
100421
|
+
return {};
|
|
100422
|
+
});
|
|
100423
|
+
}
|
|
100415
100424
|
// Store cloudBaseOptions in server instance for tools to access
|
|
100416
100425
|
if (cloudBaseOptions) {
|
|
100417
100426
|
server.cloudBaseOptions = cloudBaseOptions;
|
|
@@ -100442,10 +100451,10 @@ function getDefaultServer() {
|
|
|
100442
100451
|
}
|
|
100443
100452
|
var stdio_js_1 = __webpack_require__(6166);
|
|
100444
100453
|
Object.defineProperty(exports, "StdioServerTransport", ({ enumerable: true, get: function () { return stdio_js_1.StdioServerTransport; } }));
|
|
100445
|
-
var
|
|
100446
|
-
Object.defineProperty(exports, "error", ({ enumerable: true, get: function () { return
|
|
100447
|
-
Object.defineProperty(exports, "info", ({ enumerable: true, get: function () { return
|
|
100448
|
-
Object.defineProperty(exports, "warn", ({ enumerable: true, get: function () { return
|
|
100454
|
+
var logger_js_2 = __webpack_require__(13039);
|
|
100455
|
+
Object.defineProperty(exports, "error", ({ enumerable: true, get: function () { return logger_js_2.error; } }));
|
|
100456
|
+
Object.defineProperty(exports, "info", ({ enumerable: true, get: function () { return logger_js_2.info; } }));
|
|
100457
|
+
Object.defineProperty(exports, "warn", ({ enumerable: true, get: function () { return logger_js_2.warn; } }));
|
|
100449
100458
|
var telemetry_js_1 = __webpack_require__(45880);
|
|
100450
100459
|
Object.defineProperty(exports, "reportToolCall", ({ enumerable: true, get: function () { return telemetry_js_1.reportToolCall; } }));
|
|
100451
100460
|
Object.defineProperty(exports, "reportToolkitLifecycle", ({ enumerable: true, get: function () { return telemetry_js_1.reportToolkitLifecycle; } }));
|
|
@@ -101741,6 +101750,53 @@ class AsyncReader extends reader_1.default {
|
|
|
101741
101750
|
exports["default"] = AsyncReader;
|
|
101742
101751
|
|
|
101743
101752
|
|
|
101753
|
+
/***/ }),
|
|
101754
|
+
|
|
101755
|
+
/***/ 32720:
|
|
101756
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
101757
|
+
|
|
101758
|
+
"use strict";
|
|
101759
|
+
|
|
101760
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
101761
|
+
exports.sendDeployNotification = sendDeployNotification;
|
|
101762
|
+
const logger_js_1 = __webpack_require__(13039);
|
|
101763
|
+
/**
|
|
101764
|
+
* Send deployment notification to CodeBuddy IDE
|
|
101765
|
+
* @param server ExtendedMcpServer instance
|
|
101766
|
+
* @param notificationData Deployment notification data
|
|
101767
|
+
*/
|
|
101768
|
+
async function sendDeployNotification(server, notificationData) {
|
|
101769
|
+
// Check if current IDE is CodeBuddy (prefer server.ide, fallback to environment variable)
|
|
101770
|
+
const currentIde = server.ide || process.env.INTEGRATION_IDE;
|
|
101771
|
+
if (currentIde !== 'CodeBuddy' || !server.server) {
|
|
101772
|
+
// Not CodeBuddy IDE, skip notification
|
|
101773
|
+
return;
|
|
101774
|
+
}
|
|
101775
|
+
try {
|
|
101776
|
+
// Send notification using sendLoggingMessage
|
|
101777
|
+
server.server.sendLoggingMessage({
|
|
101778
|
+
level: "notice",
|
|
101779
|
+
data: {
|
|
101780
|
+
type: "tcb",
|
|
101781
|
+
event: "deploy",
|
|
101782
|
+
data: {
|
|
101783
|
+
type: notificationData.deployType, // "hosting" or "cloudrun"
|
|
101784
|
+
url: notificationData.url,
|
|
101785
|
+
projectId: notificationData.projectId,
|
|
101786
|
+
projectName: notificationData.projectName,
|
|
101787
|
+
consoleUrl: notificationData.consoleUrl
|
|
101788
|
+
}
|
|
101789
|
+
}
|
|
101790
|
+
});
|
|
101791
|
+
(0, logger_js_1.info)(`CodeBuddy IDE: 已发送部署通知 - ${notificationData.deployType} - ${notificationData.url}`);
|
|
101792
|
+
}
|
|
101793
|
+
catch (err) {
|
|
101794
|
+
// Log error but don't throw - notification failure should not affect deployment flow
|
|
101795
|
+
(0, logger_js_1.error)(`Failed to send deployment notification: ${err instanceof Error ? err.message : err}`, err);
|
|
101796
|
+
}
|
|
101797
|
+
}
|
|
101798
|
+
|
|
101799
|
+
|
|
101744
101800
|
/***/ }),
|
|
101745
101801
|
|
|
101746
101802
|
/***/ 32923:
|
|
@@ -110054,6 +110110,7 @@ const fs_1 = __importDefault(__webpack_require__(29021));
|
|
|
110054
110110
|
const path_1 = __importDefault(__webpack_require__(39902));
|
|
110055
110111
|
const zod_1 = __webpack_require__(21614);
|
|
110056
110112
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
110113
|
+
const notification_js_1 = __webpack_require__(32720);
|
|
110057
110114
|
// CloudRun service types
|
|
110058
110115
|
exports.CLOUDRUN_SERVICE_TYPES = ['function', 'container'];
|
|
110059
110116
|
// CloudRun access types
|
|
@@ -110558,6 +110615,58 @@ for await (let x of res.textStream) {
|
|
|
110558
110615
|
catch (error) {
|
|
110559
110616
|
// Ignore cloudbaserc.json creation errors
|
|
110560
110617
|
}
|
|
110618
|
+
// Send deployment notification to CodeBuddy IDE
|
|
110619
|
+
try {
|
|
110620
|
+
// Query service details to get access URL
|
|
110621
|
+
let serviceUrl = "";
|
|
110622
|
+
try {
|
|
110623
|
+
const serviceDetails = await cloudrunService.detail({ serverName: input.serverName });
|
|
110624
|
+
// Extract access URL from service details
|
|
110625
|
+
// Priority: DefaultDomainName > CustomDomainName > PublicDomain > InternalDomain
|
|
110626
|
+
const details = serviceDetails; // Use any to access dynamic properties
|
|
110627
|
+
if (details?.BaseInfo?.DefaultDomainName) {
|
|
110628
|
+
// DefaultDomainName is already a complete URL (e.g., https://...)
|
|
110629
|
+
serviceUrl = details.BaseInfo.DefaultDomainName;
|
|
110630
|
+
}
|
|
110631
|
+
else if (details?.BaseInfo?.CustomDomainName) {
|
|
110632
|
+
// CustomDomainName might be a domain without protocol
|
|
110633
|
+
const customDomain = details.BaseInfo.CustomDomainName;
|
|
110634
|
+
serviceUrl = customDomain.startsWith('http') ? customDomain : `https://${customDomain}`;
|
|
110635
|
+
}
|
|
110636
|
+
else if (details?.BaseInfo?.PublicDomain) {
|
|
110637
|
+
serviceUrl = `https://${details.BaseInfo.PublicDomain}`;
|
|
110638
|
+
}
|
|
110639
|
+
else if (details?.BaseInfo?.InternalDomain) {
|
|
110640
|
+
serviceUrl = `https://${details.BaseInfo.InternalDomain}`;
|
|
110641
|
+
}
|
|
110642
|
+
else if (details?.AccessInfo?.PublicDomain) {
|
|
110643
|
+
serviceUrl = `https://${details.AccessInfo.PublicDomain}`;
|
|
110644
|
+
}
|
|
110645
|
+
else {
|
|
110646
|
+
serviceUrl = ""; // URL not available
|
|
110647
|
+
}
|
|
110648
|
+
}
|
|
110649
|
+
catch (detailErr) {
|
|
110650
|
+
// If query fails, continue with empty URL
|
|
110651
|
+
serviceUrl = "";
|
|
110652
|
+
}
|
|
110653
|
+
// Extract project name from targetPath
|
|
110654
|
+
const projectName = path_1.default.basename(targetPath);
|
|
110655
|
+
// Build console URL
|
|
110656
|
+
const consoleUrl = `https://tcb.cloud.tencent.com/dev?envId=${currentEnvId}#/platform-run/service/detail?serverName=${input.serverName}&tabId=overview&envId=${currentEnvId}`;
|
|
110657
|
+
// Send notification
|
|
110658
|
+
await (0, notification_js_1.sendDeployNotification)(server, {
|
|
110659
|
+
deployType: 'cloudrun',
|
|
110660
|
+
url: serviceUrl,
|
|
110661
|
+
projectId: currentEnvId,
|
|
110662
|
+
projectName: projectName,
|
|
110663
|
+
consoleUrl: consoleUrl
|
|
110664
|
+
});
|
|
110665
|
+
}
|
|
110666
|
+
catch (notifyErr) {
|
|
110667
|
+
// Notification failure should not affect deployment flow
|
|
110668
|
+
// Error is already logged in sendDeployNotification
|
|
110669
|
+
}
|
|
110561
110670
|
return {
|
|
110562
110671
|
content: [
|
|
110563
110672
|
{
|
|
@@ -114734,14 +114843,20 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|
|
114734
114843
|
/***/ }),
|
|
114735
114844
|
|
|
114736
114845
|
/***/ 37279:
|
|
114737
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
114846
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
114738
114847
|
|
|
114739
114848
|
"use strict";
|
|
114740
114849
|
|
|
114850
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
114851
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
114852
|
+
};
|
|
114741
114853
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
114742
114854
|
exports.registerHostingTools = registerHostingTools;
|
|
114855
|
+
const fs_1 = __importDefault(__webpack_require__(29021));
|
|
114856
|
+
const path_1 = __importDefault(__webpack_require__(39902));
|
|
114743
114857
|
const zod_1 = __webpack_require__(21614);
|
|
114744
114858
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
114859
|
+
const notification_js_1 = __webpack_require__(32720);
|
|
114745
114860
|
function registerHostingTools(server) {
|
|
114746
114861
|
// 获取 cloudBaseOptions,如果没有则为 undefined
|
|
114747
114862
|
const cloudBaseOptions = server.cloudBaseOptions;
|
|
@@ -114778,6 +114893,43 @@ function registerHostingTools(server) {
|
|
|
114778
114893
|
// 获取环境信息
|
|
114779
114894
|
const envInfo = await cloudbase.env.getEnvInfo();
|
|
114780
114895
|
const staticDomain = envInfo.EnvInfo?.StaticStorages?.[0]?.StaticDomain;
|
|
114896
|
+
const accessUrl = staticDomain ? `https://${staticDomain}/${cloudPath || ''}` : "";
|
|
114897
|
+
// Send deployment notification to CodeBuddy IDE
|
|
114898
|
+
try {
|
|
114899
|
+
const envId = await (0, cloudbase_manager_js_1.getEnvId)(cloudBaseOptions);
|
|
114900
|
+
// Extract project name from localPath
|
|
114901
|
+
let projectName = "unknown";
|
|
114902
|
+
if (localPath) {
|
|
114903
|
+
try {
|
|
114904
|
+
// If localPath is a file, get parent directory name; if it's a directory, get directory name
|
|
114905
|
+
const stats = fs_1.default.statSync(localPath);
|
|
114906
|
+
if (stats.isFile()) {
|
|
114907
|
+
projectName = path_1.default.basename(path_1.default.dirname(localPath));
|
|
114908
|
+
}
|
|
114909
|
+
else {
|
|
114910
|
+
projectName = path_1.default.basename(localPath);
|
|
114911
|
+
}
|
|
114912
|
+
}
|
|
114913
|
+
catch (statErr) {
|
|
114914
|
+
// If stat fails, try to extract from path directly
|
|
114915
|
+
projectName = path_1.default.basename(localPath);
|
|
114916
|
+
}
|
|
114917
|
+
}
|
|
114918
|
+
// Build console URL
|
|
114919
|
+
const consoleUrl = `https://tcb.cloud.tencent.com/dev?envId=${envId}#/static-hosting`;
|
|
114920
|
+
// Send notification
|
|
114921
|
+
await (0, notification_js_1.sendDeployNotification)(server, {
|
|
114922
|
+
deployType: 'hosting',
|
|
114923
|
+
url: accessUrl,
|
|
114924
|
+
projectId: envId,
|
|
114925
|
+
projectName: projectName,
|
|
114926
|
+
consoleUrl: consoleUrl
|
|
114927
|
+
});
|
|
114928
|
+
}
|
|
114929
|
+
catch (notifyErr) {
|
|
114930
|
+
// Notification failure should not affect deployment flow
|
|
114931
|
+
// Error is already logged in sendDeployNotification
|
|
114932
|
+
}
|
|
114781
114933
|
return {
|
|
114782
114934
|
content: [
|
|
114783
114935
|
{
|
|
@@ -114786,7 +114938,7 @@ function registerHostingTools(server) {
|
|
|
114786
114938
|
...result,
|
|
114787
114939
|
staticDomain,
|
|
114788
114940
|
message: "文件上传成功",
|
|
114789
|
-
accessUrl:
|
|
114941
|
+
accessUrl: accessUrl
|
|
114790
114942
|
}, null, 2)
|
|
114791
114943
|
}
|
|
114792
114944
|
]
|
|
@@ -134714,7 +134866,7 @@ class TelemetryReporter {
|
|
|
134714
134866
|
const nodeVersion = process.version; // Node.js版本
|
|
134715
134867
|
const arch = os_1.default.arch(); // 系统架构
|
|
134716
134868
|
// 从构建时注入的版本号获取MCP版本信息
|
|
134717
|
-
const mcpVersion = process.env.npm_package_version || "2.0
|
|
134869
|
+
const mcpVersion = process.env.npm_package_version || "2.1.0" || 0;
|
|
134718
134870
|
return {
|
|
134719
134871
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
134720
134872
|
deviceId: this.deviceId,
|
|
@@ -185380,6 +185532,7 @@ async function registerRagTools(server) {
|
|
|
185380
185532
|
}
|
|
185381
185533
|
});
|
|
185382
185534
|
let skills = [];
|
|
185535
|
+
let openapis = [];
|
|
185383
185536
|
// 知识库检索
|
|
185384
185537
|
try {
|
|
185385
185538
|
skills = await prepareKnowledgeBaseWebTemplate();
|
|
@@ -185389,22 +185542,40 @@ async function registerRagTools(server) {
|
|
|
185389
185542
|
error,
|
|
185390
185543
|
});
|
|
185391
185544
|
}
|
|
185545
|
+
// OpenAPI 文档准备
|
|
185546
|
+
try {
|
|
185547
|
+
openapis = await prepareOpenAPIDocs();
|
|
185548
|
+
}
|
|
185549
|
+
catch (error) {
|
|
185550
|
+
(0, logger_js_1.warn)("[searchKnowledgeBase] Failed to prepare OpenAPI docs", {
|
|
185551
|
+
error,
|
|
185552
|
+
});
|
|
185553
|
+
}
|
|
185392
185554
|
server.registerTool?.("searchKnowledgeBase", {
|
|
185393
185555
|
title: "云开发知识库检索",
|
|
185394
|
-
description: `云开发知识库智能检索工具,支持向量查询 (vector)
|
|
185556
|
+
description: `云开发知识库智能检索工具,支持向量查询 (vector)、固定文档 (doc) 和 OpenAPI 文档 (openapi) 查询。
|
|
185395
185557
|
|
|
185396
|
-
强烈推荐始终优先使用固定文档 (doc) 模式进行检索,仅当固定文档无法覆盖你的问题时,再使用向量查询 (vector) 模式。
|
|
185558
|
+
强烈推荐始终优先使用固定文档 (doc) 或 OpenAPI 文档 (openapi) 模式进行检索,仅当固定文档无法覆盖你的问题时,再使用向量查询 (vector) 模式。
|
|
185397
185559
|
|
|
185398
185560
|
固定文档 (doc) 查询当前支持 ${skills.length} 个固定文档,分别是:
|
|
185399
185561
|
${skills
|
|
185400
185562
|
.map((skill) => `文档名:${path.basename(path.dirname(skill.absolutePath))} 文档介绍:${skill.description}`)
|
|
185563
|
+
.join("\n")}
|
|
185564
|
+
|
|
185565
|
+
OpenAPI 文档 (openapi) 查询当前支持 ${openapis.length} 个 API 文档,分别是:
|
|
185566
|
+
${openapis
|
|
185567
|
+
.map((api) => `API名:${api.name} API介绍:${api.description}`)
|
|
185401
185568
|
.join("\n")}`,
|
|
185402
185569
|
inputSchema: {
|
|
185403
|
-
mode: zod_1.z.enum(["vector", "doc"]),
|
|
185570
|
+
mode: zod_1.z.enum(["vector", "doc", "openapi"]),
|
|
185404
185571
|
docName: zod_1.z
|
|
185405
185572
|
.enum(skills.map((skill) => path.basename(path.dirname(skill.absolutePath))))
|
|
185406
185573
|
.optional()
|
|
185407
185574
|
.describe("mode=doc 时指定。文档名称。"),
|
|
185575
|
+
apiName: zod_1.z
|
|
185576
|
+
.enum(openapis.map((api) => api.name))
|
|
185577
|
+
.optional()
|
|
185578
|
+
.describe("mode=openapi 时指定。API 名称。"),
|
|
185408
185579
|
threshold: zod_1.z
|
|
185409
185580
|
.number()
|
|
185410
185581
|
.default(0.5)
|
|
@@ -185434,7 +185605,7 @@ async function registerRagTools(server) {
|
|
|
185434
185605
|
openWorldHint: true,
|
|
185435
185606
|
category: "rag",
|
|
185436
185607
|
},
|
|
185437
|
-
}, async ({ id, content, options: { chunkExpand = [3, 3] } = {}, limit = 5, threshold = 0.5, mode, docName, }) => {
|
|
185608
|
+
}, async ({ id, content, options: { chunkExpand = [3, 3] } = {}, limit = 5, threshold = 0.5, mode, docName, apiName, }) => {
|
|
185438
185609
|
if (mode === "doc") {
|
|
185439
185610
|
const absolutePath = skills.find((skill) => skill.absolutePath.includes(docName)).absolutePath;
|
|
185440
185611
|
return {
|
|
@@ -185446,6 +185617,27 @@ async function registerRagTools(server) {
|
|
|
185446
185617
|
],
|
|
185447
185618
|
};
|
|
185448
185619
|
}
|
|
185620
|
+
if (mode === "openapi") {
|
|
185621
|
+
const api = openapis.find((api) => api.name === apiName);
|
|
185622
|
+
if (!api) {
|
|
185623
|
+
return {
|
|
185624
|
+
content: [
|
|
185625
|
+
{
|
|
185626
|
+
type: "text",
|
|
185627
|
+
text: `OpenAPI document "${apiName}" not found. Available APIs: ${openapis.map((a) => a.name).join(", ")}`,
|
|
185628
|
+
},
|
|
185629
|
+
],
|
|
185630
|
+
};
|
|
185631
|
+
}
|
|
185632
|
+
return {
|
|
185633
|
+
content: [
|
|
185634
|
+
{
|
|
185635
|
+
type: "text",
|
|
185636
|
+
text: `OpenAPI document: ${api.name}\nDescription: ${api.description}\nPath: ${api.absolutePath}\n\n${(await fs.readFile(api.absolutePath)).toString()}`,
|
|
185637
|
+
},
|
|
185638
|
+
],
|
|
185639
|
+
};
|
|
185640
|
+
}
|
|
185449
185641
|
// 枚举到后端 id 映射
|
|
185450
185642
|
const backendId = KnowledgeBaseIdMap[id] || id;
|
|
185451
185643
|
const signInRes = await fetch("https://tcb-advanced-a656fc.api.tcloudbasegateway.com/auth/v1/signin/anonymously", {
|
|
@@ -185522,6 +185714,65 @@ function extractDescriptionFromFrontMatter(content) {
|
|
|
185522
185714
|
.match(/^(?:decsription|description)\s*:\s*(.*)$/m);
|
|
185523
185715
|
return match ? match[1].trim() : null;
|
|
185524
185716
|
}
|
|
185717
|
+
// OpenAPI 文档 URL 列表
|
|
185718
|
+
const OPENAPI_SOURCES = [
|
|
185719
|
+
{
|
|
185720
|
+
name: "mysqldb",
|
|
185721
|
+
description: "MySQL RESTful API - 云开发 MySQL 数据库 HTTP API",
|
|
185722
|
+
url: "https://docs.cloudbase.net/openapi/mysqldb.v1.openapi.yaml",
|
|
185723
|
+
},
|
|
185724
|
+
{
|
|
185725
|
+
name: "functions",
|
|
185726
|
+
description: "Cloud Functions API - 云函数 HTTP API",
|
|
185727
|
+
url: "https://docs.cloudbase.net/openapi/functions.v1.openapi.yaml",
|
|
185728
|
+
},
|
|
185729
|
+
{
|
|
185730
|
+
name: "auth",
|
|
185731
|
+
description: "Authentication API - 身份认证 HTTP API",
|
|
185732
|
+
url: "https://docs.cloudbase.net/openapi/auth.v1.openapi.yaml",
|
|
185733
|
+
},
|
|
185734
|
+
{
|
|
185735
|
+
name: "cloudrun",
|
|
185736
|
+
description: "CloudRun API - 云托管服务 HTTP API",
|
|
185737
|
+
url: "https://docs.cloudbase.net/openapi/cloudrun.v1.openapi.yaml",
|
|
185738
|
+
},
|
|
185739
|
+
{
|
|
185740
|
+
name: "storage",
|
|
185741
|
+
description: "Storage API - 云存储 HTTP API",
|
|
185742
|
+
url: "https://docs.cloudbase.net/openapi/storage.v1.openapi.yaml",
|
|
185743
|
+
},
|
|
185744
|
+
];
|
|
185745
|
+
// 下载并准备 OpenAPI 文档
|
|
185746
|
+
async function prepareOpenAPIDocs() {
|
|
185747
|
+
const baseDir = path.join(os.homedir(), ".cloudbase-mcp", "openapi");
|
|
185748
|
+
await fs.mkdir(baseDir, { recursive: true });
|
|
185749
|
+
const results = [];
|
|
185750
|
+
await Promise.all(OPENAPI_SOURCES.map(async (source) => {
|
|
185751
|
+
try {
|
|
185752
|
+
const response = await fetch(source.url);
|
|
185753
|
+
if (!response.ok) {
|
|
185754
|
+
(0, logger_js_1.warn)(`[prepareOpenAPIDocs] Failed to download ${source.name}`, {
|
|
185755
|
+
status: response.status,
|
|
185756
|
+
});
|
|
185757
|
+
return;
|
|
185758
|
+
}
|
|
185759
|
+
const content = await response.text();
|
|
185760
|
+
const filePath = path.join(baseDir, `${source.name}.openapi.yaml`);
|
|
185761
|
+
await fs.writeFile(filePath, content, "utf8");
|
|
185762
|
+
results.push({
|
|
185763
|
+
name: source.name,
|
|
185764
|
+
description: source.description,
|
|
185765
|
+
absolutePath: filePath,
|
|
185766
|
+
});
|
|
185767
|
+
}
|
|
185768
|
+
catch (error) {
|
|
185769
|
+
(0, logger_js_1.warn)(`[prepareOpenAPIDocs] Failed to download ${source.name}`, {
|
|
185770
|
+
error,
|
|
185771
|
+
});
|
|
185772
|
+
}
|
|
185773
|
+
}));
|
|
185774
|
+
return results;
|
|
185775
|
+
}
|
|
185525
185776
|
async function collectSkillDescriptions(rootDir) {
|
|
185526
185777
|
const result = [];
|
|
185527
185778
|
async function walk(dir) {
|
|
@@ -200359,7 +200610,7 @@ ${envIdSection}
|
|
|
200359
200610
|
## 环境信息
|
|
200360
200611
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
200361
200612
|
- Node.js版本: ${process.version}
|
|
200362
|
-
- MCP 版本:${process.env.npm_package_version || "2.0
|
|
200613
|
+
- MCP 版本:${process.env.npm_package_version || "2.1.0" || 0}
|
|
200363
200614
|
- 系统架构: ${os_1.default.arch()}
|
|
200364
200615
|
- 时间: ${new Date().toISOString()}
|
|
200365
200616
|
- 请求ID: ${requestId}
|
|
@@ -208640,12 +208891,15 @@ deleteCollection: 删除数据`),
|
|
|
208640
208891
|
collectionName: zod_1.z.string().describe("集合名称"),
|
|
208641
208892
|
documents: zod_1.z
|
|
208642
208893
|
.array(zod_1.z.object({}).passthrough())
|
|
208894
|
+
.optional()
|
|
208643
208895
|
.describe("要插入的文档对象数组,每个文档都是对象(insert 操作必填)"),
|
|
208644
208896
|
query: zod_1.z
|
|
208645
208897
|
.union([zod_1.z.object({}).passthrough(), zod_1.z.string()])
|
|
208898
|
+
.optional()
|
|
208646
208899
|
.describe("查询条件(对象或字符串,推荐对象)(update/delete 操作必填)"),
|
|
208647
208900
|
update: zod_1.z
|
|
208648
208901
|
.union([zod_1.z.object({}).passthrough(), zod_1.z.string()])
|
|
208902
|
+
.optional()
|
|
208649
208903
|
.describe("更新内容(对象或字符串,推荐对象)(update 操作必填)"),
|
|
208650
208904
|
isMulti: zod_1.z
|
|
208651
208905
|
.boolean()
|
|
@@ -208665,6 +208919,9 @@ deleteCollection: 删除数据`),
|
|
|
208665
208919
|
},
|
|
208666
208920
|
}, async ({ action, collectionName, documents, query, update, isMulti, upsert, }) => {
|
|
208667
208921
|
if (action === "insert") {
|
|
208922
|
+
if (!documents) {
|
|
208923
|
+
throw new Error("insert 操作时必须提供 documents");
|
|
208924
|
+
}
|
|
208668
208925
|
const text = await insertDocuments({
|
|
208669
208926
|
collectionName,
|
|
208670
208927
|
documents,
|
|
@@ -208680,6 +208937,12 @@ deleteCollection: 删除数据`),
|
|
|
208680
208937
|
};
|
|
208681
208938
|
}
|
|
208682
208939
|
if (action === "update") {
|
|
208940
|
+
if (!query) {
|
|
208941
|
+
throw new Error("update 操作时必须提供 query");
|
|
208942
|
+
}
|
|
208943
|
+
if (!update) {
|
|
208944
|
+
throw new Error("update 操作时必须提供 update");
|
|
208945
|
+
}
|
|
208683
208946
|
const text = await updateDocuments({
|
|
208684
208947
|
collectionName,
|
|
208685
208948
|
query,
|
|
@@ -208698,6 +208961,9 @@ deleteCollection: 删除数据`),
|
|
|
208698
208961
|
};
|
|
208699
208962
|
}
|
|
208700
208963
|
if (action === "delete") {
|
|
208964
|
+
if (!query) {
|
|
208965
|
+
throw new Error("delete 操作时必须提供 query");
|
|
208966
|
+
}
|
|
208701
208967
|
const text = await deleteDocuments({
|
|
208702
208968
|
collectionName,
|
|
208703
208969
|
query,
|
|
@@ -214936,7 +215202,7 @@ function registerSetupTools(server) {
|
|
|
214936
215202
|
title: "下载项目模板",
|
|
214937
215203
|
description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
|
|
214938
215204
|
|
|
214939
|
-
**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
|
|
215205
|
+
**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.1.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
214940
215206
|
inputSchema: {
|
|
214941
215207
|
template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
|
|
214942
215208
|
ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
|