dingtalk-wiki 1.2.6 → 1.2.7

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.
Files changed (2) hide show
  1. package/index.js +25 -16
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1632,23 +1632,32 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1632
1632
  } catch (e) { console.error(`[DEBUG] get_wiki_doc_content: search fallback failed: ${e.message}`); }
1633
1633
  }
1634
1634
 
1635
- console.error(`[DEBUG] get_wiki_doc_content: calling blocks API with docKey=${realDocKey}`);
1636
- const result = await dingtalk.docRequest('GET', `/v1.0/doc/suites/documents/${realDocKey}/blocks`, { operatorId: operator_id || null });
1637
- const blocks = result.result?.data || [];
1638
- let output = '';
1639
- blocks.forEach((block) => {
1640
- const text = extractBlockText(block);
1641
- output += text + '\n\n';
1642
- });
1643
- if (!blocks.length) {
1644
- output = '(文档为空或无可读内容)';
1635
+ try {
1636
+ const result = await dingtalk.docRequest('GET', `/v1.0/doc/suites/documents/${realDocKey}/blocks`, { operatorId: operator_id || null });
1637
+ const blocks = result.result?.data || [];
1638
+ let output = '';
1639
+ blocks.forEach((block) => {
1640
+ const text = extractBlockText(block);
1641
+ output += text + '\n\n';
1642
+ });
1643
+ if (!blocks.length) {
1644
+ output = '(文档为空或无可读内容)';
1645
+ }
1646
+ return {
1647
+ content: [{
1648
+ type: 'text',
1649
+ text: output.trim()
1650
+ }]
1651
+ };
1652
+ } catch (blocksErr) {
1653
+ return {
1654
+ content: [{
1655
+ type: 'text',
1656
+ text: `❌ blocks API 调用失败\n错误: ${blocksErr.message}\n\n调试信息:\n- 输入 doc_key: ${docKey}\n- 解析后 realDocKey: ${realDocKey}\n- workspaceId: ${workspaceId || '未提供'}\n- operator_id: ${operator_id || '未提供(将自动解析)'}`
1657
+ }],
1658
+ isError: true
1659
+ };
1645
1660
  }
1646
- return {
1647
- content: [{
1648
- type: 'text',
1649
- text: output.trim()
1650
- }]
1651
- };
1652
1661
  }
1653
1662
 
1654
1663
  case 'update_wiki_doc_content': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dingtalk-wiki",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "DingTalk Wiki / Docs read-write MCP server that fills the gap left by DingTalk official MCP.",
5
5
  "main": "index.js",
6
6
  "bin": {