dingtalk-wiki 1.1.4 → 1.1.5
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/index.js +96 -43
- package/package.json +1 -1
- package/skill/SKILL.md +7 -1
package/index.js
CHANGED
|
@@ -417,6 +417,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
417
417
|
workspace_id: {
|
|
418
418
|
type: 'string',
|
|
419
419
|
description: '知识库工作空间 ID'
|
|
420
|
+
},
|
|
421
|
+
operator_id: {
|
|
422
|
+
type: 'string',
|
|
423
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
420
424
|
}
|
|
421
425
|
},
|
|
422
426
|
required: ['workspace_id']
|
|
@@ -434,7 +438,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
434
438
|
},
|
|
435
439
|
parent_node_id: {
|
|
436
440
|
type: 'string',
|
|
437
|
-
description: '父节点 ID
|
|
441
|
+
description: '父节点 ID(不传则列出根目录节点)'
|
|
442
|
+
},
|
|
443
|
+
operator_id: {
|
|
444
|
+
type: 'string',
|
|
445
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
438
446
|
}
|
|
439
447
|
},
|
|
440
448
|
required: ['workspace_id']
|
|
@@ -456,9 +464,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
456
464
|
},
|
|
457
465
|
doc_type: {
|
|
458
466
|
type: 'string',
|
|
459
|
-
description: '
|
|
460
|
-
|
|
461
|
-
|
|
467
|
+
description: '文档类型,可选: DOC / WORKBOOK / MIND / FOLDER(默认 DOC)'
|
|
468
|
+
},
|
|
469
|
+
operator_id: {
|
|
470
|
+
type: 'string',
|
|
471
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
462
472
|
},
|
|
463
473
|
parent_node_id: {
|
|
464
474
|
type: 'string',
|
|
@@ -481,6 +491,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
481
491
|
node_id: {
|
|
482
492
|
type: 'string',
|
|
483
493
|
description: '节点 ID'
|
|
494
|
+
},
|
|
495
|
+
operator_id: {
|
|
496
|
+
type: 'string',
|
|
497
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
484
498
|
}
|
|
485
499
|
},
|
|
486
500
|
required: ['node_id']
|
|
@@ -488,7 +502,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
488
502
|
},
|
|
489
503
|
{
|
|
490
504
|
name: 'search_wiki',
|
|
491
|
-
description: '
|
|
505
|
+
description: '搜索知识库(POST /v2.0/doc/search)',
|
|
492
506
|
inputSchema: {
|
|
493
507
|
type: 'object',
|
|
494
508
|
properties: {
|
|
@@ -499,6 +513,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
499
513
|
workspace_id: {
|
|
500
514
|
type: 'string',
|
|
501
515
|
description: '指定知识库 ID(可选)'
|
|
516
|
+
},
|
|
517
|
+
max_results: {
|
|
518
|
+
type: 'number',
|
|
519
|
+
description: '返回条数上限(默认 10,最大 20)'
|
|
520
|
+
},
|
|
521
|
+
next_token: {
|
|
522
|
+
type: 'string',
|
|
523
|
+
description: '分页游标(上次返回的 nextToken)'
|
|
524
|
+
},
|
|
525
|
+
operator_id: {
|
|
526
|
+
type: 'string',
|
|
527
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
502
528
|
}
|
|
503
529
|
},
|
|
504
530
|
required: ['keyword']
|
|
@@ -894,8 +920,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
894
920
|
}
|
|
895
921
|
|
|
896
922
|
case 'get_wiki_workspace': {
|
|
897
|
-
const { workspace_id } = args;
|
|
898
|
-
|
|
923
|
+
const { workspace_id, operator_id } = args;
|
|
924
|
+
if (operator_id) {
|
|
925
|
+
dingtalk.setOperatorId(operator_id);
|
|
926
|
+
}
|
|
899
927
|
const result = await dingtalk.wikiRequest('workspaces');
|
|
900
928
|
const workspaces = result.workspaces || [];
|
|
901
929
|
const workspace = workspaces.find(ws => ws.workspaceId === workspace_id);
|
|
@@ -1066,24 +1094,65 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1066
1094
|
}
|
|
1067
1095
|
|
|
1068
1096
|
case 'get_wiki_node': {
|
|
1069
|
-
const { node_id } = args;
|
|
1070
|
-
|
|
1097
|
+
const { node_id, operator_id } = args;
|
|
1098
|
+
if (operator_id) {
|
|
1099
|
+
dingtalk.setOperatorId(operator_id);
|
|
1100
|
+
}
|
|
1101
|
+
const result = await dingtalk.docRequest('GET', `/v2.0/wiki/nodes/${node_id}`, {
|
|
1102
|
+
operatorId: operator_id || null
|
|
1103
|
+
});
|
|
1104
|
+
const node = result;
|
|
1105
|
+
let output = `📄 节点详情\n\n`;
|
|
1106
|
+
output += `名称: ${node.name || '-'}\n`;
|
|
1107
|
+
output += `ID: ${node.id || node.nodeId || '-'}\n`;
|
|
1108
|
+
output += `类型: ${node.type || '-'}\n`;
|
|
1109
|
+
output += `知识库 ID: ${node.workspaceId || '-'}\n`;
|
|
1110
|
+
output += `父节点: ${node.parentNodeId || '-'}\n`;
|
|
1111
|
+
output += `创建时间: ${node.createdTime || '-'}\n`;
|
|
1112
|
+
output += `修改时间: ${node.modifiedTime || '-'}\n`;
|
|
1113
|
+
output += `URL: ${node.url || '-'}\n`;
|
|
1114
|
+
if (node.document) {
|
|
1115
|
+
output += `文档信息: ${JSON.stringify(node.document)}\n`;
|
|
1116
|
+
}
|
|
1071
1117
|
return {
|
|
1072
|
-
content: [{
|
|
1073
|
-
type: 'text',
|
|
1074
|
-
text: `📄 节点 ID: ${node_id}\n\n请使用 list_wiki_nodes 获取节点列表,然后通过节点链接访问详情。`
|
|
1075
|
-
}]
|
|
1118
|
+
content: [{ type: 'text', text: output }]
|
|
1076
1119
|
};
|
|
1077
1120
|
}
|
|
1078
1121
|
|
|
1079
1122
|
case 'search_wiki': {
|
|
1080
|
-
const { keyword, workspace_id } = args;
|
|
1081
|
-
|
|
1123
|
+
const { keyword, workspace_id, max_results = 10, next_token, operator_id } = args;
|
|
1124
|
+
if (operator_id) {
|
|
1125
|
+
dingtalk.setOperatorId(operator_id);
|
|
1126
|
+
}
|
|
1127
|
+
const body = {
|
|
1128
|
+
keyword,
|
|
1129
|
+
maxResults: Math.min(max_results, 20)
|
|
1130
|
+
};
|
|
1131
|
+
if (next_token) {
|
|
1132
|
+
body.nextToken = next_token;
|
|
1133
|
+
}
|
|
1134
|
+
if (workspace_id) {
|
|
1135
|
+
body.option = { workspaceIds: [workspace_id] };
|
|
1136
|
+
}
|
|
1137
|
+
const result = await dingtalk.docRequest('POST', '/v2.0/doc/search', {
|
|
1138
|
+
operatorId: operator_id || null,
|
|
1139
|
+
data: body
|
|
1140
|
+
});
|
|
1141
|
+
const items = result.items || [];
|
|
1142
|
+
let output = `🔍 搜索 "${keyword}" (${items.length}条)\n\n`;
|
|
1143
|
+
items.forEach((item, i) => {
|
|
1144
|
+
output += `${i + 1}. ${item.name}\n`;
|
|
1145
|
+
output += ` 知识库: ${item.workspaceId}\n`;
|
|
1146
|
+
output += ` 链接: ${item.url}\n\n`;
|
|
1147
|
+
});
|
|
1148
|
+
if (!items.length) {
|
|
1149
|
+
output += '没有找到匹配的知识库。\n';
|
|
1150
|
+
}
|
|
1151
|
+
if (result.nextToken) {
|
|
1152
|
+
output += `--- 更多结果, nextToken: ${result.nextToken} ---\n`;
|
|
1153
|
+
}
|
|
1082
1154
|
return {
|
|
1083
|
-
content: [{
|
|
1084
|
-
type: 'text',
|
|
1085
|
-
text: `🔍 搜索知识库: ${keyword}\n\n搜索功能需要 Wiki.Search 权限。\n\n请直接访问知识库网页版进行搜索:\nhttps://alidocs.dingtalk.com/i/spaces/${workspace_id || ''}/search?keyword=${encodeURIComponent(keyword)}`
|
|
1086
|
-
}]
|
|
1155
|
+
content: [{ type: 'text', text: output }]
|
|
1087
1156
|
};
|
|
1088
1157
|
}
|
|
1089
1158
|
|
|
@@ -1165,20 +1234,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1165
1234
|
if (operator_id) {
|
|
1166
1235
|
dingtalk.setOperatorId(operator_id);
|
|
1167
1236
|
}
|
|
1168
|
-
const opId = await dingtalk.resolveOperatorId(operator_id || null);
|
|
1169
1237
|
await dingtalk.docRequest('POST', `/v1.0/doc/suites/documents/${docKey}/overwriteContent`, {
|
|
1170
|
-
operatorId:
|
|
1171
|
-
data: {
|
|
1172
|
-
operatorId: opId,
|
|
1173
|
-
content,
|
|
1174
|
-
contentType: 'markdown'
|
|
1175
|
-
}
|
|
1238
|
+
operatorId: operator_id || null,
|
|
1239
|
+
data: { content, contentType: 'markdown' }
|
|
1176
1240
|
});
|
|
1177
1241
|
return {
|
|
1178
|
-
content: [{
|
|
1179
|
-
type: 'text',
|
|
1180
|
-
text: '✅ 文档内容已更新'
|
|
1181
|
-
}]
|
|
1242
|
+
content: [{ type: 'text', text: '✅ 文档内容已更新' }]
|
|
1182
1243
|
};
|
|
1183
1244
|
}
|
|
1184
1245
|
|
|
@@ -1187,19 +1248,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1187
1248
|
if (operator_id) {
|
|
1188
1249
|
dingtalk.setOperatorId(operator_id);
|
|
1189
1250
|
}
|
|
1190
|
-
const opId = await dingtalk.resolveOperatorId(operator_id || null);
|
|
1191
1251
|
await dingtalk.docRequest('PATCH', `/v1.0/doc/workspaces/${workspace_id}/docs/${node_id}`, {
|
|
1192
|
-
operatorId:
|
|
1193
|
-
data: {
|
|
1194
|
-
name,
|
|
1195
|
-
operatorId: opId
|
|
1196
|
-
}
|
|
1252
|
+
operatorId: operator_id || null,
|
|
1253
|
+
data: { name }
|
|
1197
1254
|
});
|
|
1198
1255
|
return {
|
|
1199
|
-
content: [{
|
|
1200
|
-
type: 'text',
|
|
1201
|
-
text: `✅ 文档已重命名为: ${name}`
|
|
1202
|
-
}]
|
|
1256
|
+
content: [{ type: 'text', text: `✅ 文档已重命名为: ${name}` }]
|
|
1203
1257
|
};
|
|
1204
1258
|
}
|
|
1205
1259
|
|
|
@@ -1208,9 +1262,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1208
1262
|
if (operator_id) {
|
|
1209
1263
|
dingtalk.setOperatorId(operator_id);
|
|
1210
1264
|
}
|
|
1211
|
-
const opId = await dingtalk.resolveOperatorId(operator_id || null);
|
|
1212
1265
|
await dingtalk.docRequest('DELETE', `/v1.0/doc/workspaces/${workspace_id}/docs/${node_id}`, {
|
|
1213
|
-
operatorId:
|
|
1266
|
+
operatorId: operator_id || null
|
|
1214
1267
|
});
|
|
1215
1268
|
return {
|
|
1216
1269
|
content: [{
|
|
@@ -1362,7 +1415,7 @@ async function main() {
|
|
|
1362
1415
|
const transport = new StdioServerTransport();
|
|
1363
1416
|
await server.connect(transport);
|
|
1364
1417
|
console.error('钉钉 Wiki MCP Server 已启动 v2.0');
|
|
1365
|
-
console.error(`Config
|
|
1418
|
+
console.error(`Config via DINGTALK_WIKI_CONFIG env var`);
|
|
1366
1419
|
}
|
|
1367
1420
|
|
|
1368
1421
|
main().catch(console.error);
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -100,11 +100,17 @@ mcporter call dingtalk-wiki.delete_wiki_doc \
|
|
|
100
100
|
workspace_id="your_workspace_id" \
|
|
101
101
|
node_id="your_node_id"
|
|
102
102
|
|
|
103
|
-
#
|
|
103
|
+
# 搜索知识库
|
|
104
104
|
mcporter call dingtalk-wiki.search_wiki keyword="项目规划"
|
|
105
105
|
|
|
106
106
|
# 在指定知识库内搜索
|
|
107
107
|
mcporter call dingtalk-wiki.search_wiki keyword="项目规划" workspace_id="your_workspace_id"
|
|
108
|
+
|
|
109
|
+
# 自定义返回条数
|
|
110
|
+
mcporter call dingtalk-wiki.search_wiki keyword="项目规划" max_results=5
|
|
111
|
+
|
|
112
|
+
# 分页搜索
|
|
113
|
+
mcporter call dingtalk-wiki.search_wiki keyword="项目规划" next_token="your_next_token"
|
|
108
114
|
```
|
|
109
115
|
|
|
110
116
|
### AI 表格(Notable)
|