yuque-ai-mcp 2.12.0 → 2.12.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.
@@ -10,12 +10,13 @@
10
10
  */
11
11
  import { isErrorResult } from "../common/api-client.js";
12
12
  import { webRequest } from "../common/web-request.js";
13
- import { check, requiredString } from "../common/validate.js";
13
+ import { check, requiredString, optionalString } from "../common/validate.js";
14
14
  const CATALOG_REFERER = "https://www.yuque.com/";
15
15
  export const webBatchMoveCatalogNodes = {
16
16
  name: "yuque_web_batch_move_catalog_nodes",
17
17
  description: "Cookie-based: Batch move document nodes to a target catalog node. " +
18
18
  "PUT /api/catalog_nodes/batch. " +
19
+ "Supports cross-repo move (target_book_id may differ from book_id). " +
19
20
  "No membership required. " +
20
21
  "Moves the specified node_uuids under the target_uuid directory as children. " +
21
22
  "详见 references/api/catalog_api.md",
@@ -32,14 +33,18 @@ export const webBatchMoveCatalogNodes = {
32
33
  },
33
34
  book_id: {
34
35
  type: "string",
35
- description: "Repository ID (numeric, required)",
36
+ description: "源知识库 ID(数字,必填)。节点当前所在的知识库。 / Source repository ID (numeric, required). The repo the nodes currently live in.",
37
+ },
38
+ target_book_id: {
39
+ type: "string",
40
+ description: "目标知识库 ID(数字,可选)。跨库移动时填目标知识库 ID。缺省为 book_id(同库移动)。 / Target repository ID (numeric, optional). For cross-repo move set this to the destination repo. Defaults to book_id (same-repo move).",
36
41
  },
37
42
  },
38
43
  required: ["node_uuids", "target_uuid", "book_id"],
39
44
  },
40
45
  async handler(args) {
41
46
  // @validate
42
- const __v = check(requiredString(args?.node_uuids, "node_uuids"), requiredString(args?.target_uuid, "target_uuid"), requiredString(args?.book_id, "book_id"));
47
+ const __v = check(requiredString(args?.node_uuids, "node_uuids"), requiredString(args?.target_uuid, "target_uuid"), requiredString(args?.book_id, "book_id"), optionalString(args?.target_book_id, "target_book_id"));
43
48
  if (__v)
44
49
  return __v;
45
50
  const bookId = Number(args?.book_id);
@@ -49,6 +54,15 @@ export const webBatchMoveCatalogNodes = {
49
54
  isError: true,
50
55
  };
51
56
  }
57
+ // target_book_id 缺省 = book_id(同库移动);填了则支持跨库
58
+ const targetBookIdRaw = args?.target_book_id?.trim();
59
+ const targetBookId = targetBookIdRaw ? Number(targetBookIdRaw) : bookId;
60
+ if (!targetBookId) {
61
+ return {
62
+ content: [{ type: "text", text: JSON.stringify({ error: "target_book_id 必须为有效数字 / target_book_id must be a valid number" }, null, 2) }],
63
+ isError: true,
64
+ };
65
+ }
52
66
  // Parse node_uuids JSON array
53
67
  let nodeUuids;
54
68
  try {
@@ -76,7 +90,7 @@ export const webBatchMoveCatalogNodes = {
76
90
  node_uuids: nodeUuids,
77
91
  target_uuid: args.target_uuid,
78
92
  book_id: bookId,
79
- target_book_id: bookId,
93
+ target_book_id: targetBookId,
80
94
  transfer_action: "prependChild",
81
95
  insert_to_catalog: true,
82
96
  };
@@ -93,7 +107,10 @@ export const webBatchMoveCatalogNodes = {
93
107
  moved_count: nodeUuids.length,
94
108
  node_uuids: nodeUuids,
95
109
  target_uuid: args.target_uuid,
96
- message: `成功将 ${nodeUuids.length} 个文档节点移动到目标目录下 / Successfully moved ${nodeUuids.length} document nodes to target catalog`,
110
+ book_id: bookId,
111
+ target_book_id: targetBookId,
112
+ cross_repo: targetBookId !== bookId,
113
+ message: `成功将 ${nodeUuids.length} 个文档节点移动到目标目录下(${targetBookId !== bookId ? "跨库" : "同库"}) / Successfully moved ${nodeUuids.length} document nodes to target catalog (${targetBookId !== bookId ? "cross-repo" : "same-repo"})`,
97
114
  }, null, 2) }],
