feishu-doc-mcp 1.0.4 → 1.0.6
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 -3
- package/build/index.js +12 -20
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
|
|
19
19
|
### 内容智能处理
|
|
20
20
|
|
|
21
|
-
- HTML 自动转换为 Markdown,便于 AI 理解和引用
|
|
22
21
|
- 大文件自动提示分段读取,保护 context window
|
|
23
22
|
- 临时文件智能命名(可读前缀 + Hash),避免冲突
|
|
24
23
|
|
|
@@ -45,9 +44,11 @@
|
|
|
45
44
|
无需安装,直接使用 npx 运行:
|
|
46
45
|
|
|
47
46
|
```bash
|
|
48
|
-
npx feishu-doc-mcp
|
|
47
|
+
npx feishu-doc-mcp@latest
|
|
49
48
|
```
|
|
50
49
|
|
|
50
|
+
> 使用 `@latest` 确保每次运行时获取最新版本。
|
|
51
|
+
|
|
51
52
|
### 全局安装
|
|
52
53
|
|
|
53
54
|
```bash
|
|
@@ -73,7 +74,7 @@ feishu-doc-mcp
|
|
|
73
74
|
"mcpServers": {
|
|
74
75
|
"feishu-doc": {
|
|
75
76
|
"command": "npx",
|
|
76
|
-
"args": ["feishu-doc-mcp"]
|
|
77
|
+
"args": ["feishu-doc-mcp@latest"]
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
}
|
package/build/index.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import TurndownService from "turndown";
|
|
5
4
|
import * as fs from "fs";
|
|
6
5
|
import * as os from "os";
|
|
7
6
|
import * as path from "path";
|
|
8
7
|
import * as crypto from "crypto";
|
|
9
8
|
import { z } from "zod";
|
|
10
|
-
// 初始化 Turndown 用于将 HTML 转为 Markdown
|
|
11
|
-
const turndownService = new TurndownService({
|
|
12
|
-
headingStyle: "atx",
|
|
13
|
-
codeBlockStyle: "fenced",
|
|
14
|
-
});
|
|
15
9
|
// API 端点
|
|
16
10
|
const DIRECTORY_LIST_URL = "https://open.feishu.cn/api/tools/docment/directory_list";
|
|
17
11
|
const URI_MAPPING_URL = "https://open.feishu.cn/document_portal/v1/document_portal/v1/document/uri/mapping";
|
|
@@ -223,23 +217,12 @@ class FeishuDocServer {
|
|
|
223
217
|
if (detail.description) {
|
|
224
218
|
content += `${detail.description}\n\n`;
|
|
225
219
|
}
|
|
226
|
-
// 主要内容
|
|
220
|
+
// 主要内容
|
|
227
221
|
if (detail.content) {
|
|
228
|
-
|
|
229
|
-
if (typeof detail.content === "string" && detail.content.includes("<")) {
|
|
230
|
-
content += turndownService.turndown(detail.content);
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
content += detail.content;
|
|
234
|
-
}
|
|
222
|
+
content += detail.content;
|
|
235
223
|
}
|
|
236
224
|
else if (detail.body) {
|
|
237
|
-
|
|
238
|
-
content += turndownService.turndown(detail.body);
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
content += JSON.stringify(detail.body, null, 2);
|
|
242
|
-
}
|
|
225
|
+
content += typeof detail.body === "string" ? detail.body : JSON.stringify(detail.body, null, 2);
|
|
243
226
|
}
|
|
244
227
|
else {
|
|
245
228
|
// 返回原始数据结构供分析
|
|
@@ -280,7 +263,16 @@ class FeishuDocServer {
|
|
|
280
263
|
throw new Error(`Failed to fetch document: ${message}`);
|
|
281
264
|
}
|
|
282
265
|
}
|
|
266
|
+
// 清理临时目录
|
|
267
|
+
cleanupTempDir() {
|
|
268
|
+
if (fs.existsSync(TEMP_DOC_DIR)) {
|
|
269
|
+
fs.rmSync(TEMP_DOC_DIR, { recursive: true, force: true });
|
|
270
|
+
console.error(`[Cleanup] Removed temp directory: ${TEMP_DOC_DIR}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
283
273
|
async run() {
|
|
274
|
+
// 启动时清理临时目录
|
|
275
|
+
this.cleanupTempDir();
|
|
284
276
|
// 先初始化并注册工具
|
|
285
277
|
await this.initializeAndRegisterTools();
|
|
286
278
|
const transport = new StdioServerTransport();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feishu-doc-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "MCP server for Feishu Open Platform Documentation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -40,12 +40,10 @@
|
|
|
40
40
|
"homepage": "https://github.com/ztxtxwd/feishu-doc-mcp#readme",
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
43
|
-
"turndown": "^7.2.2",
|
|
44
43
|
"zod": "^4.3.5"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@types/node": "^25.0.6",
|
|
48
|
-
"@types/turndown": "^5.0.6",
|
|
49
47
|
"typescript": "^5.9.3"
|
|
50
48
|
},
|
|
51
49
|
"engines": {
|