yuque-mcp-plus 0.2.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/CHANGELOG.md +32 -0
- package/README.en.md +853 -0
- package/README.md +882 -0
- package/RELEASE.md +105 -0
- package/package.json +46 -0
- package/src/config.js +37 -0
- package/src/index.js +17 -0
- package/src/server.js +55 -0
- package/src/tools.js +514 -0
- package/src/yuque-client.js +545 -0
package/src/tools.js
ADDED
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
function schemaProperty(type, description, extras = {}) {
|
|
2
|
+
return {
|
|
3
|
+
type,
|
|
4
|
+
description,
|
|
5
|
+
...extras
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function jsonText(value) {
|
|
10
|
+
return {
|
|
11
|
+
content: [
|
|
12
|
+
{
|
|
13
|
+
type: "text",
|
|
14
|
+
text: JSON.stringify(value, null, 2)
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function repoRefSchema() {
|
|
21
|
+
return {
|
|
22
|
+
repoId: schemaProperty("number", "Yuque repository ID."),
|
|
23
|
+
repoNamespace: schemaProperty("string", "Yuque repository namespace.")
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function registerAlias(aliases, aliasName, targetName) {
|
|
28
|
+
aliases[aliasName] = targetName;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const TOOL_DEFINITIONS = [
|
|
32
|
+
{
|
|
33
|
+
name: "yuque_request",
|
|
34
|
+
description: "Generic Yuque OpenAPI request passthrough for endpoints not wrapped by dedicated tools.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
method: schemaProperty("string", "HTTP method.", { enum: ["GET", "POST", "PUT", "DELETE", "PATCH"] }),
|
|
39
|
+
path: schemaProperty("string", "API path starting with /, for example /repos/123."),
|
|
40
|
+
params: {
|
|
41
|
+
type: "object",
|
|
42
|
+
description: "Optional query parameters."
|
|
43
|
+
},
|
|
44
|
+
body: {
|
|
45
|
+
type: "object",
|
|
46
|
+
description: "Optional JSON request body."
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
required: ["path"]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "yuque_multipart_request",
|
|
54
|
+
description: "Generic Yuque multipart request for upload-style endpoints such as attachment workflows.",
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {
|
|
58
|
+
method: schemaProperty("string", "HTTP method.", { enum: ["POST", "PUT", "PATCH"] }),
|
|
59
|
+
path: schemaProperty("string", "API path starting with /, for example /repos/123/resources."),
|
|
60
|
+
params: {
|
|
61
|
+
type: "object",
|
|
62
|
+
description: "Optional query parameters."
|
|
63
|
+
},
|
|
64
|
+
fields: {
|
|
65
|
+
type: "object",
|
|
66
|
+
description: "Optional multipart text fields."
|
|
67
|
+
},
|
|
68
|
+
files: {
|
|
69
|
+
type: "array",
|
|
70
|
+
description: "Files to upload as multipart form-data.",
|
|
71
|
+
items: {
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {
|
|
74
|
+
fieldName: schemaProperty("string", "Multipart field name."),
|
|
75
|
+
filePath: schemaProperty("string", "Absolute or workspace-local file path."),
|
|
76
|
+
filename: schemaProperty("string", "Optional override filename."),
|
|
77
|
+
contentType: schemaProperty("string", "Optional MIME type.")
|
|
78
|
+
},
|
|
79
|
+
required: ["fieldName", "filePath"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
required: ["path", "files"]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "yuque_hello",
|
|
88
|
+
description: "Call the Yuque hello endpoint.",
|
|
89
|
+
inputSchema: { type: "object", properties: {} }
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "yuque_get_user",
|
|
93
|
+
description: "Get the current Yuque user.",
|
|
94
|
+
inputSchema: { type: "object", properties: {} }
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "yuque_get_repos",
|
|
98
|
+
description: "List Yuque repositories for the current user or a specified user.",
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: "object",
|
|
101
|
+
properties: {
|
|
102
|
+
userId: schemaProperty("string", "Optional Yuque user ID."),
|
|
103
|
+
ownerType: schemaProperty("string", "Optional owner type.", { enum: ["user", "group"] }),
|
|
104
|
+
ownerLogin: schemaProperty("string", "Optional owner login. When provided, ownerType decides /users/{login}/repos or /groups/{login}/repos.")
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "yuque_list_groups",
|
|
110
|
+
description: "List groups or teams for the current user or a specified user.",
|
|
111
|
+
inputSchema: {
|
|
112
|
+
type: "object",
|
|
113
|
+
properties: {
|
|
114
|
+
userId: schemaProperty("number", "Optional Yuque user ID.")
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "yuque_get_repo",
|
|
120
|
+
description: "Get repository detail.",
|
|
121
|
+
inputSchema: {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: repoRefSchema()
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "yuque_get_default_repository",
|
|
128
|
+
description: "Resolve the default Yuque repository using server config or a fallback heuristic.",
|
|
129
|
+
inputSchema: { type: "object", properties: {} }
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "yuque_get_repository_toc_tree",
|
|
133
|
+
description: "Get the full repository TOC tree, including nested directories and docs.",
|
|
134
|
+
inputSchema: {
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
...repoRefSchema(),
|
|
138
|
+
repoNamespace: schemaProperty("string", "Yuque repository namespace, for example user/repo.")
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "yuque_get_docs",
|
|
144
|
+
description: "List docs in a repository.",
|
|
145
|
+
inputSchema: {
|
|
146
|
+
type: "object",
|
|
147
|
+
properties: {
|
|
148
|
+
...repoRefSchema(),
|
|
149
|
+
limit: schemaProperty("number", "Optional page size.", { minimum: 1, maximum: 100 }),
|
|
150
|
+
offset: schemaProperty("number", "Optional offset.", { minimum: 0 })
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "yuque_get_doc",
|
|
156
|
+
description: "Get doc detail by doc ID.",
|
|
157
|
+
inputSchema: {
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
docId: schemaProperty("number", "Yuque doc ID."),
|
|
161
|
+
...repoRefSchema()
|
|
162
|
+
},
|
|
163
|
+
required: ["docId"]
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "yuque_create_doc",
|
|
168
|
+
description: "Create a doc. If parentUuid is provided, the doc is attached under that TOC node.",
|
|
169
|
+
inputSchema: {
|
|
170
|
+
type: "object",
|
|
171
|
+
properties: {
|
|
172
|
+
...repoRefSchema(),
|
|
173
|
+
title: schemaProperty("string", "Doc title.", { minLength: 1 }),
|
|
174
|
+
body: schemaProperty("string", "Markdown or lake body."),
|
|
175
|
+
format: schemaProperty("string", "Doc format.", { enum: ["markdown", "lake", "html"] }),
|
|
176
|
+
slug: schemaProperty("string", "Optional slug."),
|
|
177
|
+
parentUuid: schemaProperty("string", "Optional TOC parent UUID.")
|
|
178
|
+
},
|
|
179
|
+
required: ["title"]
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "yuque_update_doc",
|
|
184
|
+
description: "Update an existing doc.",
|
|
185
|
+
inputSchema: {
|
|
186
|
+
type: "object",
|
|
187
|
+
properties: {
|
|
188
|
+
docId: schemaProperty("number", "Yuque doc ID."),
|
|
189
|
+
...repoRefSchema(),
|
|
190
|
+
title: schemaProperty("string", "Optional new title."),
|
|
191
|
+
body: schemaProperty("string", "Optional new body."),
|
|
192
|
+
format: schemaProperty("string", "Optional new format.", { enum: ["markdown", "lake", "html"] })
|
|
193
|
+
},
|
|
194
|
+
required: ["docId"]
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "yuque_move_document",
|
|
199
|
+
description: "Move a doc or TOC node to another parent by UUID.",
|
|
200
|
+
inputSchema: {
|
|
201
|
+
type: "object",
|
|
202
|
+
properties: {
|
|
203
|
+
docId: schemaProperty("number", "Doc ID. Used to resolve nodeUuid if nodeUuid is omitted."),
|
|
204
|
+
nodeUuid: schemaProperty("string", "Existing TOC node UUID."),
|
|
205
|
+
...repoRefSchema(),
|
|
206
|
+
parentUuid: schemaProperty("string", "Target parent UUID."),
|
|
207
|
+
targetUuid: schemaProperty("string", "Alias of parentUuid."),
|
|
208
|
+
actionMode: schemaProperty("string", "TOC action mode.", { enum: ["child", "sibling"] }),
|
|
209
|
+
position: schemaProperty("string", "Insert position.", { enum: ["append", "prepend"] })
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "yuque_create_toc_node",
|
|
215
|
+
description: "Create a TITLE or LINK node in the repository TOC tree.",
|
|
216
|
+
inputSchema: {
|
|
217
|
+
type: "object",
|
|
218
|
+
properties: {
|
|
219
|
+
...repoRefSchema(),
|
|
220
|
+
title: schemaProperty("string", "Node title.", { minLength: 1 }),
|
|
221
|
+
nodeType: schemaProperty("string", "Node type.", { enum: ["TITLE", "LINK"] }),
|
|
222
|
+
url: schemaProperty("string", "Optional URL when nodeType is LINK."),
|
|
223
|
+
parentUuid: schemaProperty("string", "Target parent UUID."),
|
|
224
|
+
targetUuid: schemaProperty("string", "Alias of parentUuid."),
|
|
225
|
+
actionMode: schemaProperty("string", "TOC action mode.", { enum: ["child", "sibling"] }),
|
|
226
|
+
position: schemaProperty("string", "Insert position.", { enum: ["append", "prepend"] })
|
|
227
|
+
},
|
|
228
|
+
required: ["title"]
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "yuque_delete_toc_node",
|
|
233
|
+
description: "Delete a TITLE or LINK node from the repository TOC tree.",
|
|
234
|
+
inputSchema: {
|
|
235
|
+
type: "object",
|
|
236
|
+
properties: {
|
|
237
|
+
...repoRefSchema(),
|
|
238
|
+
nodeUuid: schemaProperty("string", "Existing TOC node UUID."),
|
|
239
|
+
parentUuid: schemaProperty("string", "Optional parent TOC UUID. If omitted, the server resolves the delete strategy from the TOC tree."),
|
|
240
|
+
targetUuid: schemaProperty("string", "Alias of parentUuid."),
|
|
241
|
+
actionMode: schemaProperty("string", "Optional TOC action mode override.", { enum: ["child", "sibling"] })
|
|
242
|
+
},
|
|
243
|
+
required: ["nodeUuid"]
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "yuque_delete_doc",
|
|
248
|
+
description: "Delete a doc by ID.",
|
|
249
|
+
inputSchema: {
|
|
250
|
+
type: "object",
|
|
251
|
+
properties: {
|
|
252
|
+
docId: schemaProperty("number", "Yuque doc ID."),
|
|
253
|
+
...repoRefSchema()
|
|
254
|
+
},
|
|
255
|
+
required: ["docId"]
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "yuque_search",
|
|
260
|
+
description: "Search Yuque content.",
|
|
261
|
+
inputSchema: {
|
|
262
|
+
type: "object",
|
|
263
|
+
properties: {
|
|
264
|
+
query: schemaProperty("string", "Search query.", { minLength: 1 }),
|
|
265
|
+
type: schemaProperty("string", "Search type.", { enum: ["DOC", "BOOK", "USER"] }),
|
|
266
|
+
page: schemaProperty("number", "Page number.", { minimum: 1 }),
|
|
267
|
+
repoId: schemaProperty("number", "Optional repository ID filter.")
|
|
268
|
+
},
|
|
269
|
+
required: ["query"]
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "yuque_create_repo",
|
|
274
|
+
description: "Create a repository.",
|
|
275
|
+
inputSchema: {
|
|
276
|
+
type: "object",
|
|
277
|
+
properties: {
|
|
278
|
+
name: schemaProperty("string", "Repository name.", { minLength: 1 }),
|
|
279
|
+
slug: schemaProperty("string", "Optional repository slug."),
|
|
280
|
+
description: schemaProperty("string", "Optional repository description."),
|
|
281
|
+
isPublic: schemaProperty("boolean", "Whether the repository is public."),
|
|
282
|
+
ownerType: schemaProperty("string", "Owner type.", { enum: ["user", "group"] }),
|
|
283
|
+
ownerLogin: schemaProperty("string", "Owner login for user or group repo creation.")
|
|
284
|
+
},
|
|
285
|
+
required: ["name"]
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: "yuque_update_repo",
|
|
290
|
+
description: "Update repository metadata.",
|
|
291
|
+
inputSchema: {
|
|
292
|
+
type: "object",
|
|
293
|
+
properties: {
|
|
294
|
+
...repoRefSchema(),
|
|
295
|
+
name: schemaProperty("string", "Repository name."),
|
|
296
|
+
slug: schemaProperty("string", "Repository slug."),
|
|
297
|
+
description: schemaProperty("string", "Repository description."),
|
|
298
|
+
isPublic: schemaProperty("boolean", "Whether the repository is public.")
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "yuque_delete_repo",
|
|
304
|
+
description: "Delete a repository.",
|
|
305
|
+
inputSchema: {
|
|
306
|
+
type: "object",
|
|
307
|
+
properties: repoRefSchema()
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: "yuque_update_repository_toc",
|
|
312
|
+
description: "Send a raw TOC update payload to the repository TOC API.",
|
|
313
|
+
inputSchema: {
|
|
314
|
+
type: "object",
|
|
315
|
+
properties: {
|
|
316
|
+
...repoRefSchema(),
|
|
317
|
+
payload: {
|
|
318
|
+
type: "object",
|
|
319
|
+
description: "Raw TOC update payload."
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
required: ["payload"]
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: "yuque_list_doc_versions",
|
|
327
|
+
description: "List all versions of a document.",
|
|
328
|
+
inputSchema: {
|
|
329
|
+
type: "object",
|
|
330
|
+
properties: {
|
|
331
|
+
docId: schemaProperty("number", "Yuque doc ID.")
|
|
332
|
+
},
|
|
333
|
+
required: ["docId"]
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "yuque_get_doc_version",
|
|
338
|
+
description: "Get a specific document version.",
|
|
339
|
+
inputSchema: {
|
|
340
|
+
type: "object",
|
|
341
|
+
properties: {
|
|
342
|
+
versionId: schemaProperty("number", "Yuque version ID.")
|
|
343
|
+
},
|
|
344
|
+
required: ["versionId"]
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: "yuque_list_group_members",
|
|
349
|
+
description: "List all members of a group or team.",
|
|
350
|
+
inputSchema: {
|
|
351
|
+
type: "object",
|
|
352
|
+
properties: {
|
|
353
|
+
login: schemaProperty("string", "Group login.")
|
|
354
|
+
},
|
|
355
|
+
required: ["login"]
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "yuque_update_group_member",
|
|
360
|
+
description: "Update a group member role.",
|
|
361
|
+
inputSchema: {
|
|
362
|
+
type: "object",
|
|
363
|
+
properties: {
|
|
364
|
+
login: schemaProperty("string", "Group login."),
|
|
365
|
+
userId: schemaProperty("number", "Yuque user ID."),
|
|
366
|
+
role: schemaProperty("number", "Role: 0 member, 1 admin, 2 owner.")
|
|
367
|
+
},
|
|
368
|
+
required: ["login", "userId", "role"]
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
name: "yuque_remove_group_member",
|
|
373
|
+
description: "Remove a member from a group.",
|
|
374
|
+
inputSchema: {
|
|
375
|
+
type: "object",
|
|
376
|
+
properties: {
|
|
377
|
+
login: schemaProperty("string", "Group login."),
|
|
378
|
+
userId: schemaProperty("number", "Yuque user ID.")
|
|
379
|
+
},
|
|
380
|
+
required: ["login", "userId"]
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: "yuque_group_stats",
|
|
385
|
+
description: "Get overall statistics for a group.",
|
|
386
|
+
inputSchema: {
|
|
387
|
+
type: "object",
|
|
388
|
+
properties: {
|
|
389
|
+
login: schemaProperty("string", "Group login.")
|
|
390
|
+
},
|
|
391
|
+
required: ["login"]
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "yuque_group_member_stats",
|
|
396
|
+
description: "Get member statistics for a group.",
|
|
397
|
+
inputSchema: {
|
|
398
|
+
type: "object",
|
|
399
|
+
properties: {
|
|
400
|
+
login: schemaProperty("string", "Group login.")
|
|
401
|
+
},
|
|
402
|
+
required: ["login"]
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
name: "yuque_group_book_stats",
|
|
407
|
+
description: "Get repository statistics for a group.",
|
|
408
|
+
inputSchema: {
|
|
409
|
+
type: "object",
|
|
410
|
+
properties: {
|
|
411
|
+
login: schemaProperty("string", "Group login.")
|
|
412
|
+
},
|
|
413
|
+
required: ["login"]
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: "yuque_group_doc_stats",
|
|
418
|
+
description: "Get document statistics for a group.",
|
|
419
|
+
inputSchema: {
|
|
420
|
+
type: "object",
|
|
421
|
+
properties: {
|
|
422
|
+
login: schemaProperty("string", "Group login.")
|
|
423
|
+
},
|
|
424
|
+
required: ["login"]
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
];
|
|
428
|
+
|
|
429
|
+
const TOOL_HANDLERS = {
|
|
430
|
+
yuque_request: async (args, client) => jsonText(await client.rawRequest(args)),
|
|
431
|
+
yuque_multipart_request: async (args, client) => jsonText(await client.multipartRequest(args)),
|
|
432
|
+
yuque_hello: async (_args, client) => jsonText(await client.hello()),
|
|
433
|
+
yuque_get_user: async (_args, client) => jsonText(await client.getUser()),
|
|
434
|
+
yuque_get_repos: async (args, client) =>
|
|
435
|
+
jsonText(await client.getRepos(args.ownerLogin ? args : args.userId)),
|
|
436
|
+
yuque_list_groups: async (args, client) => jsonText(await client.listGroups(args.userId)),
|
|
437
|
+
yuque_get_repo: async (args, client) => jsonText(await client.getRepo(args)),
|
|
438
|
+
yuque_get_default_repository: async (_args, client) => jsonText(await client.getDefaultRepository()),
|
|
439
|
+
yuque_get_repository_toc_tree: async (args, client) => jsonText(await client.getRepositoryTocTree(args)),
|
|
440
|
+
yuque_get_docs: async (args, client) => jsonText(await client.getDocs(args, args)),
|
|
441
|
+
yuque_get_doc: async (args, client) => jsonText(await client.getDoc(args.docId, args)),
|
|
442
|
+
yuque_create_doc: async (args, client) => jsonText(await client.createDoc(args)),
|
|
443
|
+
yuque_update_doc: async (args, client) => jsonText(await client.updateDoc(args.docId, args)),
|
|
444
|
+
yuque_move_document: async (args, client) => jsonText(await client.moveDocument(args)),
|
|
445
|
+
yuque_create_toc_node: async (args, client) => jsonText(await client.createTocNode(args)),
|
|
446
|
+
yuque_delete_toc_node: async (args, client) => jsonText(await client.deleteTocNode(args)),
|
|
447
|
+
yuque_delete_doc: async (args, client) => {
|
|
448
|
+
await client.deleteDoc(args.docId, args);
|
|
449
|
+
return jsonText({ ok: true, docId: args.docId });
|
|
450
|
+
},
|
|
451
|
+
yuque_search: async (args, client) => jsonText(await client.search(args)),
|
|
452
|
+
yuque_create_repo: async (args, client) => jsonText(await client.createRepo(args)),
|
|
453
|
+
yuque_update_repo: async (args, client) => jsonText(await client.updateRepo(args)),
|
|
454
|
+
yuque_delete_repo: async (args, client) => jsonText(await client.deleteRepo(args)),
|
|
455
|
+
yuque_update_repository_toc: async (args, client) => jsonText(await client.updateToc(args)),
|
|
456
|
+
yuque_list_doc_versions: async (args, client) => jsonText(await client.listDocVersions(args.docId)),
|
|
457
|
+
yuque_get_doc_version: async (args, client) => jsonText(await client.getDocVersion(args.versionId)),
|
|
458
|
+
yuque_list_group_members: async (args, client) => jsonText(await client.listGroupMembers(args.login)),
|
|
459
|
+
yuque_update_group_member: async (args, client) => jsonText(await client.updateGroupMember(args.login, args.userId, args.role)),
|
|
460
|
+
yuque_remove_group_member: async (args, client) => {
|
|
461
|
+
await client.removeGroupMember(args.login, args.userId);
|
|
462
|
+
return jsonText({ ok: true, login: args.login, userId: args.userId });
|
|
463
|
+
},
|
|
464
|
+
yuque_group_stats: async (args, client) => jsonText(await client.getGroupStats(args.login)),
|
|
465
|
+
yuque_group_member_stats: async (args, client) => jsonText(await client.getGroupMemberStats(args.login)),
|
|
466
|
+
yuque_group_book_stats: async (args, client) => jsonText(await client.getGroupBookStats(args.login)),
|
|
467
|
+
yuque_group_doc_stats: async (args, client) => jsonText(await client.getGroupDocStats(args.login))
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
const TOOL_ALIASES = {};
|
|
471
|
+
|
|
472
|
+
registerAlias(TOOL_ALIASES, "yuque_list_repos", "yuque_get_repos");
|
|
473
|
+
registerAlias(TOOL_ALIASES, "yuque_list_docs", "yuque_get_docs");
|
|
474
|
+
registerAlias(TOOL_ALIASES, "yuque_get_toc", "yuque_get_repository_toc_tree");
|
|
475
|
+
registerAlias(TOOL_ALIASES, "yuque_update_toc", "yuque_update_repository_toc");
|
|
476
|
+
|
|
477
|
+
export const TOOLS = [
|
|
478
|
+
...TOOL_DEFINITIONS,
|
|
479
|
+
{
|
|
480
|
+
name: "yuque_list_repos",
|
|
481
|
+
description: "Alias of yuque_get_repos for compatibility with official naming.",
|
|
482
|
+
inputSchema: TOOL_DEFINITIONS.find((tool) => tool.name === "yuque_get_repos").inputSchema
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
name: "yuque_list_docs",
|
|
486
|
+
description: "Alias of yuque_get_docs for compatibility with official naming.",
|
|
487
|
+
inputSchema: TOOL_DEFINITIONS.find((tool) => tool.name === "yuque_get_docs").inputSchema
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: "yuque_get_toc",
|
|
491
|
+
description: "Alias of yuque_get_repository_toc_tree for compatibility with official naming.",
|
|
492
|
+
inputSchema: TOOL_DEFINITIONS.find((tool) => tool.name === "yuque_get_repository_toc_tree").inputSchema
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
name: "yuque_update_toc",
|
|
496
|
+
description: "Alias of yuque_update_repository_toc for compatibility with official naming.",
|
|
497
|
+
inputSchema: TOOL_DEFINITIONS.find((tool) => tool.name === "yuque_update_repository_toc").inputSchema
|
|
498
|
+
}
|
|
499
|
+
];
|
|
500
|
+
|
|
501
|
+
export function resolveToolName(name) {
|
|
502
|
+
return TOOL_ALIASES[name] || name;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export async function handleTool(name, args, client) {
|
|
506
|
+
const resolvedName = resolveToolName(name);
|
|
507
|
+
const handler = TOOL_HANDLERS[resolvedName];
|
|
508
|
+
|
|
509
|
+
if (!handler) {
|
|
510
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return handler(args, client);
|
|
514
|
+
}
|