98
115
  };
99
116
  },
@@ -1 +1 @@
1
- {"version":3,"file":"batch-move-catalog-nodes.js","sourceRoot":"","sources":["../../src/web-doc/batch-move-catalog-nodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;A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c,EAAE,YAAY;YAC5B,eAAe,EAAE,cAAc;YAC/B,iBAAiB,EAAE,IAAI;SACxB,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE;YACnC,MAAM,EAAE,KAAK;YACb,IAAI;YACJ,OAAO,EAAE,eAAe;SACzB,CAAC,CAAC;QAEH,IAAI,aAAa,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC;QAEzC,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACtD,OAAO,EAAE,IAAI;wBACb,WAAW,EAAE,SAAS,CAAC,MAAM;wBAC7B,UAAU,EAAE,SAAS;wBACrB,WAAW,EAAE,IAAK,CAAC,WAAW;wBAC9B,OAAO,EAAE,MAAM;wBACf,cAAc,EAAE,YAAY;wBAC5B,UAAU,EAAE,YAAY,KAAK,MAAM;wBACnC,OAAO,EAAE,OAAO,SAAS,CAAC,MAAM,kBAAkB,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,0BAA0B,SAAS,CAAC,MAAM,sCAAsC,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,GAAG;qBAC/N,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SACf,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -4,5 +4,6 @@ export { webRepoList } from "./list-repos.js";
4
4
  export { webTocGet } from "./get-toc.js";
5
5
  export { webDocDelete } from "./delete-doc.js";
6
6
  export { webBatchMoveCatalogNodes } from "./batch-move-catalog-nodes.js";
7
+ export { webMoveCatalogNode } from "./move-catalog-node.js";
7
8
  import type { McpTool } from "../common/types.js";
8
9
  export declare const webDocTools: McpTool[];
@@ -4,11 +4,13 @@ export { webRepoList } from "./list-repos.js";
4
4
  export { webTocGet } from "./get-toc.js";
5
5
  export { webDocDelete } from "./delete-doc.js";
6
6
  export { webBatchMoveCatalogNodes } from "./batch-move-catalog-nodes.js";
7
+ export { webMoveCatalogNode } from "./move-catalog-node.js";
7
8
  import { webDocGet } from "./get-doc.js";
8
9
  import { webDocList } from "./list-docs.js";
9
10
  import { webRepoList } from "./list-repos.js";
10
11
  import { webTocGet } from "./get-toc.js";
11
12
  import { webDocDelete } from "./delete-doc.js";
12
13
  import { webBatchMoveCatalogNodes } from "./batch-move-catalog-nodes.js";
13
- export const webDocTools = [webDocGet, webDocList, webRepoList, webTocGet, webDocDelete, webBatchMoveCatalogNodes];
14
+ import { webMoveCatalogNode } from "./move-catalog-node.js";
15
+ export const webDocTools = [webDocGet, webDocList, webRepoList, webTocGet, webDocDelete, webBatchMoveCatalogNodes, webMoveCatalogNode];
14
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/web-doc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,CAAC,MAAM,WAAW,GAAc,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,wBAAwB,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/web-doc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,CAAC,MAAM,WAAW,GAAc,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,wBAAwB,EAAE,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * web-doc/move-catalog-node — Cookie 态移动单个目录节点(支持跨库 + 带子树)
3
+ *
4
+ * 端点:PUT /api/catalog_nodes/move(Web API,Cookie 认证)
5
+ * 职责:将单个目录节点移动到目标目录/目标知识库下。
6
+ *
7
+ * 相比 batch 版的优势:
8
+ * - 支持跨知识库移动(target_book_id 可 != book_id)
9
+ * - 支持 with_children 连带子节点整棵子树移动
10
+ * - 单节点语义,字段与原 web 端完全对齐
11
+ */
12
+ import type { McpTool } from "../common/types.js";
13
+ export declare const webMoveCatalogNode: McpTool;
@@ -0,0 +1,112 @@
1
+ /**
2
+ * web-doc/move-catalog-node — Cookie 态移动单个目录节点(支持跨库 + 带子树)
3
+ *
4
+ * 端点:PUT /api/catalog_nodes/move(Web API,Cookie 认证)
5
+ * 职责:将单个目录节点移动到目标目录/目标知识库下。
6
+ *
7
+ * 相比 batch 版的优势:
8
+ * - 支持跨知识库移动(target_book_id 可 != book_id)
9
+ * - 支持 with_children 连带子节点整棵子树移动
10
+ * - 单节点语义,字段与原 web 端完全对齐
11
+ */
12
+ import { isErrorResult } from "../common/api-client.js";
13
+ import { webRequest } from "../common/web-request.js";
14
+ import { check, requiredString, optionalString, optionalBoolean } from "../common/validate.js";
15
+ const MOVE_REFERER = "https://www.yuque.com/";
16
+ export const webMoveCatalogNode = {
17
+ name: "yuque_web_move_catalog_node",
18
+ description: "Cookie-based: Move a single catalog node to a target catalog node / target repo. " +
19
+ "PUT /api/catalog_nodes/move. " +
20
+ "Supports cross-repo move (target_book_id may differ from book_id) and moving the whole subtree (with_children). " +
21
+ "No membership required. " +
22
+ "详见 references/api/catalog_api.md",
23
+ inputSchema: {
24
+ type: "object",
25
+ properties: {
26
+ book_id: {
27
+ type: "string",
28
+ description: "Source repository ID (numeric, required). The repo the node currently lives in.",
29
+ },
30
+ node_uuid: {
31
+ type: "string",
32
+ description: "Catalog node UUID to move (required).",
33
+ },
34
+ target_book_id: {
35
+ type: "string",
36
+ description: "Target repository ID (numeric). For cross-repo move set this to the destination repo. Defaults to book_id (same-repo move).",
37
+ },
38
+ target_uuid: {
39
+ type: "string",
40
+ description: "Target catalog node UUID to move into. Leave empty / null to move to the root of the target repo.",
41
+ },
42
+ action: {
43
+ type: "string",
44
+ description: "Move action. Default 'prependChild'. Common values: prependChild (as first child), appendChild (as last child).",
45
+ },
46
+ with_children: {
47
+ type: "boolean",
48
+ description: "Move the whole subtree (all descendant nodes) together. Default true.",
49
+ },
50
+ insert_to_catalog: {
51
+ type: "boolean",
52
+ description: "Whether to insert into the catalog/TOC. Default true.",
53
+ },
54
+ },
55
+ required: ["book_id", "node_uuid"],
56
+ },
57
+ async handler(args) {
58
+ // @validate
59
+ const __v = check(requiredString(args?.book_id, "book_id"), requiredString(args?.node_uuid, "node_uuid"), optionalString(args?.target_book_id, "target_book_id"), optionalString(args?.target_uuid, "target_uuid"), optionalString(args?.action, "action"), optionalBoolean(args?.with_children, "with_children"), optionalBoolean(args?.insert_to_catalog, "insert_to_catalog"));
60
+ if (__v)
61
+ return __v;
62
+ const bookId = Number(args?.book_id);
63
+ if (!bookId) {
64
+ return {
65
+ content: [{ type: "text", text: JSON.stringify({ error: "book_id 必须为有效数字 / book_id must be a valid number" }, null, 2) }],
66
+ isError: true,
67
+ };
68
+ }
69
+ // target_book_id 缺省 = book_id(同库移动);填了则支持跨库
70
+ const targetBookIdRaw = args?.target_book_id?.trim();
71
+ const targetBookId = targetBookIdRaw ? Number(targetBookIdRaw) : bookId;
72
+ if (!targetBookId) {
73
+ return {
74
+ content: [{ type: "text", text: JSON.stringify({ error: "target_book_id 必须为有效数字 / target_book_id must be a valid number" }, null, 2) }],
75
+ isError: true,
76
+ };
77
+ }
78
+ // target_uuid 留空 → null(移动到目标库根目录)
79
+ const targetUuid = args?.target_uuid?.trim() || null;
80
+ const body = {
81
+ book_id: bookId,
82
+ node_uuid: args.node_uuid,
83
+ target_uuid: targetUuid,
84
+ action: args?.action?.trim() || "prependChild",
85
+ target_book_id: targetBookId,
86
+ with_children: args?.with_children ?? true,
87
+ insert_to_catalog: args?.insert_to_catalog ?? true,
88
+ };
89
+ const url = "https://www.yuque.com/api/catalog_nodes/move";
90
+ const result = await webRequest(url, {
91
+ method: "PUT",
92
+ body,
93
+ referer: MOVE_REFERER,
94
+ });
95
+ if (isErrorResult(result))
96
+ return result;
97
+ return {
98
+ content: [{ type: "text", text: JSON.stringify({
99
+ success: true,
100
+ book_id: bookId,
101
+ target_book_id: targetBookId,
102
+ node_uuid: args.node_uuid,
103
+ target_uuid: targetUuid,
104
+ action: body.action,
105
+ with_children: body.with_children,
106
+ cross_repo: targetBookId !== bookId,
107
+ message: `成功移动目录节点到目标位置(${targetBookId !== bookId ? "跨库" : "同库"}) / Successfully moved catalog node (${targetBookId !== bookId ? "cross-repo" : "same-repo"})`,
108
+ }, null, 2) }],
109
+ };
110
+ },
111
+ };
112
+ //# sourceMappingURL=move-catalog-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"move-catalog-node.js","sourceRoot":"","sources":["../../src/web-doc/move-catalog-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE/F,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAE9C,MAAM,CAAC,MAAM,kBAAkB,GAAY;IACzC,IAAI,EAAE,6BAA6B;IACnC,WAAW,EACT,mFAAmF;QACnF,+BAA+B;QAC/B,kHAAkH;QAClH,0BAA0B;QAC1B,kCAAkC;IAEpC,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iFAAiF;aAC/F;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uCAAuC;aACrD;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6HAA6H;aAC3I;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mGAAm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AAU;wBACvB,MAAM,EAAE,IAAI,CAAC,MAAM;wBACnB,aAAa,EAAE,IAAI,CAAC,aAAa;wBACjC,UAAU,EAAE,YAAY,KAAK,MAAM;wBACnC,OAAO,EAAE,iBAAiB,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,wCAAwC,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,GAAG;qBAC/J,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SACf,CAAC;IACJ,CAAC;CACF,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yuque-ai-mcp",
3
- "version": "2.12.0",
4
- "description": "Full-featured Yuque MCP Server \u2014 62 fine-grained tools covering the entire Yuque OpenAPI",
3
+ "version": "2.12.1",
4
+ "description": "Full-featured Yuque MCP Server — 62 fine-grained tools covering the entire Yuque OpenAPI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
@@ -23,7 +23,7 @@
23
23
  "ai",
24
24
  "llm",
25
25
  "claude",
26
- "\u8bed\u96c0"
26
+ "语雀"
27
27
  ],
28
28
  "scripts": {
29
29
  "build": "tsc",
@@ -46,4 +46,4 @@
46
46
  "tsx": "^4.22.4",
47
47
  "typescript": "^5.4.0"
48
48
  }
49
- }
49
+ }