@lmcc-dev/mult-fetch-mcp-server 1.2.1 → 1.3.1
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 +80 -29
- package/README.zh.md +80 -29
- package/dist/i18n-test-report.json +2 -2
- package/dist/i18n-unused-keys-report.json +4 -4
- package/dist/src/client.js +522 -131
- package/dist/src/index.js +0 -0
- package/dist/src/lib/fetch.js +8 -0
- package/dist/src/lib/fetchers/browser/BrowserFetcher.js +139 -199
- package/dist/src/lib/fetchers/common/BaseFetcher.js +203 -0
- package/dist/src/lib/fetchers/common/types.js +4 -0
- package/dist/src/lib/fetchers/common/utils.js +1 -1
- package/dist/src/lib/fetchers/index.js +11 -0
- package/dist/src/lib/fetchers/node/NodeFetcher.js +91 -66
- package/dist/src/lib/i18n/keys/browser.js +40 -2
- package/dist/src/lib/i18n/keys/chunkManager.js +43 -0
- package/dist/src/lib/i18n/keys/client.js +53 -1
- package/dist/src/lib/i18n/keys/contentSize.js +20 -0
- package/dist/src/lib/i18n/keys/fetcher.js +88 -79
- package/dist/src/lib/i18n/keys/index.js +4 -0
- package/dist/src/lib/i18n/keys/node.js +7 -1
- package/dist/src/lib/i18n/keys/processor.js +30 -0
- package/dist/src/lib/i18n/keys/tools.js +5 -1
- package/dist/src/lib/i18n/keys/url.js +45 -0
- package/dist/src/lib/i18n/keys.js +25 -0
- package/dist/src/lib/i18n/locales/en/browser.js +52 -14
- package/dist/src/lib/i18n/locales/en/chunkManager.js +41 -0
- package/dist/src/lib/i18n/locales/en/client.js +62 -9
- package/dist/src/lib/i18n/locales/en/contentSize.js +17 -0
- package/dist/src/lib/i18n/locales/en/fetcher.js +50 -30
- package/dist/src/lib/i18n/locales/en/index.js +9 -1
- package/dist/src/lib/i18n/locales/en/node.js +26 -20
- package/dist/src/lib/i18n/locales/en/processor.js +28 -0
- package/dist/src/lib/i18n/locales/en/tools.js +5 -1
- package/dist/src/lib/i18n/locales/en/url.js +40 -0
- package/dist/src/lib/i18n/locales/en.js +51 -0
- package/dist/src/lib/i18n/locales/zh/browser.js +85 -47
- package/dist/src/lib/i18n/locales/zh/chunkManager.js +41 -0
- package/dist/src/lib/i18n/locales/zh/client.js +53 -1
- package/dist/src/lib/i18n/locales/zh/contentSize.js +17 -0
- package/dist/src/lib/i18n/locales/zh/fetcher.js +67 -47
- package/dist/src/lib/i18n/locales/zh/index.js +9 -1
- package/dist/src/lib/i18n/locales/zh/node.js +50 -44
- package/dist/src/lib/i18n/locales/zh/processor.js +28 -0
- package/dist/src/lib/i18n/locales/zh/tools.js +5 -1
- package/dist/src/lib/i18n/locales/zh/url.js +40 -0
- package/dist/src/lib/i18n/locales/zh.js +51 -0
- package/dist/src/lib/logger.js +11 -2
- package/dist/src/lib/server/fetcher.js +15 -5
- package/dist/src/lib/server/tools.js +202 -52
- package/dist/src/lib/types.js +5 -0
- package/dist/src/lib/utils/ChunkManager.js +177 -0
- package/dist/src/lib/utils/ContentProcessor.js +134 -0
- package/dist/src/lib/utils/ContentSizeManager.js +123 -0
- package/dist/src/lib/utils/TemplateUtils.js +71 -0
- package/dist/src/lib/utils/errors.js +2 -8
- package/dist/src/mcp-server.js +0 -0
- package/dist/src/test-i18n.js +0 -0
- package/dist/tests/BrowserFetcher.test.js +0 -0
- package/dist/tests/NodeFetcher.test.js +0 -0
- package/dist/tests/client.test.js +0 -0
- package/dist/tests/fetch.test.js +0 -0
- package/dist/tests/fetchers/plain-text.test.js +146 -0
- package/dist/tests/i18n-missing-keys.js +0 -0
- package/dist/tests/i18n-remove-unused-keys.js +0 -0
- package/dist/tests/i18n-unused-keys.js +0 -0
- package/dist/tests/i18n.test.js +0 -0
- package/dist/tests/logger.test.js +0 -0
- package/dist/tests/mcp-server.test.js +0 -0
- package/dist/tests/server/fetcher.test.js +69 -15
- package/dist/tests/server/tools.test.js +165 -16
- package/dist/tests/setup.js +0 -0
- package/dist/tests/test-direct-client.js +113 -5
- package/dist/tests/test-i18n.js +0 -0
- package/dist/tests/test-mcp-methods.js +67 -1
- package/dist/tests/test-mcp.js +83 -3
- package/dist/tests/test-mini4k.js +90 -3
- package/dist/tests/types.test.js +0 -0
- package/dist/tests/utils/ChunkManager.test.js +163 -0
- package/dist/tests/utils/ContentSizeManager.test.js +170 -0
- package/dist/vitest.config.js +0 -0
- package/package.json +28 -23
package/README.md
CHANGED
|
@@ -31,32 +31,35 @@ This project implements an MCP-compliant client and server for communication bet
|
|
|
31
31
|
|
|
32
32
|
```
|
|
33
33
|
fetch-mcp/
|
|
34
|
-
├── src/
|
|
35
|
-
│ ├── lib/
|
|
36
|
-
│ │ ├──
|
|
37
|
-
│ │ ├──
|
|
38
|
-
│ │ ├──
|
|
39
|
-
│ │ │ ├──
|
|
40
|
-
│ │ │
|
|
41
|
-
│ │ │ ├──
|
|
42
|
-
│ │ │
|
|
43
|
-
│ │
|
|
44
|
-
│ │ │
|
|
45
|
-
│ │ ├──
|
|
46
|
-
│ │ │ ├──
|
|
47
|
-
│ │ │ └──
|
|
48
|
-
│ │
|
|
49
|
-
│ ├──
|
|
50
|
-
│
|
|
51
|
-
├──
|
|
52
|
-
├──
|
|
53
|
-
│ ├──
|
|
54
|
-
│ ├──
|
|
55
|
-
│ └──
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
34
|
+
├── src/ # Source code directory
|
|
35
|
+
│ ├── lib/ # Library files
|
|
36
|
+
│ │ ├── fetchers/ # Web fetching implementations
|
|
37
|
+
│ │ │ ├── browser/ # Browser-based fetching
|
|
38
|
+
│ │ │ │ ├── BrowserFetcher.ts # Browser fetching implementation
|
|
39
|
+
│ │ │ │ ├── BrowserInstance.ts # Browser instance management
|
|
40
|
+
│ │ │ │ └── PageOperations.ts # Page interaction operations
|
|
41
|
+
│ │ │ ├── node/ # Node.js-based fetching
|
|
42
|
+
│ │ │ └── common/ # Shared fetching utilities
|
|
43
|
+
│ │ ├── utils/ # Utility modules
|
|
44
|
+
│ │ │ ├── ChunkManager.ts # Content chunking functionality
|
|
45
|
+
│ │ │ ├── ContentProcessor.ts # HTML to text conversion
|
|
46
|
+
│ │ │ ├── ContentSizeManager.ts # Content size limiting
|
|
47
|
+
│ │ │ └── ErrorHandler.ts # Error management
|
|
48
|
+
│ │ ├── server/ # Server-related modules
|
|
49
|
+
│ │ │ ├── index.ts # Server entry point
|
|
50
|
+
│ │ │ ├── browser.ts # Browser management
|
|
51
|
+
│ │ │ ├── fetcher.ts # Web fetching logic
|
|
52
|
+
│ │ │ ├── tools.ts # Tool registration and handling
|
|
53
|
+
│ │ │ ├── resources.ts # Resource handling
|
|
54
|
+
│ │ │ ├── prompts.ts # Prompt templates
|
|
55
|
+
│ │ │ └── types.ts # Server type definitions
|
|
56
|
+
│ │ ├── i18n/ # Internationalization support
|
|
57
|
+
│ │ └── types.ts # Common type definitions
|
|
58
|
+
│ ├── client.ts # MCP client implementation
|
|
59
|
+
│ └── mcp-server.ts # MCP server main entry
|
|
60
|
+
├── index.ts # Server entry point
|
|
61
|
+
├── tests/ # Test files
|
|
62
|
+
└── dist/ # Compiled files
|
|
60
63
|
```
|
|
61
64
|
|
|
62
65
|
## MCP Specification
|
|
@@ -72,8 +75,10 @@ This project implements the Standard Input/Output (Stdio) transport method.
|
|
|
72
75
|
|
|
73
76
|
- Implementation based on the official MCP SDK
|
|
74
77
|
- Support for Standard Input/Output (Stdio) transport
|
|
75
|
-
- Multiple web scraping methods (HTML, JSON, text, Markdown)
|
|
78
|
+
- Multiple web scraping methods (HTML, JSON, text, Markdown, plain text conversion)
|
|
76
79
|
- Intelligent mode switching: automatically switches between standard requests and browser mode
|
|
80
|
+
- Content size management: automatically splits large content into manageable chunks to overcome AI context size limitations
|
|
81
|
+
- Chunked content retrieval: ability to request specific chunks of large content while maintaining context continuity
|
|
77
82
|
- Detailed debug logs output to standard error stream
|
|
78
83
|
- Support for Chinese and English bilingual internationalization
|
|
79
84
|
- Modular design for easy maintenance and extension
|
|
@@ -171,6 +176,7 @@ After configuration, restart Claude desktop, and you can use the following tools
|
|
|
171
176
|
- `fetch_json`: Get JSON data
|
|
172
177
|
- `fetch_txt`: Get plain text content
|
|
173
178
|
- `fetch_markdown`: Get Markdown formatted content
|
|
179
|
+
- `fetch_plaintext`: Get plain text content converted from HTML (strips HTML tags)
|
|
174
180
|
|
|
175
181
|
## Build
|
|
176
182
|
|
|
@@ -190,7 +196,13 @@ node dist/index.js
|
|
|
190
196
|
npx @lmcc-dev/mult-fetch-mcp-server
|
|
191
197
|
```
|
|
192
198
|
|
|
193
|
-
##
|
|
199
|
+
## Client Demo Tools
|
|
200
|
+
|
|
201
|
+
> **Note**: The following client.js functionality is provided for demonstration and testing purposes only. When used with Claude or other AI assistants, the MCP server is driven by the AI, which manages the chunking process automatically.
|
|
202
|
+
|
|
203
|
+
### Command Line Client
|
|
204
|
+
|
|
205
|
+
The project includes a command-line client for testing and development purposes:
|
|
194
206
|
|
|
195
207
|
```bash
|
|
196
208
|
pnpm run client <method> <params_json>
|
|
@@ -198,6 +210,23 @@ pnpm run client <method> <params_json>
|
|
|
198
210
|
pnpm run client fetch_html '{"url": "https://example.com", "debug": true}'
|
|
199
211
|
```
|
|
200
212
|
|
|
213
|
+
### Demo Client Chunk Control Parameters
|
|
214
|
+
|
|
215
|
+
When testing with the command-line client, you can use these parameters to demonstrate content chunking capabilities:
|
|
216
|
+
|
|
217
|
+
- `--all-chunks`: Command line flag to automatically fetch all chunks in sequence (demonstration purpose only)
|
|
218
|
+
- `--max-chunks`: Command line flag to limit the maximum number of chunks to fetch (optional, default is 10)
|
|
219
|
+
|
|
220
|
+
#### Real-time Output Demo
|
|
221
|
+
|
|
222
|
+
The client.js demo tool provides real-time output capabilities:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
node dist/src/client.js fetch_html '{"url":"https://example.com", "startCursor": 0, "contentSizeLimit": 500}' --all-chunks --debug
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The demo client will automatically fetch all chunks in sequence and display them immediately, showcasing how large content can be processed in real-time.
|
|
229
|
+
|
|
201
230
|
## Run Tests
|
|
202
231
|
|
|
203
232
|
```bash
|
|
@@ -402,6 +431,7 @@ if (result.isError) {
|
|
|
402
431
|
- `fetch_json`: Get JSON data
|
|
403
432
|
- `fetch_txt`: Get plain text content
|
|
404
433
|
- `fetch_markdown`: Get Markdown formatted content
|
|
434
|
+
- `fetch_plaintext`: Get plain text content converted from HTML (strips HTML tags)
|
|
405
435
|
|
|
406
436
|
### Resources Support
|
|
407
437
|
|
|
@@ -472,10 +502,22 @@ Each tool supports the following parameters:
|
|
|
472
502
|
- `noDelay`: Whether to disable random delay between requests (optional, default is false)
|
|
473
503
|
- `useSystemProxy`: Whether to use system proxy (optional, default is true)
|
|
474
504
|
|
|
505
|
+
#### Content Size Control Parameters
|
|
506
|
+
- `enableContentSplitting`: Whether to split large content into chunks (optional, default is true)
|
|
507
|
+
- `contentSizeLimit`: Maximum content size in bytes before splitting (optional, default is 50000)
|
|
508
|
+
- `startCursor`: Starting cursor position in bytes for retrieving content from a specific position (optional, default is 0)
|
|
509
|
+
|
|
510
|
+
These parameters help manage large content that would exceed AI model context size limits, allowing you to retrieve web content in manageable chunks while maintaining the ability to process the complete information.
|
|
511
|
+
|
|
512
|
+
#### Chunk Management
|
|
513
|
+
- `chunkId`: Unique identifier for a chunk set when content is split (used for requesting subsequent chunks)
|
|
514
|
+
|
|
515
|
+
When content is split into chunks, the response includes metadata that allows the AI to request subsequent chunks using the `chunkId` and `startCursor` parameters. The system uses byte-level chunk management to provide precise control over content retrieval, enabling seamless processing of content from any position.
|
|
516
|
+
|
|
475
517
|
#### Mode Control Parameters
|
|
476
518
|
- `useBrowser`: Whether to use browser mode (optional, default is false)
|
|
477
519
|
- `useNodeFetch`: Whether to force using Node.js mode (optional, default is false, mutually exclusive with `useBrowser`)
|
|
478
|
-
- `autoDetectMode`: Whether to automatically detect and switch to browser mode (optional, default is true)
|
|
520
|
+
- `autoDetectMode`: Whether to automatically detect and switch to browser mode if standard mode fails with 403/Forbidden errors (optional, default is true). Set to false to strictly use the specified mode without automatic switching.
|
|
479
521
|
|
|
480
522
|
#### Browser Mode Specific Parameters
|
|
481
523
|
- `waitForSelector`: Selector to wait for in browser mode (optional, default is 'body')
|
|
@@ -514,6 +556,15 @@ When `debug: true` is set, the logs will be output to stderr with the following
|
|
|
514
556
|
- `[NODE-FETCH]`: Logs from the Node.js fetcher
|
|
515
557
|
- `[BROWSER-FETCH]`: Logs from the browser fetcher
|
|
516
558
|
- `[CLIENT]`: Logs from the client
|
|
559
|
+
- `[TOOLS]`: Logs from the tools implementation
|
|
560
|
+
- `[FETCHER]`: Logs from the main fetcher interface
|
|
561
|
+
- `[CONTENT]`: Logs related to content processing
|
|
562
|
+
- `[CONTENT-PROCESSOR]`: Logs from the HTML content processor
|
|
563
|
+
- `[CONTENT-SIZE]`: Logs related to content size management
|
|
564
|
+
- `[CHUNK-MANAGER]`: Logs related to content chunking operations
|
|
565
|
+
- `[ERROR-HANDLER]`: Logs related to error handling
|
|
566
|
+
- `[BROWSER-MANAGER]`: Logs from the browser instance manager
|
|
567
|
+
|
|
517
568
|
|
|
518
569
|
## License
|
|
519
570
|
|
package/README.zh.md
CHANGED
|
@@ -28,32 +28,35 @@
|
|
|
28
28
|
|
|
29
29
|
```
|
|
30
30
|
fetch-mcp/
|
|
31
|
-
├── src/
|
|
32
|
-
│ ├── lib/
|
|
33
|
-
│ │ ├──
|
|
34
|
-
│ │ ├──
|
|
35
|
-
│ │ ├──
|
|
36
|
-
│ │ │ ├──
|
|
37
|
-
│ │ │
|
|
38
|
-
│ │ │ ├──
|
|
39
|
-
│ │ │
|
|
40
|
-
│ │
|
|
41
|
-
│ │ │
|
|
42
|
-
│ │ ├──
|
|
43
|
-
│ │ │ ├──
|
|
44
|
-
│ │ │ └──
|
|
45
|
-
│ │
|
|
46
|
-
│ ├──
|
|
47
|
-
│
|
|
48
|
-
├──
|
|
49
|
-
├──
|
|
50
|
-
│ ├──
|
|
51
|
-
│ ├──
|
|
52
|
-
│ └──
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
31
|
+
├── src/ # 源代码目录
|
|
32
|
+
│ ├── lib/ # 库文件
|
|
33
|
+
│ │ ├── fetchers/ # 网页获取实现
|
|
34
|
+
│ │ │ ├── browser/ # 基于浏览器的获取
|
|
35
|
+
│ │ │ │ ├── BrowserFetcher.ts # 浏览器获取实现
|
|
36
|
+
│ │ │ │ ├── BrowserInstance.ts # 浏览器实例管理
|
|
37
|
+
│ │ │ │ └── PageOperations.ts # 页面交互操作
|
|
38
|
+
│ │ │ ├── node/ # 基于Node.js的获取
|
|
39
|
+
│ │ │ └── common/ # 共享获取工具
|
|
40
|
+
│ │ ├── utils/ # 工具模块
|
|
41
|
+
│ │ │ ├── ChunkManager.ts # 内容分块功能
|
|
42
|
+
│ │ │ ├── ContentProcessor.ts # HTML到文本转换
|
|
43
|
+
│ │ │ ├── ContentSizeManager.ts # 内容大小限制
|
|
44
|
+
│ │ │ └── ErrorHandler.ts # 错误处理
|
|
45
|
+
│ │ ├── server/ # 服务器相关模块
|
|
46
|
+
│ │ │ ├── index.ts # 服务器入口
|
|
47
|
+
│ │ │ ├── browser.ts # 浏览器管理
|
|
48
|
+
│ │ │ ├── fetcher.ts # 网页获取逻辑
|
|
49
|
+
│ │ │ ├── tools.ts # 工具注册和处理
|
|
50
|
+
│ │ │ ├── resources.ts # 资源处理
|
|
51
|
+
│ │ │ ├── prompts.ts # 提示模板
|
|
52
|
+
│ │ │ └── types.ts # 服务器类型定义
|
|
53
|
+
│ │ ├── i18n/ # 国际化支持
|
|
54
|
+
│ │ └── types.ts # 通用类型定义
|
|
55
|
+
│ ├── client.ts # MCP 客户端实现
|
|
56
|
+
│ └── mcp-server.ts # MCP 服务器主入口
|
|
57
|
+
├── index.ts # 服务器入口点
|
|
58
|
+
├── tests/ # 测试文件
|
|
59
|
+
└── dist/ # 编译后的文件
|
|
57
60
|
```
|
|
58
61
|
|
|
59
62
|
## MCP规范
|
|
@@ -69,8 +72,10 @@ fetch-mcp/
|
|
|
69
72
|
|
|
70
73
|
- 基于官方 MCP SDK 的实现
|
|
71
74
|
- 支持标准输入输出(Stdio)传输方式
|
|
72
|
-
- 提供了多种网页抓取方法(HTML、JSON、文本、Markdown
|
|
75
|
+
- 提供了多种网页抓取方法(HTML、JSON、文本、Markdown、纯文本转换)
|
|
73
76
|
- 智能模式切换:自动在标准请求和浏览器模式之间切换
|
|
77
|
+
- 内容大小管理:自动将大型内容分割成可管理的块,以解决AI模型上下文大小限制问题
|
|
78
|
+
- 分块内容检索:能够请求大型内容的特定块,同时保持上下文连续性
|
|
74
79
|
- 详细的调试日志输出到标准错误流
|
|
75
80
|
- 支持中英文双语国际化
|
|
76
81
|
- 模块化设计,便于维护和扩展
|
|
@@ -168,6 +173,7 @@ npx @lmcc-dev/mult-fetch-mcp-server
|
|
|
168
173
|
- `fetch_json`: 获取 JSON 数据
|
|
169
174
|
- `fetch_txt`: 获取纯文本内容
|
|
170
175
|
- `fetch_markdown`: 获取 Markdown 格式内容
|
|
176
|
+
- `fetch_plaintext`: 获取从HTML转换的纯文本内容(去除HTML标签)
|
|
171
177
|
|
|
172
178
|
## 构建
|
|
173
179
|
|
|
@@ -187,7 +193,13 @@ mult-fetch-mcp-server
|
|
|
187
193
|
npx mult-fetch-mcp-server
|
|
188
194
|
```
|
|
189
195
|
|
|
190
|
-
##
|
|
196
|
+
## 客户端演示工具
|
|
197
|
+
|
|
198
|
+
> **注意**:以下 client.js 功能仅供演示和测试使用。当与 Claude 或其他 AI 助手一起使用时,MCP 服务器由 AI 驱动,它会自动管理分块处理过程。
|
|
199
|
+
|
|
200
|
+
### 命令行客户端
|
|
201
|
+
|
|
202
|
+
本项目包含一个命令行客户端,用于测试和开发目的:
|
|
191
203
|
|
|
192
204
|
```bash
|
|
193
205
|
pnpm run client <method> <params_json>
|
|
@@ -195,6 +207,23 @@ pnpm run client <method> <params_json>
|
|
|
195
207
|
pnpm run client fetch_html '{"url": "https://example.com", "debug": true}'
|
|
196
208
|
```
|
|
197
209
|
|
|
210
|
+
### 演示客户端分块控制参数
|
|
211
|
+
|
|
212
|
+
在使用命令行客户端进行测试时,可以使用这些参数来演示内容分块功能:
|
|
213
|
+
|
|
214
|
+
- `--all-chunks`:命令行标志,用于自动按顺序获取所有块(仅用于演示目的)
|
|
215
|
+
- `--max-chunks`:命令行标志,用于限制要获取的最大块数(可选,默认为10)
|
|
216
|
+
|
|
217
|
+
#### 实时输出演示
|
|
218
|
+
|
|
219
|
+
client.js 演示工具提供实时输出功能:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
node dist/src/client.js fetch_html '{"url":"https://example.com", "startCursor": 0, "contentSizeLimit": 500}' --all-chunks --debug
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
演示客户端将自动按顺序获取所有块并立即显示它们,展示大型内容如何能够实时处理。
|
|
226
|
+
|
|
198
227
|
## 运行测试
|
|
199
228
|
|
|
200
229
|
```bash
|
|
@@ -401,6 +430,7 @@ if (result.isError) {
|
|
|
401
430
|
- `fetch_json`: 获取JSON数据
|
|
402
431
|
- `fetch_txt`: 获取纯文本内容
|
|
403
432
|
- `fetch_markdown`: 获取Markdown格式内容
|
|
433
|
+
- `fetch_plaintext`: 获取从HTML转换的纯文本内容(去除HTML标签)
|
|
404
434
|
|
|
405
435
|
### 资源支持
|
|
406
436
|
|
|
@@ -471,10 +501,22 @@ console.log('调试获取提示:', debugPrompt);
|
|
|
471
501
|
- `noDelay`: 是否禁用请求间的随机延迟(可选,默认为false)
|
|
472
502
|
- `useSystemProxy`: 是否使用系统代理(可选,默认为true)
|
|
473
503
|
|
|
504
|
+
#### 内容大小控制参数
|
|
505
|
+
- `enableContentSplitting`: 是否将大内容分割成多个块(可选,默认为true)
|
|
506
|
+
- `contentSizeLimit`: 内容分割前的最大字节数(可选,默认为50000)
|
|
507
|
+
- `startCursor`: 字节级偏移量,用于从特定位置开始获取内容(可选,默认为0)
|
|
508
|
+
|
|
509
|
+
这些参数有助于管理超出AI模型上下文大小限制的大型内容,允许您以可管理的块获取网页内容,同时保持处理完整信息的能力。
|
|
510
|
+
|
|
511
|
+
#### 分块管理
|
|
512
|
+
- `chunkId`: 内容分割时的块集唯一标识符(用于请求后续块)
|
|
513
|
+
|
|
514
|
+
当内容被分割成多个块时,响应中包含元数据,允许AI使用`chunkId`和`startCursor`参数请求后续块。系统使用字节级分块管理提供对内容检索的精确控制,实现从内容中任何位置无缝处理。
|
|
515
|
+
|
|
474
516
|
#### 模式控制参数
|
|
475
517
|
- `useBrowser`: 是否使用浏览器模式(可选,默认为false)
|
|
476
518
|
- `useNodeFetch`: 是否强制使用Node.js模式(可选,默认为false,与`useBrowser`互斥)
|
|
477
|
-
- `autoDetectMode`:
|
|
519
|
+
- `autoDetectMode`: 是否在标准模式失败(出现403/Forbidden错误)时自动检测并切换到浏览器模式(可选,默认为true)。设置为false可以严格使用指定的模式,不进行自动切换。
|
|
478
520
|
|
|
479
521
|
#### 浏览器模式特有参数
|
|
480
522
|
- `waitForSelector`: 浏览器模式下等待的选择器(可选,默认为'body')
|
|
@@ -513,6 +555,15 @@ console.log('调试获取提示:', debugPrompt);
|
|
|
513
555
|
- `[NODE-FETCH]`: Node.js获取器的日志
|
|
514
556
|
- `[BROWSER-FETCH]`: 浏览器获取器的日志
|
|
515
557
|
- `[CLIENT]`: 客户端的日志
|
|
558
|
+
- `[TOOLS]`: 工具实现的日志
|
|
559
|
+
- `[FETCHER]`: 主获取器接口的日志
|
|
560
|
+
- `[CONTENT]`: 内容处理相关的日志
|
|
561
|
+
- `[CONTENT-PROCESSOR]`: HTML内容处理器的日志
|
|
562
|
+
- `[CONTENT-SIZE]`: 内容大小管理相关的日志
|
|
563
|
+
- `[CHUNK-MANAGER]`: 内容分块操作相关的日志
|
|
564
|
+
- `[ERROR-HANDLER]`: 错误处理相关的日志
|
|
565
|
+
- `[BROWSER-MANAGER]`: 浏览器实例管理器的日志
|
|
566
|
+
|
|
516
567
|
|
|
517
568
|
## 许可证
|
|
518
569
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2025-03-
|
|
3
|
-
"totalKeys":
|
|
4
|
-
"totalUsedKeys":
|
|
5
|
-
"totalFiles":
|
|
2
|
+
"timestamp": "2025-03-19T09:24:59.700Z",
|
|
3
|
+
"totalKeys": 572,
|
|
4
|
+
"totalUsedKeys": 572,
|
|
5
|
+
"totalFiles": 236,
|
|
6
6
|
"unusedKeys": [],
|
|
7
7
|
"hasUnusedKeys": false
|
|
8
8
|
}
|