Skip to content

Commit d43ad6c

Browse files
committed
fix: 修正 sort 字段说明
1 parent 5e98fc3 commit d43ad6c

1 file changed

Lines changed: 30 additions & 10 deletions

File tree

mcp/src/tools/databaseNoSQL.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import CloudBase from "@cloudbase/manager-node";
22
import { z } from "zod";
3-
import { getCloudBaseManager, logCloudBaseResult } from "../cloudbase-manager.js";
3+
import {
4+
getCloudBaseManager,
5+
logCloudBaseResult,
6+
} from "../cloudbase-manager.js";
47
import { ExtendedMcpServer } from "../server.js";
58
import { Logger } from "../types.js";
69

@@ -217,8 +220,11 @@ checkIndex: 检查索引是否存在`),
217220
title: "修改 NoSQL 数据库结构",
218221
description: "修改 NoSQL 数据库结构",
219222
inputSchema: {
220-
action: z.enum(["createCollection", "updateCollection", "deleteCollection"])
221-
.describe(`createCollection: 创建集合
223+
action: z.enum([
224+
"createCollection",
225+
"updateCollection",
226+
"deleteCollection",
227+
]).describe(`createCollection: 创建集合
222228
updateCollection: 更新集合
223229
deleteCollection: 删除集合`),
224230
collectionName: z.string().describe("集合名称"),
@@ -320,9 +326,8 @@ deleteCollection: 删除集合`),
320326
success: true,
321327
requestId: result.RequestId,
322328
action,
323-
message: result.Exists === false
324-
? "集合不存在"
325-
: "云开发数据库集合删除成功",
329+
message:
330+
result.Exists === false ? "集合不存在" : "云开发数据库集合删除成功",
326331
};
327332
if (result.Exists === false) {
328333
body.exists = false;
@@ -358,9 +363,21 @@ deleteCollection: 删除集合`),
358363
.optional()
359364
.describe("返回字段投影(对象或字符串,推荐对象)"),
360365
sort: z
361-
.union([z.object({}).passthrough(), z.string()])
366+
.union([
367+
z.array(
368+
z
369+
.object({
370+
key: z.string().describe("sort 字段名"),
371+
direction: z.number().describe("排序方向,1:升序,-1:降序"),
372+
})
373+
.passthrough(),
374+
),
375+
z.string(),
376+
])
362377
.optional()
363-
.describe("排序条件(对象或字符串,推荐对象)"),
378+
.describe(
379+
"排序条件,使用对象或字符串。",
380+
),
364381
limit: z.number().optional().describe("返回数量限制"),
365382
offset: z.number().optional().describe("跳过的记录数"),
366383
},
@@ -416,8 +433,11 @@ deleteCollection: 删除集合`),
416433
title: "修改 NoSQL 数据库数据记录",
417434
description: "修改 NoSQL 数据库数据记录",
418435
inputSchema: {
419-
action: z.enum(["insert", "update", "delete"])
420-
.describe(`insert: 插入数据(新增文档)\nupdate: 更新数据\ndelete: 删除数据`),
436+
action: z
437+
.enum(["insert", "update", "delete"])
438+
.describe(
439+
`insert: 插入数据(新增文档)\nupdate: 更新数据\ndelete: 删除数据`,
440+
),
421441
collectionName: z.string().describe("集合名称"),
422442
documents: z
423443
.array(z.object({}).passthrough())

0 commit comments

Comments
 (0)