dingtalk-wiki 1.1.2 → 1.1.4
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 +0 -4
- package/README.zh-CN.md +0 -4
- package/docs/clients/mcporter.md +0 -2
- package/index.js +490 -0
- package/package.json +1 -1
- package/skill/SKILL.md +62 -0
package/README.md
CHANGED
|
@@ -223,7 +223,6 @@ When a new project starts, automation can create a standard folder tree such as:
|
|
|
223
223
|
If you have registered this server in your MCP client config under the name `dingtalk-wiki`:
|
|
224
224
|
|
|
225
225
|
```bash
|
|
226
|
-
mcporter call dingtalk-wiki.show_config
|
|
227
226
|
mcporter call dingtalk-wiki.list_wiki_workspaces
|
|
228
227
|
mcporter call dingtalk-wiki.list_wiki_nodes workspace_id="your_workspace_id"
|
|
229
228
|
mcporter call dingtalk-wiki.create_wiki_doc workspace_id="your_workspace_id" name="Weekly Summary" doc_type="DOC"
|
|
@@ -235,7 +234,6 @@ mcporter call dingtalk-wiki.get_user_info userid="your_user_id"
|
|
|
235
234
|
If you want to run the server directly without pre-registering it, call the tool names directly:
|
|
236
235
|
|
|
237
236
|
```bash
|
|
238
|
-
mcporter call --stdio "node ./index.js" show_config
|
|
239
237
|
mcporter call --stdio "node ./index.js" list_wiki_workspaces
|
|
240
238
|
mcporter call --stdio "node ./index.js" list_wiki_nodes workspace_id="your_workspace_id"
|
|
241
239
|
mcporter call --stdio "node ./index.js" create_wiki_doc workspace_id="your_workspace_id" name="Weekly Summary" doc_type="DOC"
|
|
@@ -245,8 +243,6 @@ mcporter call --stdio "node ./index.js" create_wiki_doc workspace_id="your_works
|
|
|
245
243
|
|
|
246
244
|
## Available MCP tools
|
|
247
245
|
|
|
248
|
-
- `set_operator`
|
|
249
|
-
- `show_config`
|
|
250
246
|
- `list_wiki_workspaces`
|
|
251
247
|
- `get_wiki_workspace`
|
|
252
248
|
- `list_wiki_nodes`
|
package/README.zh-CN.md
CHANGED
|
@@ -216,7 +216,6 @@ node index.js
|
|
|
216
216
|
如果你已经在 MCP client 里把这个 server 注册为 `dingtalk-wiki`:
|
|
217
217
|
|
|
218
218
|
```bash
|
|
219
|
-
mcporter call dingtalk-wiki.show_config
|
|
220
219
|
mcporter call dingtalk-wiki.list_wiki_workspaces
|
|
221
220
|
mcporter call dingtalk-wiki.list_wiki_nodes workspace_id="your_workspace_id"
|
|
222
221
|
mcporter call dingtalk-wiki.create_wiki_doc workspace_id="your_workspace_id" name="Weekly Summary" doc_type="DOC"
|
|
@@ -228,7 +227,6 @@ mcporter call dingtalk-wiki.get_user_info userid="your_user_id"
|
|
|
228
227
|
如果你不想预先注册 server,而是直接拉起它,那么工具名直接写裸工具名:
|
|
229
228
|
|
|
230
229
|
```bash
|
|
231
|
-
mcporter call --stdio "node ./index.js" show_config
|
|
232
230
|
mcporter call --stdio "node ./index.js" list_wiki_workspaces
|
|
233
231
|
mcporter call --stdio "node ./index.js" list_wiki_nodes workspace_id="your_workspace_id"
|
|
234
232
|
mcporter call --stdio "node ./index.js" create_wiki_doc workspace_id="your_workspace_id" name="Weekly Summary" doc_type="DOC"
|
|
@@ -238,8 +236,6 @@ mcporter call --stdio "node ./index.js" create_wiki_doc workspace_id="your_works
|
|
|
238
236
|
|
|
239
237
|
## 可用 MCP 工具
|
|
240
238
|
|
|
241
|
-
- `set_operator`
|
|
242
|
-
- `show_config`
|
|
243
239
|
- `list_wiki_workspaces`
|
|
244
240
|
- `get_wiki_workspace`
|
|
245
241
|
- `list_wiki_nodes`
|
package/docs/clients/mcporter.md
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
Use the server directly over stdio. In this mode, call the tool names directly:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
mcporter call --stdio "node /absolute/path/to/dingtalk-wiki-mcp/index.js" show_config
|
|
9
8
|
mcporter call --stdio "node /absolute/path/to/dingtalk-wiki-mcp/index.js" list_wiki_workspaces
|
|
10
9
|
mcporter call --stdio "node /absolute/path/to/dingtalk-wiki-mcp/index.js" create_wiki_doc workspace_id="your_workspace_id" name="Weekly Summary"
|
|
11
10
|
```
|
|
@@ -15,7 +14,6 @@ mcporter call --stdio "node /absolute/path/to/dingtalk-wiki-mcp/index.js" create
|
|
|
15
14
|
If you registered the server under the name `dingtalk-wiki`, then use namespaced calls:
|
|
16
15
|
|
|
17
16
|
```bash
|
|
18
|
-
mcporter call dingtalk-wiki.show_config
|
|
19
17
|
mcporter call dingtalk-wiki.list_wiki_workspaces
|
|
20
18
|
mcporter call dingtalk-wiki.create_wiki_doc workspace_id="your_workspace_id" name="Weekly Summary"
|
|
21
19
|
```
|
package/index.js
CHANGED
|
@@ -52,6 +52,64 @@ function loadEnvFile(filePath) {
|
|
|
52
52
|
return true;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
function getElementsText(elements) {
|
|
56
|
+
if (!elements || !Array.isArray(elements)) return '';
|
|
57
|
+
return elements.map(el => {
|
|
58
|
+
if (el.textRun?.content) return el.textRun.content;
|
|
59
|
+
if (el.paragraphRun?.richText?.elements) return getElementsText(el.paragraphRun.richText.elements);
|
|
60
|
+
return '';
|
|
61
|
+
}).join('');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function extractBlockText(block) {
|
|
65
|
+
const getText = () => {
|
|
66
|
+
switch (block.blockType) {
|
|
67
|
+
case 'paragraph':
|
|
68
|
+
return getElementsText(block.paragraph?.richText?.elements);
|
|
69
|
+
case 'heading': {
|
|
70
|
+
const level = block.heading?.headingType || 1;
|
|
71
|
+
const headingText = getElementsText(block.heading?.richText?.elements);
|
|
72
|
+
return `${'#'.repeat(level)} ${headingText}`;
|
|
73
|
+
}
|
|
74
|
+
case 'table': {
|
|
75
|
+
const table = block.table;
|
|
76
|
+
if (!table?.cells) return '[空表格]';
|
|
77
|
+
const cellTexts = table.cells.map(cell => {
|
|
78
|
+
const cellBlocks = cell.blocks || [];
|
|
79
|
+
return cellBlocks.map(cb => extractBlockText(cb)).join(' | ');
|
|
80
|
+
});
|
|
81
|
+
const colCount = table.columnsCount || (table.cells[0]?.blocks?.length || 1);
|
|
82
|
+
const rows = [];
|
|
83
|
+
let currentRow = [];
|
|
84
|
+
cellTexts.forEach((t, i) => {
|
|
85
|
+
currentRow.push(t);
|
|
86
|
+
if (currentRow.length === colCount) {
|
|
87
|
+
rows.push(currentRow.join(' | '));
|
|
88
|
+
currentRow = [];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (currentRow.length) rows.push(currentRow.join(' | '));
|
|
92
|
+
return rows.map(r => `| ${r} |`).join('\n');
|
|
93
|
+
}
|
|
94
|
+
case 'unorderedList':
|
|
95
|
+
return `• ${getElementsText(block.unorderedList?.richText?.elements)}`;
|
|
96
|
+
case 'orderedList':
|
|
97
|
+
return `1. ${getElementsText(block.orderedList?.richText?.elements)}`;
|
|
98
|
+
case 'blockquote':
|
|
99
|
+
return `> ${getElementsText(block.blockquote?.richText?.elements)}`;
|
|
100
|
+
case 'codeBlock':
|
|
101
|
+
return '```\n' + getElementsText(block.codeBlock?.richText?.elements) + '\n```';
|
|
102
|
+
case 'divider':
|
|
103
|
+
return '---';
|
|
104
|
+
case 'image':
|
|
105
|
+
return `[图片: ${block.image?.caption || ''}]`;
|
|
106
|
+
default:
|
|
107
|
+
return `[${block.blockType}] ${getElementsText(block.paragraph?.richText?.elements)}`;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
return getText();
|
|
111
|
+
}
|
|
112
|
+
|
|
55
113
|
const DOTENV_CANDIDATES = [
|
|
56
114
|
process.env.DINGTALK_WIKI_ENV_PATH,
|
|
57
115
|
path.join(process.cwd(), '.env'),
|
|
@@ -228,6 +286,33 @@ class DingTalkClient {
|
|
|
228
286
|
return this.operatorId;
|
|
229
287
|
}
|
|
230
288
|
|
|
289
|
+
async docRequest(method, pathName, { operatorId = null, data = null } = {}) {
|
|
290
|
+
const token = await this.getAccessToken();
|
|
291
|
+
const resolvedOperatorId = await this.resolveOperatorId(operatorId);
|
|
292
|
+
const url = `${DINGTALK_API_V2}${pathName}`;
|
|
293
|
+
|
|
294
|
+
try {
|
|
295
|
+
const response = await axios({
|
|
296
|
+
method,
|
|
297
|
+
url,
|
|
298
|
+
headers: {
|
|
299
|
+
'x-acs-dingtalk-access-token': token,
|
|
300
|
+
'Content-Type': 'application/json'
|
|
301
|
+
},
|
|
302
|
+
params: {
|
|
303
|
+
operatorId: resolvedOperatorId
|
|
304
|
+
},
|
|
305
|
+
data
|
|
306
|
+
});
|
|
307
|
+
return response.data;
|
|
308
|
+
} catch (error) {
|
|
309
|
+
if (error.response) {
|
|
310
|
+
throw new Error(`${error.response.data?.message || error.message} (code: ${error.response.data?.code})`);
|
|
311
|
+
}
|
|
312
|
+
throw error;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
231
316
|
async notableRequest(method, pathName, { operatorId = null, params = {}, data = null } = {}) {
|
|
232
317
|
const token = await this.getAccessToken();
|
|
233
318
|
const resolvedOperatorId = await this.resolveOperatorId(operatorId);
|
|
@@ -476,6 +561,255 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
476
561
|
required: ['userid']
|
|
477
562
|
}
|
|
478
563
|
},
|
|
564
|
+
{
|
|
565
|
+
name: 'get_wiki_doc_content',
|
|
566
|
+
description: '读取文档正文内容(返回 Block 结构,含标题、段落、表格等)',
|
|
567
|
+
inputSchema: {
|
|
568
|
+
type: 'object',
|
|
569
|
+
properties: {
|
|
570
|
+
doc_key: {
|
|
571
|
+
type: 'string',
|
|
572
|
+
description: '文档 docKey。wiki nodes 返回的 nodeId 本质是 dentryUuid,可直接用于此处'
|
|
573
|
+
},
|
|
574
|
+
operator_id: {
|
|
575
|
+
type: 'string',
|
|
576
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
required: ['doc_key']
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
name: 'update_wiki_doc_content',
|
|
584
|
+
description: '覆写文档正文内容(⚠️ 全量覆盖,不可撤销)',
|
|
585
|
+
inputSchema: {
|
|
586
|
+
type: 'object',
|
|
587
|
+
properties: {
|
|
588
|
+
doc_key: {
|
|
589
|
+
type: 'string',
|
|
590
|
+
description: '文档 docKey。wiki nodes 返回的 nodeId 本质是 dentryUuid,可直接用于此处'
|
|
591
|
+
},
|
|
592
|
+
content: {
|
|
593
|
+
type: 'string',
|
|
594
|
+
description: '要写入的 Markdown 内容'
|
|
595
|
+
},
|
|
596
|
+
operator_id: {
|
|
597
|
+
type: 'string',
|
|
598
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
required: ['doc_key', 'content']
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
name: 'rename_wiki_doc',
|
|
606
|
+
description: '重命名文档',
|
|
607
|
+
inputSchema: {
|
|
608
|
+
type: 'object',
|
|
609
|
+
properties: {
|
|
610
|
+
workspace_id: {
|
|
611
|
+
type: 'string',
|
|
612
|
+
description: '知识库工作空间 ID'
|
|
613
|
+
},
|
|
614
|
+
node_id: {
|
|
615
|
+
type: 'string',
|
|
616
|
+
description: '节点 ID(重命名的目标文档)'
|
|
617
|
+
},
|
|
618
|
+
name: {
|
|
619
|
+
type: 'string',
|
|
620
|
+
description: '新的文档名称'
|
|
621
|
+
},
|
|
622
|
+
operator_id: {
|
|
623
|
+
type: 'string',
|
|
624
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
required: ['workspace_id', 'node_id', 'name']
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
name: 'delete_wiki_doc',
|
|
632
|
+
description: '删除文档节点',
|
|
633
|
+
inputSchema: {
|
|
634
|
+
type: 'object',
|
|
635
|
+
properties: {
|
|
636
|
+
workspace_id: {
|
|
637
|
+
type: 'string',
|
|
638
|
+
description: '知识库工作空间 ID'
|
|
639
|
+
},
|
|
640
|
+
node_id: {
|
|
641
|
+
type: 'string',
|
|
642
|
+
description: '节点 ID(要删除的目标文档)'
|
|
643
|
+
},
|
|
644
|
+
operator_id: {
|
|
645
|
+
type: 'string',
|
|
646
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
required: ['workspace_id', 'node_id']
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
name: 'create_notable_record',
|
|
654
|
+
description: '在 AI 表格数据表中创建一条或多条记录',
|
|
655
|
+
inputSchema: {
|
|
656
|
+
type: 'object',
|
|
657
|
+
properties: {
|
|
658
|
+
base_id: {
|
|
659
|
+
type: 'string',
|
|
660
|
+
description: 'Notable baseId'
|
|
661
|
+
},
|
|
662
|
+
sheet_id: {
|
|
663
|
+
type: 'string',
|
|
664
|
+
description: '数据表 ID 或名称,可通过 list_notable_sheets 获取'
|
|
665
|
+
},
|
|
666
|
+
records: {
|
|
667
|
+
type: 'array',
|
|
668
|
+
description: '要创建的记录数组。每条记录为 { fields: { 字段名: 值 } }',
|
|
669
|
+
items: {
|
|
670
|
+
type: 'object',
|
|
671
|
+
properties: {
|
|
672
|
+
fields: {
|
|
673
|
+
type: 'object',
|
|
674
|
+
description: '字段名到字段值的映射'
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
required: ['fields']
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
operator_id: {
|
|
681
|
+
type: 'string',
|
|
682
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
required: ['base_id', 'sheet_id', 'records']
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
name: 'update_notable_record',
|
|
690
|
+
description: '更新 AI 表格数据表中的多条记录',
|
|
691
|
+
inputSchema: {
|
|
692
|
+
type: 'object',
|
|
693
|
+
properties: {
|
|
694
|
+
base_id: {
|
|
695
|
+
type: 'string',
|
|
696
|
+
description: 'Notable baseId'
|
|
697
|
+
},
|
|
698
|
+
sheet_id: {
|
|
699
|
+
type: 'string',
|
|
700
|
+
description: '数据表 ID 或名称'
|
|
701
|
+
},
|
|
702
|
+
records: {
|
|
703
|
+
type: 'array',
|
|
704
|
+
description: '要更新的记录数组。每条记录格式为 { id: "recordId", fields: { 字段名: 值 } }',
|
|
705
|
+
items: {
|
|
706
|
+
type: 'object',
|
|
707
|
+
properties: {
|
|
708
|
+
id: {
|
|
709
|
+
type: 'string',
|
|
710
|
+
description: '记录 ID'
|
|
711
|
+
},
|
|
712
|
+
fields: {
|
|
713
|
+
type: 'object',
|
|
714
|
+
description: '要更新的字段'
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
required: ['id', 'fields']
|
|
718
|
+
}
|
|
719
|
+
},
|
|
720
|
+
operator_id: {
|
|
721
|
+
type: 'string',
|
|
722
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
723
|
+
}
|
|
724
|
+
},
|
|
725
|
+
required: ['base_id', 'sheet_id', 'records']
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
name: 'delete_notable_record',
|
|
730
|
+
description: '删除 AI 表格数据表中的多条记录',
|
|
731
|
+
inputSchema: {
|
|
732
|
+
type: 'object',
|
|
733
|
+
properties: {
|
|
734
|
+
base_id: {
|
|
735
|
+
type: 'string',
|
|
736
|
+
description: 'Notable baseId'
|
|
737
|
+
},
|
|
738
|
+
sheet_id: {
|
|
739
|
+
type: 'string',
|
|
740
|
+
description: '数据表 ID 或名称'
|
|
741
|
+
},
|
|
742
|
+
record_ids: {
|
|
743
|
+
type: 'array',
|
|
744
|
+
description: '要删除的记录 ID 列表',
|
|
745
|
+
items: {
|
|
746
|
+
type: 'string'
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
operator_id: {
|
|
750
|
+
type: 'string',
|
|
751
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
required: ['base_id', 'sheet_id', 'record_ids']
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
name: 'create_notable_sheet',
|
|
759
|
+
description: '在 AI 表格中创建一个新的数据表',
|
|
760
|
+
inputSchema: {
|
|
761
|
+
type: 'object',
|
|
762
|
+
properties: {
|
|
763
|
+
base_id: {
|
|
764
|
+
type: 'string',
|
|
765
|
+
description: 'Notable baseId'
|
|
766
|
+
},
|
|
767
|
+
name: {
|
|
768
|
+
type: 'string',
|
|
769
|
+
description: '数据表名称'
|
|
770
|
+
},
|
|
771
|
+
fields: {
|
|
772
|
+
type: 'array',
|
|
773
|
+
description: '数据表字段配置(可选),格式: [{ name: "字段名", type: "字段类型", property: {} }]',
|
|
774
|
+
items: {
|
|
775
|
+
type: 'object',
|
|
776
|
+
properties: {
|
|
777
|
+
name: { type: 'string', description: '字段名' },
|
|
778
|
+
type: { type: 'string', description: '字段类型,如 Text, Number, Select 等' }
|
|
779
|
+
},
|
|
780
|
+
required: ['name', 'type']
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
operator_id: {
|
|
784
|
+
type: 'string',
|
|
785
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
required: ['base_id', 'name']
|
|
789
|
+
}
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
name: 'delete_notable_sheet',
|
|
793
|
+
description: '删除 AI 表格中的一个数据表',
|
|
794
|
+
inputSchema: {
|
|
795
|
+
type: 'object',
|
|
796
|
+
properties: {
|
|
797
|
+
base_id: {
|
|
798
|
+
type: 'string',
|
|
799
|
+
description: 'Notable baseId'
|
|
800
|
+
},
|
|
801
|
+
sheet_id: {
|
|
802
|
+
type: 'string',
|
|
803
|
+
description: '数据表 ID 或名称'
|
|
804
|
+
},
|
|
805
|
+
operator_id: {
|
|
806
|
+
type: 'string',
|
|
807
|
+
description: '操作者 unionid(不传则使用默认用户)'
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
required: ['base_id', 'sheet_id']
|
|
811
|
+
}
|
|
812
|
+
},
|
|
479
813
|
{
|
|
480
814
|
name: 'list_notable_sheets',
|
|
481
815
|
description: '读取 AI 表格 / Notable 的所有数据表。对于 .able 节点,直接使用 nodeId 作为 base_id。',
|
|
@@ -803,6 +1137,89 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
803
1137
|
};
|
|
804
1138
|
}
|
|
805
1139
|
|
|
1140
|
+
case 'get_wiki_doc_content': {
|
|
1141
|
+
const { doc_key: docKey, operator_id } = args;
|
|
1142
|
+
if (operator_id) {
|
|
1143
|
+
dingtalk.setOperatorId(operator_id);
|
|
1144
|
+
}
|
|
1145
|
+
const result = await dingtalk.docRequest('GET', `/v1.0/doc/suites/documents/${docKey}/blocks`, { operatorId: operator_id || null });
|
|
1146
|
+
const blocks = result.result?.data || [];
|
|
1147
|
+
let output = '';
|
|
1148
|
+
blocks.forEach((block) => {
|
|
1149
|
+
const text = extractBlockText(block);
|
|
1150
|
+
output += text + '\n\n';
|
|
1151
|
+
});
|
|
1152
|
+
if (!blocks.length) {
|
|
1153
|
+
output = '(文档为空或无可读内容)';
|
|
1154
|
+
}
|
|
1155
|
+
return {
|
|
1156
|
+
content: [{
|
|
1157
|
+
type: 'text',
|
|
1158
|
+
text: output.trim()
|
|
1159
|
+
}]
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
case 'update_wiki_doc_content': {
|
|
1164
|
+
const { doc_key: docKey, content, operator_id } = args;
|
|
1165
|
+
if (operator_id) {
|
|
1166
|
+
dingtalk.setOperatorId(operator_id);
|
|
1167
|
+
}
|
|
1168
|
+
const opId = await dingtalk.resolveOperatorId(operator_id || null);
|
|
1169
|
+
await dingtalk.docRequest('POST', `/v1.0/doc/suites/documents/${docKey}/overwriteContent`, {
|
|
1170
|
+
operatorId: opId,
|
|
1171
|
+
data: {
|
|
1172
|
+
operatorId: opId,
|
|
1173
|
+
content,
|
|
1174
|
+
contentType: 'markdown'
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
return {
|
|
1178
|
+
content: [{
|
|
1179
|
+
type: 'text',
|
|
1180
|
+
text: '✅ 文档内容已更新'
|
|
1181
|
+
}]
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
case 'rename_wiki_doc': {
|
|
1186
|
+
const { workspace_id, node_id, name, operator_id } = args;
|
|
1187
|
+
if (operator_id) {
|
|
1188
|
+
dingtalk.setOperatorId(operator_id);
|
|
1189
|
+
}
|
|
1190
|
+
const opId = await dingtalk.resolveOperatorId(operator_id || null);
|
|
1191
|
+
await dingtalk.docRequest('PATCH', `/v1.0/doc/workspaces/${workspace_id}/docs/${node_id}`, {
|
|
1192
|
+
operatorId: opId,
|
|
1193
|
+
data: {
|
|
1194
|
+
name,
|
|
1195
|
+
operatorId: opId
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
return {
|
|
1199
|
+
content: [{
|
|
1200
|
+
type: 'text',
|
|
1201
|
+
text: `✅ 文档已重命名为: ${name}`
|
|
1202
|
+
}]
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
case 'delete_wiki_doc': {
|
|
1207
|
+
const { workspace_id, node_id, operator_id } = args;
|
|
1208
|
+
if (operator_id) {
|
|
1209
|
+
dingtalk.setOperatorId(operator_id);
|
|
1210
|
+
}
|
|
1211
|
+
const opId = await dingtalk.resolveOperatorId(operator_id || null);
|
|
1212
|
+
await dingtalk.docRequest('DELETE', `/v1.0/doc/workspaces/${workspace_id}/docs/${node_id}`, {
|
|
1213
|
+
operatorId: opId
|
|
1214
|
+
});
|
|
1215
|
+
return {
|
|
1216
|
+
content: [{
|
|
1217
|
+
type: 'text',
|
|
1218
|
+
text: `✅ 文档已删除 (nodeId: ${node_id})`
|
|
1219
|
+
}]
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
|
|
806
1223
|
case 'list_notable_sheets': {
|
|
807
1224
|
const { base_id, operator_id } = args;
|
|
808
1225
|
const result = await dingtalk.notableRequest('GET', `/v1.0/notable/bases/${base_id}/sheets`, {
|
|
@@ -853,6 +1270,79 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
853
1270
|
};
|
|
854
1271
|
}
|
|
855
1272
|
|
|
1273
|
+
case 'create_notable_record': {
|
|
1274
|
+
const { base_id, sheet_id, records, operator_id } = args;
|
|
1275
|
+
const result = await dingtalk.notableRequest('POST', `/v1.0/notable/bases/${base_id}/sheets/${sheet_id}/records`, {
|
|
1276
|
+
operatorId: operator_id || null,
|
|
1277
|
+
data: { records }
|
|
1278
|
+
});
|
|
1279
|
+
return {
|
|
1280
|
+
content: [{
|
|
1281
|
+
type: 'text',
|
|
1282
|
+
text: `✅ 已创建 ${records.length} 条记录\n\n${JSON.stringify(result, null, 2)}`
|
|
1283
|
+
}]
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
case 'update_notable_record': {
|
|
1288
|
+
const { base_id, sheet_id, records, operator_id } = args;
|
|
1289
|
+
const result = await dingtalk.notableRequest('PUT', `/v1.0/notable/bases/${base_id}/sheets/${sheet_id}/records`, {
|
|
1290
|
+
operatorId: operator_id || null,
|
|
1291
|
+
data: { records }
|
|
1292
|
+
});
|
|
1293
|
+
return {
|
|
1294
|
+
content: [{
|
|
1295
|
+
type: 'text',
|
|
1296
|
+
text: `✅ 已更新 ${records.length} 条记录\n\n${JSON.stringify(result, null, 2)}`
|
|
1297
|
+
}]
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
case 'delete_notable_record': {
|
|
1302
|
+
const { base_id, sheet_id, record_ids, operator_id } = args;
|
|
1303
|
+
const result = await dingtalk.notableRequest('DELETE', `/v1.0/notable/bases/${base_id}/sheets/${sheet_id}/records`, {
|
|
1304
|
+
operatorId: operator_id || null,
|
|
1305
|
+
data: { recordIds: record_ids }
|
|
1306
|
+
});
|
|
1307
|
+
return {
|
|
1308
|
+
content: [{
|
|
1309
|
+
type: 'text',
|
|
1310
|
+
text: `✅ 已删除 ${record_ids.length} 条记录`
|
|
1311
|
+
}]
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
case 'create_notable_sheet': {
|
|
1316
|
+
const { base_id, name, fields, operator_id } = args;
|
|
1317
|
+
const data = { name };
|
|
1318
|
+
if (fields) {
|
|
1319
|
+
data.fields = fields;
|
|
1320
|
+
}
|
|
1321
|
+
const result = await dingtalk.notableRequest('POST', `/v1.0/notable/bases/${base_id}/sheets`, {
|
|
1322
|
+
operatorId: operator_id || null,
|
|
1323
|
+
data
|
|
1324
|
+
});
|
|
1325
|
+
return {
|
|
1326
|
+
content: [{
|
|
1327
|
+
type: 'text',
|
|
1328
|
+
text: `✅ 数据表已创建\n\n${JSON.stringify(result, null, 2)}`
|
|
1329
|
+
}]
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
case 'delete_notable_sheet': {
|
|
1334
|
+
const { base_id, sheet_id, operator_id } = args;
|
|
1335
|
+
await dingtalk.notableRequest('DELETE', `/v1.0/notable/bases/${base_id}/sheets/${sheet_id}`, {
|
|
1336
|
+
operatorId: operator_id || null
|
|
1337
|
+
});
|
|
1338
|
+
return {
|
|
1339
|
+
content: [{
|
|
1340
|
+
type: 'text',
|
|
1341
|
+
text: `✅ 数据表已删除 (sheetId: ${sheet_id})`
|
|
1342
|
+
}]
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
|
|
856
1346
|
default:
|
|
857
1347
|
throw new Error(`未知工具: ${name}`);
|
|
858
1348
|
}
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -7,10 +7,19 @@
|
|
|
7
7
|
- `get_wiki_workspace` - 获取知识库详情
|
|
8
8
|
- `list_wiki_nodes` - 列出知识库节点(文档 / 目录)
|
|
9
9
|
- `get_wiki_node` - 获取节点详情
|
|
10
|
+
- `get_wiki_doc_content` - 读取文档正文内容(Block 结构)
|
|
10
11
|
- `create_wiki_doc` - 创建文档(支持 `DOC` / `WORKBOOK` / `MIND` / `FOLDER`)
|
|
12
|
+
- `update_wiki_doc_content` - 覆写文档内容(Markdown,⚠️ 全量覆盖)
|
|
13
|
+
- `rename_wiki_doc` - 重命名文档
|
|
14
|
+
- `delete_wiki_doc` - 删除文档节点
|
|
11
15
|
- `search_wiki` - 搜索知识库内容
|
|
12
16
|
- `list_notable_sheets` - 获取 `.able` / AI 表格中的所有数据表
|
|
13
17
|
- `list_notable_records` - 获取指定数据表中的 records
|
|
18
|
+
- `create_notable_record` - 创建记录(单条或多条)
|
|
19
|
+
- `update_notable_record` - 更新记录
|
|
20
|
+
- `delete_notable_record` - 删除记录
|
|
21
|
+
- `create_notable_sheet` - 创建数据表
|
|
22
|
+
- `delete_notable_sheet` - 删除数据表
|
|
14
23
|
|
|
15
24
|
### 组织架构
|
|
16
25
|
- `list_departments` - 列出部门列表
|
|
@@ -72,6 +81,25 @@ mcporter call dingtalk-wiki.create_wiki_doc \
|
|
|
72
81
|
# 获取节点详情
|
|
73
82
|
mcporter call dingtalk-wiki.get_wiki_node node_id="your_node_id"
|
|
74
83
|
|
|
84
|
+
# 读取文档正文内容
|
|
85
|
+
mcporter call dingtalk-wiki.get_wiki_doc_content doc_key="your_doc_key"
|
|
86
|
+
|
|
87
|
+
# 更新文档内容(Markdown,⚠️ 全量覆盖)
|
|
88
|
+
mcporter call dingtalk-wiki.update_wiki_doc_content \
|
|
89
|
+
doc_key="your_doc_key" \
|
|
90
|
+
content="# 新标题\n\n新正文"
|
|
91
|
+
|
|
92
|
+
# 重命名文档
|
|
93
|
+
mcporter call dingtalk-wiki.rename_wiki_doc \
|
|
94
|
+
workspace_id="your_workspace_id" \
|
|
95
|
+
node_id="your_node_id" \
|
|
96
|
+
name="新文档名称"
|
|
97
|
+
|
|
98
|
+
# 删除文档
|
|
99
|
+
mcporter call dingtalk-wiki.delete_wiki_doc \
|
|
100
|
+
workspace_id="your_workspace_id" \
|
|
101
|
+
node_id="your_node_id"
|
|
102
|
+
|
|
75
103
|
# 搜索知识库内容
|
|
76
104
|
mcporter call dingtalk-wiki.search_wiki keyword="项目规划"
|
|
77
105
|
|
|
@@ -101,6 +129,40 @@ mcporter call dingtalk-wiki.list_notable_records \
|
|
|
101
129
|
base_id="your_base_id" \
|
|
102
130
|
sheet_id="your_sheet_id" \
|
|
103
131
|
next_token="your_next_token"
|
|
132
|
+
|
|
133
|
+
# 创建记录(单条或多条)
|
|
134
|
+
mcporter call dingtalk-wiki.create_notable_record \
|
|
135
|
+
base_id="your_base_id" \
|
|
136
|
+
sheet_id="your_sheet_id" \
|
|
137
|
+
records='[{"fields":{"姓名":"张三","年龄":25}}]'
|
|
138
|
+
|
|
139
|
+
# 更新记录
|
|
140
|
+
mcporter call dingtalk-wiki.update_notable_record \
|
|
141
|
+
base_id="your_base_id" \
|
|
142
|
+
sheet_id="your_sheet_id" \
|
|
143
|
+
records='[{"id":"record_id","fields":{"姓名":"李四","年龄":26}}]'
|
|
144
|
+
|
|
145
|
+
# 删除记录
|
|
146
|
+
mcporter call dingtalk-wiki.delete_notable_record \
|
|
147
|
+
base_id="your_base_id" \
|
|
148
|
+
sheet_id="your_sheet_id" \
|
|
149
|
+
record_ids='["record_id1","record_id2"]'
|
|
150
|
+
|
|
151
|
+
# 创建数据表
|
|
152
|
+
mcporter call dingtalk-wiki.create_notable_sheet \
|
|
153
|
+
base_id="your_base_id" \
|
|
154
|
+
name="新数据表"
|
|
155
|
+
|
|
156
|
+
# 创建带字段的数据表
|
|
157
|
+
mcporter call dingtalk-wiki.create_notable_sheet \
|
|
158
|
+
base_id="your_base_id" \
|
|
159
|
+
name="员工表" \
|
|
160
|
+
fields='[{"name":"姓名","type":"Text"},{"name":"年龄","type":"Number"}]'
|
|
161
|
+
|
|
162
|
+
# 删除数据表
|
|
163
|
+
mcporter call dingtalk-wiki.delete_notable_sheet \
|
|
164
|
+
base_id="your_base_id" \
|
|
165
|
+
sheet_id="your_sheet_id"
|
|
104
166
|
```
|
|
105
167
|
|
|
106
168
|
### 组织架构
|