@jnohlgard/fetch-mcp 2.2.0
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 +168 -0
- package/dist/index.js +35973 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Zach Caceres (https://zach.dev), Piotr Wilkin (ilintar@gmail.com)
|
|
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,168 @@
|
|
|
1
|
+
# Fetch MCP Server
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@jnohlgard/fetch-mcp)
|
|
6
|
+
|
|
7
|
+
An MCP server for fetching web content in multiple formats — HTML, JSON, plain text, Markdown, readable article content, and YouTube transcripts.
|
|
8
|
+
|
|
9
|
+
> This repository is a fork of [zcaceres/fetch-mcp](https://github.com/zcaceres/fetch-mcp) by [Zach Caceres](https://zach.dev), with contributions from Piotr Wilkin, originally published on npm as `mcp-fetch-server`. It builds on that original work and republishes it under its own scope; the original project remains MIT-licensed and that license is retained here.
|
|
10
|
+
|
|
11
|
+
## Tools
|
|
12
|
+
|
|
13
|
+
All tools accept the following common parameters:
|
|
14
|
+
|
|
15
|
+
| Parameter | Type | Required | Description |
|
|
16
|
+
|-----------|------|----------|-------------|
|
|
17
|
+
| `url` | string | Yes | URL to fetch |
|
|
18
|
+
| `headers` | object | No | Custom headers to include in the request |
|
|
19
|
+
| `max_length` | number | No | Maximum characters to return (default: 5000) |
|
|
20
|
+
| `start_index` | number | No | Start from this character index (default: 0) |
|
|
21
|
+
| `proxy` | string | No | Proxy URL (e.g. `http://proxy:8080`) — only honored when running under Bun |
|
|
22
|
+
|
|
23
|
+
> **Note:** `proxy` is a Bun-specific `fetch()` option. It is silently ignored when the server runs on Node (the default `npx` install path), so requests go direct in that case.
|
|
24
|
+
|
|
25
|
+
- **fetch_html** — Fetch a website and return its raw HTML content.
|
|
26
|
+
|
|
27
|
+
- **fetch_markdown** — Fetch a website and return its content converted to Markdown.
|
|
28
|
+
|
|
29
|
+
- **fetch_txt** — Fetch a website and return plain text with HTML tags, scripts, and styles removed.
|
|
30
|
+
|
|
31
|
+
- **fetch_json** — Fetch a URL and return the JSON response.
|
|
32
|
+
|
|
33
|
+
- **fetch_readable** — Fetch a website and extract the main article content using [Mozilla Readability](https://github.com/mozilla/readability), returned as Markdown. Strips navigation, ads, and boilerplate. Ideal for articles and blog posts. Accepts an optional `fallback` parameter (`"markdown"`, `"txt"`, or `"none"`, default `"none"`): when no article can be extracted, the whole page is returned in the fallback format instead of an error.
|
|
34
|
+
|
|
35
|
+
- **fetch_youtube_transcript** — Fetch a YouTube video's captions/transcript. Uses `yt-dlp` if available, otherwise extracts directly from the page. Accepts an additional `lang` parameter (default: `"en"`) to select the caption language.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### As an MCP server
|
|
40
|
+
|
|
41
|
+
Add to your MCP client configuration:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"mcpServers": {
|
|
46
|
+
"fetch": {
|
|
47
|
+
"command": "npx",
|
|
48
|
+
"args": ["@jnohlgard/fetch-mcp", "serve"]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### As a CLI
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx @jnohlgard/fetch-mcp <command> <url> [flags]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or install globally:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install -g @jnohlgard/fetch-mcp
|
|
64
|
+
fetch-mcp <command> <url> [flags]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## CLI Usage
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
fetch-mcp <command> <url> [flags]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Commands
|
|
74
|
+
|
|
75
|
+
| Command | Description |
|
|
76
|
+
|---------|-------------|
|
|
77
|
+
| `serve` | Start the MCP server over stdio |
|
|
78
|
+
| `html` | Fetch a URL and return raw HTML |
|
|
79
|
+
| `markdown` | Fetch a URL and return Markdown |
|
|
80
|
+
| `readable` | Fetch a URL and return article content as Markdown (via Readability) |
|
|
81
|
+
| `txt` | Fetch a URL and return plain text |
|
|
82
|
+
| `json` | Fetch a URL and return JSON |
|
|
83
|
+
| `youtube` | Fetch a YouTube video transcript |
|
|
84
|
+
|
|
85
|
+
### Flags
|
|
86
|
+
|
|
87
|
+
| Flag | Description |
|
|
88
|
+
|------|-------------|
|
|
89
|
+
| `--max-length <N>` | Maximum characters to return |
|
|
90
|
+
| `--start-index <N>` | Start from this character index |
|
|
91
|
+
| `--proxy <URL>` | Proxy URL (only honored when running under Bun) |
|
|
92
|
+
| `--lang <code>` | Language code for YouTube transcripts (default: `en`) |
|
|
93
|
+
| `--help` | Show help message |
|
|
94
|
+
| `--version` | Show version |
|
|
95
|
+
|
|
96
|
+
### Examples
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Fetch a page as markdown
|
|
100
|
+
fetch-mcp markdown https://example.com
|
|
101
|
+
|
|
102
|
+
# Extract article content without boilerplate
|
|
103
|
+
fetch-mcp readable https://example.com/blog/post
|
|
104
|
+
|
|
105
|
+
# Get a YouTube transcript in Spanish
|
|
106
|
+
fetch-mcp youtube https://www.youtube.com/watch?v=dQw4w9WgXcQ --lang es
|
|
107
|
+
|
|
108
|
+
# Fetch with a length limit
|
|
109
|
+
fetch-mcp html https://example.com --max-length 10000
|
|
110
|
+
|
|
111
|
+
# Fetch through a proxy (Bun only — silently ignored when running on Node)
|
|
112
|
+
fetch-mcp json https://api.example.com/data --proxy http://proxy:8080
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Environment Variables
|
|
116
|
+
|
|
117
|
+
| Variable | Description |
|
|
118
|
+
|----------|-------------|
|
|
119
|
+
| `DEFAULT_LIMIT` | Default character limit for responses (default: `5000`, set to `0` for no limit) |
|
|
120
|
+
| `MAX_RESPONSE_BYTES` | Maximum response body size in bytes (default: `10485760` / 10 MB) |
|
|
121
|
+
| `FETCH_TIMEOUT_MS` | Per-request timeout in milliseconds. Each redirect hop gets its own budget (default: `30000` / 30 s) |
|
|
122
|
+
| `FETCH_CAPTION_TIMEOUT_MS` | Timeout for the auxiliary YouTube caption fetch (default: `10000` / 10 s) |
|
|
123
|
+
| `MAX_CONCURRENT_FETCHES` | Max concurrent outbound fetches in this process; extra requests queue until a slot frees up (default: `10`, set to `0` for unlimited) |
|
|
124
|
+
| `PARSE_TIMEOUT_MS` | Deadline for HTML parsing (jsdom/Readability/Turndown) in `fetch_txt`/`fetch_readable` in milliseconds; a clear error is returned when parsing outlives the deadline (default: `10000` / 10 s) |
|
|
125
|
+
| `FETCH_LOGGING` | Structured per-request log line on stderr (host, status, duration, bytes) for correlating agent behavior with egress; only the host is ever logged, never the URL path, query, or headers (default: on, set to `0` to disable) |
|
|
126
|
+
|
|
127
|
+
Example with a custom limit:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"mcpServers": {
|
|
132
|
+
"fetch": {
|
|
133
|
+
"command": "npx",
|
|
134
|
+
"args": ["@jnohlgard/fetch-mcp", "serve"],
|
|
135
|
+
"env": {
|
|
136
|
+
"DEFAULT_LIMIT": "50000"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Features
|
|
144
|
+
|
|
145
|
+
- Fetch web content as HTML, JSON, plain text, or Markdown
|
|
146
|
+
- Extract article content with Mozilla Readability (strips ads, nav, boilerplate)
|
|
147
|
+
- Extract YouTube video transcripts (via `yt-dlp` or direct extraction)
|
|
148
|
+
- Proxy support for requests behind firewalls (Bun only; silently ignored when running on Node)
|
|
149
|
+
- Pagination with `max_length` and `start_index`
|
|
150
|
+
- Custom request headers
|
|
151
|
+
- SSRF protection (blocks private/localhost addresses, IPv4-mapped IPv6 addresses, DNS-rebinding to private IPs on the first resolution, and every redirect hop before it fires)
|
|
152
|
+
- Credential headers (`Authorization`, `Cookie`, `Proxy-Authorization`) are stripped from redirect hops that cross to a different origin
|
|
153
|
+
- Response size limits to prevent memory exhaustion
|
|
154
|
+
- Per-request timeouts (30 s per redirect hop, 10 s for the YouTube caption fetch) so a hung or slowloris connection cannot block a request indefinitely
|
|
155
|
+
- Structured per-request logging on stderr (host, status, duration, bytes) for correlating agent behavior with cluster egress; only the host is ever logged, never the URL path, query, or headers
|
|
156
|
+
|
|
157
|
+
## Development
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
bun install
|
|
161
|
+
bun run dev # start with watch mode
|
|
162
|
+
bun test # run tests
|
|
163
|
+
bun run build # build for production
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
This project is licensed under the MIT License.
|