dingtalk-wiki 1.2.2 → 1.2.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 +4 -4
- package/README.zh-CN.md +4 -4
- package/index.js +23 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dingtalk-wiki
|
|
1
|
+
# dingtalk-wiki
|
|
2
2
|
|
|
3
3
|
[](https://github.com/ianen/dingtalk-wiki-mcp/releases)
|
|
4
4
|
[](./LICENSE)
|
|
@@ -53,7 +53,7 @@ All config goes into one JSON block — no local files needed:
|
|
|
53
53
|
| `DINGTALK_APP_SECRET` | DingTalk App Secret |
|
|
54
54
|
| `DINGTALK_WIKI_CONFIG` | User/workspace config (JSON string), required |
|
|
55
55
|
|
|
56
|
-
On first call the server auto-fetches `unionId` via `userId` and caches it to `~/.cache/dingtalk-wiki
|
|
56
|
+
On first call the server auto-fetches `unionId` via `userId` and caches it to `~/.cache/dingtalk-wiki/`.
|
|
57
57
|
|
|
58
58
|
Then call tools as `dingtalk-wiki.list_wiki_workspaces` (namespaced).
|
|
59
59
|
|
|
@@ -108,14 +108,14 @@ Or:
|
|
|
108
108
|
node index.js
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
> `
|
|
111
|
+
> `pnpx dingtalk-wiki` is a future-friendly path after npm publishing.
|
|
112
112
|
> This repository already includes the correct CLI entry (`bin`), but npm distribution is not part of the current release yet.
|
|
113
113
|
|
|
114
114
|
---
|
|
115
115
|
|
|
116
116
|
## DingTalk official MCP vs this project
|
|
117
117
|
|
|
118
|
-
| Capability | DingTalk official MCP | dingtalk-wiki
|
|
118
|
+
| Capability | DingTalk official MCP | dingtalk-wiki |
|
|
119
119
|
| ------------------------------ | ----------------------------: | ----------------------: |
|
|
120
120
|
| Wiki read | Not covered | ✅ |
|
|
121
121
|
| Wiki write | Not covered | ✅ |
|
package/README.zh-CN.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dingtalk-wiki
|
|
1
|
+
# dingtalk-wiki
|
|
2
2
|
|
|
3
3
|
[](https://github.com/ianen/dingtalk-wiki-mcp/releases)
|
|
4
4
|
[](./LICENSE)
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
| `DINGTALK_APP_SECRET` | 钉钉应用 AppSecret |
|
|
55
55
|
| `DINGTALK_WIKI_CONFIG` | 用户/知识库配置(JSON 字符串),必填 |
|
|
56
56
|
|
|
57
|
-
首次调用时程序自动通过 `userId` 获取 `unionId` 并缓存到 `~/.cache/dingtalk-wiki
|
|
57
|
+
首次调用时程序自动通过 `userId` 获取 `unionId` 并缓存到 `~/.cache/dingtalk-wiki/`,后续启动不再重复请求。
|
|
58
58
|
|
|
59
59
|
之后以 `dingtalk-wiki.工具名` 的方式调用(如 `dingtalk-wiki.list_wiki_workspaces`)。
|
|
60
60
|
|
|
@@ -108,14 +108,14 @@ npm start
|
|
|
108
108
|
node index.js
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
> `npx dingtalk-wiki
|
|
111
|
+
> `npx dingtalk-wiki` 是后续可扩展的分发路径。
|
|
112
112
|
> 当前仓库已经具备正确的 CLI 入口(`bin`),但 npm 发布不在这次版本范围内。
|
|
113
113
|
|
|
114
114
|
---
|
|
115
115
|
|
|
116
116
|
## 官方 DingTalk MCP vs 本项目
|
|
117
117
|
|
|
118
|
-
| 能力 | 钉钉官方 MCP | dingtalk-wiki
|
|
118
|
+
| 能力 | 钉钉官方 MCP | dingtalk-wiki |
|
|
119
119
|
|---|---:|---:|
|
|
120
120
|
| Wiki 读取 | 未覆盖 | ✅ |
|
|
121
121
|
| Wiki 写入 | 未覆盖 | ✅ |
|
package/index.js
CHANGED
|
@@ -601,7 +601,7 @@ const wikiIndex = new WikiSearchIndex();
|
|
|
601
601
|
// MCP Server 定义
|
|
602
602
|
const server = new Server(
|
|
603
603
|
{
|
|
604
|
-
name: 'dingtalk-wiki
|
|
604
|
+
name: 'dingtalk-wiki',
|
|
605
605
|
version: '1.1.0'
|
|
606
606
|
},
|
|
607
607
|
{
|
|
@@ -1561,7 +1561,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1561
1561
|
if (operator_id) {
|
|
1562
1562
|
dingtalk.setOperatorId(operator_id);
|
|
1563
1563
|
}
|
|
1564
|
-
|
|
1564
|
+
|
|
1565
|
+
// nodeId 可能不等于 docKey,先尝试解析
|
|
1566
|
+
let realDocKey = docKey;
|
|
1567
|
+
try {
|
|
1568
|
+
const nodeInfo = await dingtalk.docRequest('GET', `/v2.0/wiki/nodes/${docKey}`, { operatorId: operator_id || null });
|
|
1569
|
+
if (nodeInfo.document?.docKey) {
|
|
1570
|
+
realDocKey = nodeInfo.document.docKey;
|
|
1571
|
+
}
|
|
1572
|
+
} catch (e) { /* 非 nodeId,直接用原始值 */ }
|
|
1573
|
+
|
|
1574
|
+
const result = await dingtalk.docRequest('GET', `/v1.0/doc/suites/documents/${realDocKey}/blocks`, { operatorId: operator_id || null });
|
|
1565
1575
|
const blocks = result.result?.data || [];
|
|
1566
1576
|
let output = '';
|
|
1567
1577
|
blocks.forEach((block) => {
|
|
@@ -1584,7 +1594,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1584
1594
|
if (operator_id) {
|
|
1585
1595
|
dingtalk.setOperatorId(operator_id);
|
|
1586
1596
|
}
|
|
1587
|
-
|
|
1597
|
+
|
|
1598
|
+
// nodeId 可能不等于 docKey,先尝试解析
|
|
1599
|
+
let realDocKey = docKey;
|
|
1600
|
+
try {
|
|
1601
|
+
const nodeInfo = await dingtalk.docRequest('GET', `/v2.0/wiki/nodes/${docKey}`, { operatorId: operator_id || null });
|
|
1602
|
+
if (nodeInfo.document?.docKey) {
|
|
1603
|
+
realDocKey = nodeInfo.document.docKey;
|
|
1604
|
+
}
|
|
1605
|
+
} catch (e) { /* 非 nodeId,直接用原始值 */ }
|
|
1606
|
+
|
|
1607
|
+
await dingtalk.docRequest('POST', `/v1.0/doc/suites/documents/${realDocKey}/overwriteContent`, {
|
|
1588
1608
|
operatorId: operator_id || null,
|
|
1589
1609
|
data: { content, contentType: 'markdown' }
|
|
1590
1610
|
});
|