@lmcc-dev/mult-fetch-mcp-server 1.0.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/LICENSE +21 -0
- package/README.md +512 -0
- package/README.zh.md +510 -0
- package/dist/index.js +21 -0
- package/dist/src/cli-language.js +78 -0
- package/dist/src/client.js +284 -0
- package/dist/src/index.js +21 -0
- package/dist/src/lib/BrowserFetcher.js +753 -0
- package/dist/src/lib/NodeFetcher.js +428 -0
- package/dist/src/lib/example.js +93 -0
- package/dist/src/lib/i18n/index.js +36 -0
- package/dist/src/lib/i18n/locales/en/browser.js +53 -0
- package/dist/src/lib/i18n/locales/en/client.js +40 -0
- package/dist/src/lib/i18n/locales/en/errors.js +18 -0
- package/dist/src/lib/i18n/locales/en/fetcher.js +67 -0
- package/dist/src/lib/i18n/locales/en/index.js +26 -0
- package/dist/src/lib/i18n/locales/en/node.js +42 -0
- package/dist/src/lib/i18n/locales/en/prompts.js +72 -0
- package/dist/src/lib/i18n/locales/en/resources.js +47 -0
- package/dist/src/lib/i18n/locales/en/server.js +32 -0
- package/dist/src/lib/i18n/locales/en/tools.js +25 -0
- package/dist/src/lib/i18n/locales/zh/browser.js +53 -0
- package/dist/src/lib/i18n/locales/zh/client.js +39 -0
- package/dist/src/lib/i18n/locales/zh/errors.js +18 -0
- package/dist/src/lib/i18n/locales/zh/fetcher.js +67 -0
- package/dist/src/lib/i18n/locales/zh/index.js +26 -0
- package/dist/src/lib/i18n/locales/zh/node.js +42 -0
- package/dist/src/lib/i18n/locales/zh/prompts.js +72 -0
- package/dist/src/lib/i18n/locales/zh/resources.js +47 -0
- package/dist/src/lib/i18n/locales/zh/server.js +32 -0
- package/dist/src/lib/i18n/locales/zh/tools.js +25 -0
- package/dist/src/lib/i18n/logger.js +57 -0
- package/dist/src/lib/logger.js +126 -0
- package/dist/src/lib/server/browser.js +86 -0
- package/dist/src/lib/server/fetcher.js +130 -0
- package/dist/src/lib/server/index.js +73 -0
- package/dist/src/lib/server/logger.js +23 -0
- package/dist/src/lib/server/prompts.js +207 -0
- package/dist/src/lib/server/resources.js +171 -0
- package/dist/src/lib/server/tools.js +346 -0
- package/dist/src/lib/server/types.js +6 -0
- package/dist/src/lib/types.js +35 -0
- package/dist/src/mcp-server.js +22 -0
- package/dist/tests/test-direct-client.js +129 -0
- package/dist/tests/test-mcp-methods.js +114 -0
- package/dist/tests/test-mcp.js +145 -0
- package/dist/tests/test-mini4k.js +147 -0
- package/images/example_en.png +0 -0
- package/images/example_zh.png +0 -0
- package/package.json +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Martin (@lmcc.dev)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
# mult-fetch-mcp-server
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/mult-fetch-mcp-server)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://github.com/modelcontextprotocol/typescript-sdk)
|
|
8
|
+
[](https://github.com/lmcc-dev/mult-fetch-mcp-server/stargazers)
|
|
9
|
+
[](https://github.com/lmcc-dev/mult-fetch-mcp-server/network/members)
|
|
10
|
+
[](https://github.com/lmcc-dev/mult-fetch-mcp-server/issues)
|
|
11
|
+
[](https://github.com/lmcc-dev/mult-fetch-mcp-server/pulls)
|
|
12
|
+
[](https://www.npmjs.com/package/mult-fetch-mcp-server)
|
|
13
|
+
[](https://github.com/lmcc-dev/mult-fetch-mcp-server/commits/main)
|
|
14
|
+
[](https://github.com/lmcc-dev/mult-fetch-mcp-server/graphs/contributors)
|
|
15
|
+
|
|
16
|
+
<!-- Future badges to consider:
|
|
17
|
+
[](https://codecov.io/gh/lmcc-dev/mult-fetch-mcp-server)
|
|
18
|
+
[](https://www.codefactor.io/repository/github/lmcc-dev/mult-fetch-mcp-server)
|
|
19
|
+
[](https://codeclimate.com/github/lmcc-dev/mult-fetch-mcp-server/maintainability)
|
|
20
|
+
-->
|
|
21
|
+
|
|
22
|
+
This project implements an MCP-compliant client and server for communication between AI assistants and external tools.
|
|
23
|
+
|
|
24
|
+
[English](./README.md) | [中文文档](./README.zh.md)
|
|
25
|
+
|
|
26
|
+
## Project Structure
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
fetch-mcp/
|
|
30
|
+
├── src/ # Source code directory
|
|
31
|
+
│ ├── lib/ # Library files
|
|
32
|
+
│ │ ├── BrowserFetcher.ts # Browser mode fetcher
|
|
33
|
+
│ │ ├── NodeFetcher.ts # Node.js mode fetcher
|
|
34
|
+
│ │ ├── server/ # Server-related modules
|
|
35
|
+
│ │ │ ├── index.ts # Server entry point
|
|
36
|
+
│ │ │ ├── browser.ts # Browser management
|
|
37
|
+
│ │ │ ├── fetcher.ts # Web fetching logic
|
|
38
|
+
│ │ │ ├── logger.ts # Logging utilities
|
|
39
|
+
│ │ │ ├── tools.ts # Tool registration and handling
|
|
40
|
+
│ │ │ └── types.ts # Server type definitions
|
|
41
|
+
│ │ ├── i18n/ # Internationalization support
|
|
42
|
+
│ │ │ ├── index.ts # i18n configuration
|
|
43
|
+
│ │ │ └── logger.ts # i18n logger utilities
|
|
44
|
+
│ │ └── types.ts # Common type definitions
|
|
45
|
+
│ ├── client.ts # MCP client implementation
|
|
46
|
+
│ └── mcp-server.ts # MCP server main entry
|
|
47
|
+
├── index.ts # Server entry point
|
|
48
|
+
├── tests/ # Test files
|
|
49
|
+
│ ├── test-mcp.ts # MCP functionality tests
|
|
50
|
+
│ ├── test-mini4k.ts # Specific website tests
|
|
51
|
+
│ └── test-direct-client.ts # Direct client call tests
|
|
52
|
+
└── dist/ # Compiled files
|
|
53
|
+
├── index.js # Compiled entry point
|
|
54
|
+
├── src/ # Compiled source code
|
|
55
|
+
└── tests/ # Compiled test files
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## MCP Specification
|
|
59
|
+
|
|
60
|
+
The Model Context Protocol (MCP) defines two main transport methods:
|
|
61
|
+
|
|
62
|
+
1. **Standard Input/Output (Stdio)**: The client starts the MCP server as a child process, and they communicate through standard input (stdin) and standard output (stdout).
|
|
63
|
+
2. **Server-Sent Events (SSE)**: Used to pass messages between client and server.
|
|
64
|
+
|
|
65
|
+
This project implements the Standard Input/Output (Stdio) transport method.
|
|
66
|
+
|
|
67
|
+
## Features
|
|
68
|
+
|
|
69
|
+
- Implementation based on the official MCP SDK
|
|
70
|
+
- Support for Standard Input/Output (Stdio) transport
|
|
71
|
+
- Multiple web scraping methods (HTML, JSON, text, Markdown)
|
|
72
|
+
- Intelligent mode switching: automatically switches between standard requests and browser mode
|
|
73
|
+
- Detailed debug logs output to standard error stream
|
|
74
|
+
- Support for Chinese and English bilingual internationalization
|
|
75
|
+
- Modular design for easy maintenance and extension
|
|
76
|
+
|
|
77
|
+
## Installation
|
|
78
|
+
|
|
79
|
+
### Local Installation
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm install
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Global Installation
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm install -g mult-fetch-mcp-server
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Or use npx to run directly (no installation required):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npx mult-fetch-mcp-server
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Integration with Claude
|
|
98
|
+
|
|
99
|
+
To integrate this tool with Claude desktop, you need to add server configuration:
|
|
100
|
+
|
|
101
|
+
### Configuration File Location
|
|
102
|
+
|
|
103
|
+
- **MacOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
104
|
+
- **Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
105
|
+
|
|
106
|
+
### Configuration Examples
|
|
107
|
+
|
|
108
|
+
#### Method 1: Using npx (Recommended)
|
|
109
|
+
|
|
110
|
+
This method is the simplest, doesn't require specifying the full path, and is suitable for global installation or direct use with npx:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"mcpServers": {
|
|
115
|
+
"mult-fetch-mcp-server": {
|
|
116
|
+
"command": "npx",
|
|
117
|
+
"args": ["mult-fetch-mcp-server"],
|
|
118
|
+
"env": {
|
|
119
|
+
"MCP_LANG": "en" // Set language to English, options: "zh" or "en"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Method 2: Specifying Full Path
|
|
127
|
+
|
|
128
|
+
If you need to use a specific installation location, you can specify the full path:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"mcpServers": {
|
|
133
|
+
"mult-fetch-mcp-server": {
|
|
134
|
+
"command": "path-to/bin/node",
|
|
135
|
+
"args": ["path-to/mult-fetch-mcp-server/dist/index.js"],
|
|
136
|
+
"env": {
|
|
137
|
+
"MCP_LANG": "en" // Set language to English, options: "zh" or "en"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Please replace `path-to/bin/node` with the path to the Node.js executable on your system, and replace `path-to/mult-fetch-mcp-server` with the actual path to this project.
|
|
145
|
+
|
|
146
|
+
### Usage Examples
|
|
147
|
+
|
|
148
|
+
Below is an example of using this tool in Claude desktop client:
|
|
149
|
+
|
|
150
|
+

|
|
151
|
+
|
|
152
|
+
The image shows how Claude can use the fetch tools to retrieve web content and process it according to your instructions.
|
|
153
|
+
|
|
154
|
+
### Usage
|
|
155
|
+
|
|
156
|
+
After configuration, restart Claude desktop, and you can use the following tools in your conversation:
|
|
157
|
+
|
|
158
|
+
- `fetch_html`: Get HTML content of a webpage
|
|
159
|
+
- `fetch_json`: Get JSON data
|
|
160
|
+
- `fetch_txt`: Get plain text content
|
|
161
|
+
- `fetch_markdown`: Get Markdown formatted content
|
|
162
|
+
|
|
163
|
+
## Build
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npm run build
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Run Server
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npm run server
|
|
173
|
+
# or
|
|
174
|
+
node dist/index.js
|
|
175
|
+
# if globally installed, you can run directly
|
|
176
|
+
mult-fetch-mcp-server
|
|
177
|
+
# or use npx
|
|
178
|
+
npx mult-fetch-mcp-server
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Run Client
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm run client <method> <params_json>
|
|
185
|
+
# example
|
|
186
|
+
npm run client fetch_html '{"url": "https://example.com", "debug": true}'
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Run Tests
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Run MCP functionality tests
|
|
193
|
+
npm run test:mcp
|
|
194
|
+
|
|
195
|
+
# Run mini4k.com website tests
|
|
196
|
+
npm run test:mini4k
|
|
197
|
+
|
|
198
|
+
# Run direct client call tests
|
|
199
|
+
npm run test:direct
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Language Settings
|
|
203
|
+
|
|
204
|
+
This project supports Chinese and English bilingual internationalization. You can set the language using environment variables:
|
|
205
|
+
|
|
206
|
+
### Using Environment Variables
|
|
207
|
+
|
|
208
|
+
Set the `MCP_LANG` environment variable to control the language:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Set to English
|
|
212
|
+
export MCP_LANG=en
|
|
213
|
+
npm run server
|
|
214
|
+
|
|
215
|
+
# Set to Chinese
|
|
216
|
+
export MCP_LANG=zh
|
|
217
|
+
npm run server
|
|
218
|
+
|
|
219
|
+
# Windows system
|
|
220
|
+
set MCP_LANG=zh
|
|
221
|
+
npm run server
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Using environment variables ensures that all related processes (including the MCP server) use the same language settings.
|
|
225
|
+
|
|
226
|
+
### Default Language
|
|
227
|
+
|
|
228
|
+
By default, the system will choose a language according to the following priority:
|
|
229
|
+
1. `MCP_LANG` environment variable
|
|
230
|
+
2. Operating system language (if it starts with "zh", use Chinese)
|
|
231
|
+
3. English (as the final fallback option)
|
|
232
|
+
|
|
233
|
+
## Debugging
|
|
234
|
+
|
|
235
|
+
This project follows the MCP protocol specification and does not output any logs by default to avoid interfering with JSON-RPC communication. Debug information is controlled through call parameters:
|
|
236
|
+
|
|
237
|
+
### Using the debug Parameter
|
|
238
|
+
|
|
239
|
+
Set the `debug: true` parameter when calling a tool:
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"url": "https://example.com",
|
|
244
|
+
"debug": true
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Debug messages are sent to the standard error stream (stderr) using the following format:
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
[MCP-SERVER] MCP server starting...
|
|
252
|
+
[CLIENT] Fetching URL: https://example.com
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Debug Log File
|
|
256
|
+
|
|
257
|
+
When debug mode is enabled, all debug messages are also written to a log file located at:
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
~/.mult-fetch-mcp-server/debug.log
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
This log file can be accessed through the MCP resources API:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
// Access the debug log file
|
|
267
|
+
const result = await client.readResource({ uri: "file:///logs/debug" });
|
|
268
|
+
console.log(result.contents[0].text);
|
|
269
|
+
|
|
270
|
+
// Clear the debug log file
|
|
271
|
+
const clearResult = await client.readResource({ uri: "file:///logs/clear" });
|
|
272
|
+
console.log(clearResult.contents[0].text);
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Proxy Settings
|
|
276
|
+
|
|
277
|
+
This tool supports various methods to configure proxy settings:
|
|
278
|
+
|
|
279
|
+
### 1. Using the `proxy` Parameter
|
|
280
|
+
|
|
281
|
+
The most direct way is to specify the proxy in the request parameters:
|
|
282
|
+
|
|
283
|
+
```json
|
|
284
|
+
{
|
|
285
|
+
"url": "https://example.com",
|
|
286
|
+
"proxy": "http://your-proxy-server:port",
|
|
287
|
+
"debug": true
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### 2. Using Environment Variables
|
|
292
|
+
|
|
293
|
+
The tool will automatically detect and use proxy settings from standard environment variables:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# Set proxy environment variables
|
|
297
|
+
export HTTP_PROXY=http://your-proxy-server:port
|
|
298
|
+
export HTTPS_PROXY=http://your-proxy-server:port
|
|
299
|
+
|
|
300
|
+
# Run the server
|
|
301
|
+
npm run server
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### 3. System Proxy Detection
|
|
305
|
+
|
|
306
|
+
The tool attempts to detect system proxy settings based on your operating system:
|
|
307
|
+
|
|
308
|
+
- **Windows**: Reads proxy settings from environment variables using the `set` command
|
|
309
|
+
- **macOS/Linux**: Reads proxy settings from environment variables using the `env` command
|
|
310
|
+
|
|
311
|
+
### 4. Proxy Troubleshooting
|
|
312
|
+
|
|
313
|
+
If you're having issues with proxy detection:
|
|
314
|
+
|
|
315
|
+
1. Use the `debug: true` parameter to see detailed logs about proxy detection
|
|
316
|
+
2. Explicitly specify the proxy using the `proxy` parameter
|
|
317
|
+
3. Ensure your proxy URL is in the correct format: `http://host:port` or `https://host:port`
|
|
318
|
+
4. For websites that require browser capabilities, set `useBrowser: true` to use browser mode
|
|
319
|
+
|
|
320
|
+
### 5. Browser Mode and Proxies
|
|
321
|
+
|
|
322
|
+
When using browser mode (`useBrowser: true`), the tool will:
|
|
323
|
+
|
|
324
|
+
1. First try to use the explicitly specified proxy (if provided)
|
|
325
|
+
2. Then try to use system proxy settings
|
|
326
|
+
3. Finally, proceed without a proxy if none is found
|
|
327
|
+
|
|
328
|
+
Browser mode is particularly useful for websites that implement anti-scraping measures or require JavaScript execution.
|
|
329
|
+
|
|
330
|
+
## Parameter Handling
|
|
331
|
+
|
|
332
|
+
This project handles parameters in the following ways:
|
|
333
|
+
|
|
334
|
+
- **debug**: Passed through call parameters, each request can individually control whether to enable debug output
|
|
335
|
+
- **MCP_LANG**: Retrieved from environment variables, controls the language settings of the entire server
|
|
336
|
+
|
|
337
|
+
## Usage
|
|
338
|
+
|
|
339
|
+
### Creating a Client
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
343
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
344
|
+
import path from 'path';
|
|
345
|
+
import { fileURLToPath } from 'url';
|
|
346
|
+
|
|
347
|
+
// Get the directory path of the current file
|
|
348
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
349
|
+
const __dirname = path.dirname(__filename);
|
|
350
|
+
|
|
351
|
+
// Create client transport layer
|
|
352
|
+
const transport = new StdioClientTransport({
|
|
353
|
+
command: 'node',
|
|
354
|
+
args: [path.resolve(__dirname, 'dist/index.js')],
|
|
355
|
+
stderr: 'inherit',
|
|
356
|
+
env: {
|
|
357
|
+
...process.env // Pass all environment variables, including MCP_LANG
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// Create client
|
|
362
|
+
const client = new Client({
|
|
363
|
+
name: "example-client",
|
|
364
|
+
version: "1.0.0"
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
// Connect to transport layer
|
|
368
|
+
await client.connect(transport);
|
|
369
|
+
|
|
370
|
+
// Use client
|
|
371
|
+
const result = await client.callTool({
|
|
372
|
+
name: 'fetch_html',
|
|
373
|
+
arguments: {
|
|
374
|
+
url: 'https://example.com',
|
|
375
|
+
debug: true // Control debug output through parameters
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
if (result.isError) {
|
|
380
|
+
console.error('Fetch failed:', result.content[0].text);
|
|
381
|
+
} else {
|
|
382
|
+
console.log('Fetch successful!');
|
|
383
|
+
console.log('Content preview:', result.content[0].text.substring(0, 500));
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Supported Tools
|
|
388
|
+
|
|
389
|
+
- `fetch_html`: Get HTML content of a webpage
|
|
390
|
+
- `fetch_json`: Get JSON data
|
|
391
|
+
- `fetch_txt`: Get plain text content
|
|
392
|
+
- `fetch_markdown`: Get Markdown formatted content
|
|
393
|
+
|
|
394
|
+
### Resources Support
|
|
395
|
+
|
|
396
|
+
The server includes support for the resources/list and resources/read methods, but currently no resources are defined in the implementation. The resource system is designed to provide access to project files and documentation, but this feature is not fully implemented yet.
|
|
397
|
+
|
|
398
|
+
#### Resource Usage Example
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
// Example: List available resources
|
|
402
|
+
const resourcesResult = await client.listResources({});
|
|
403
|
+
console.log('Available resources:', resourcesResult);
|
|
404
|
+
|
|
405
|
+
// Note: Currently this will return empty lists for resources and resourceTemplates
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Supported Prompt Templates
|
|
409
|
+
|
|
410
|
+
The server provides the following prompt templates:
|
|
411
|
+
|
|
412
|
+
- `fetch-website`: Get website content, supporting different formats and browser mode
|
|
413
|
+
- `extract-content`: Extract specific content from a website, supporting CSS selectors and data type specification
|
|
414
|
+
- `debug-fetch`: Debug website fetching issues, analyze possible causes and provide solutions
|
|
415
|
+
|
|
416
|
+
#### Prompt Template Usage
|
|
417
|
+
|
|
418
|
+
1. Use `prompts/list` to get a list of available prompt templates
|
|
419
|
+
2. Use `prompts/get` to get specific prompt template content
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
// Example: List available prompt templates
|
|
423
|
+
const promptsResult = await client.listPrompts({});
|
|
424
|
+
console.log('Available prompts:', promptsResult);
|
|
425
|
+
|
|
426
|
+
// Example: Get website content prompt
|
|
427
|
+
const fetchPrompt = await client.getPrompt({
|
|
428
|
+
name: "fetch-website",
|
|
429
|
+
arguments: {
|
|
430
|
+
url: "https://example.com",
|
|
431
|
+
format: "html",
|
|
432
|
+
useBrowser: "false"
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
console.log('Fetch website prompt:', fetchPrompt);
|
|
436
|
+
|
|
437
|
+
// Example: Debug website fetching issues
|
|
438
|
+
const debugPrompt = await client.getPrompt({
|
|
439
|
+
name: "debug-fetch",
|
|
440
|
+
arguments: {
|
|
441
|
+
url: "https://example.com",
|
|
442
|
+
error: "Connection timeout"
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
console.log('Debug fetch prompt:', debugPrompt);
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Parameter Options
|
|
449
|
+
|
|
450
|
+
Each tool supports the following parameters:
|
|
451
|
+
|
|
452
|
+
#### Basic Parameters
|
|
453
|
+
- `url`: URL to fetch (required)
|
|
454
|
+
- `headers`: Custom request headers (optional, default is {})
|
|
455
|
+
- `proxy`: Proxy server URL in format http://host:port or https://host:port (optional)
|
|
456
|
+
|
|
457
|
+
#### Network Control Parameters
|
|
458
|
+
- `timeout`: Timeout in milliseconds (optional, default is 30000)
|
|
459
|
+
- `maxRedirects`: Maximum number of redirects to follow (optional, default is 10)
|
|
460
|
+
- `noDelay`: Whether to disable random delay between requests (optional, default is false)
|
|
461
|
+
- `useSystemProxy`: Whether to use system proxy (optional, default is true)
|
|
462
|
+
|
|
463
|
+
#### Mode Control Parameters
|
|
464
|
+
- `useBrowser`: Whether to use browser mode (optional, default is false)
|
|
465
|
+
- `useNodeFetch`: Whether to force using Node.js mode (optional, default is false, mutually exclusive with `useBrowser`)
|
|
466
|
+
- `autoDetectMode`: Whether to automatically detect and switch to browser mode (optional, default is true)
|
|
467
|
+
|
|
468
|
+
#### Browser Mode Specific Parameters
|
|
469
|
+
- `waitForSelector`: Selector to wait for in browser mode (optional, default is 'body')
|
|
470
|
+
- `waitForTimeout`: Timeout to wait in browser mode in milliseconds (optional, default is 5000)
|
|
471
|
+
- `scrollToBottom`: Whether to scroll to the bottom of the page in browser mode (optional, default is false)
|
|
472
|
+
- `saveCookies`: Whether to save cookies in browser mode (optional, default is true)
|
|
473
|
+
- `closeBrowser`: Whether to close the browser instance (optional, default is false)
|
|
474
|
+
|
|
475
|
+
#### Debug Parameters
|
|
476
|
+
- `debug`: Whether to enable debug output (optional, default is false)
|
|
477
|
+
|
|
478
|
+
### Special Usage
|
|
479
|
+
|
|
480
|
+
#### Closing Browser Without Fetching
|
|
481
|
+
To close the browser instance without performing any fetch operation:
|
|
482
|
+
```json
|
|
483
|
+
{
|
|
484
|
+
"url": "about:blank",
|
|
485
|
+
"closeBrowser": true
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
#### Proxy Priority
|
|
490
|
+
The proxy is determined in the following order:
|
|
491
|
+
1. Command line specified proxy
|
|
492
|
+
2. `proxy` parameter in the request
|
|
493
|
+
3. Environment variables (if `useSystemProxy` is true)
|
|
494
|
+
4. Git configuration (if `useSystemProxy` is true)
|
|
495
|
+
|
|
496
|
+
If `proxy` is set, `useSystemProxy` will be automatically set to false.
|
|
497
|
+
|
|
498
|
+
### Debug Output
|
|
499
|
+
|
|
500
|
+
When `debug: true` is set, the logs will be output to stderr with the following prefixes:
|
|
501
|
+
- `[MCP-SERVER]`: Logs from the MCP server
|
|
502
|
+
- `[NODE-FETCH]`: Logs from the Node.js fetcher
|
|
503
|
+
- `[BROWSER-FETCH]`: Logs from the browser fetcher
|
|
504
|
+
- `[CLIENT]`: Logs from the client
|
|
505
|
+
|
|
506
|
+
## License
|
|
507
|
+
|
|
508
|
+
MIT
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
Updated by lmcc-dev
|