@j0hanz/superfetch 2.5.3 → 2.6.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/README.md +350 -226
- package/dist/assets/logo.svg +24837 -24835
- package/dist/cache.d.ts +28 -20
- package/dist/cache.js +292 -514
- package/dist/config.d.ts +41 -7
- package/dist/config.js +298 -148
- package/dist/crypto.js +25 -12
- package/dist/dom-noise-removal.js +379 -421
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +25 -8
- package/dist/fetch.d.ts +18 -16
- package/dist/fetch.js +1132 -526
- package/dist/host-normalization.js +40 -10
- package/dist/http-native.js +628 -287
- package/dist/index.js +67 -7
- package/dist/instructions.md +44 -31
- package/dist/ip-blocklist.d.ts +8 -0
- package/dist/ip-blocklist.js +65 -0
- package/dist/json.js +14 -9
- package/dist/language-detection.d.ts +2 -11
- package/dist/language-detection.js +289 -280
- package/dist/markdown-cleanup.d.ts +0 -1
- package/dist/markdown-cleanup.js +391 -429
- package/dist/mcp-validator.js +4 -2
- package/dist/mcp.js +184 -135
- package/dist/observability.js +89 -21
- package/dist/resources.js +16 -6
- package/dist/server-tuning.d.ts +2 -0
- package/dist/server-tuning.js +25 -23
- package/dist/session.d.ts +1 -0
- package/dist/session.js +41 -33
- package/dist/tasks.d.ts +2 -0
- package/dist/tasks.js +91 -9
- package/dist/timer-utils.d.ts +5 -0
- package/dist/timer-utils.js +20 -0
- package/dist/tools.d.ts +28 -5
- package/dist/tools.js +317 -183
- package/dist/transform-types.d.ts +5 -1
- package/dist/transform.d.ts +3 -2
- package/dist/transform.js +1138 -421
- package/dist/type-guards.d.ts +1 -0
- package/dist/type-guards.js +7 -0
- package/dist/workers/transform-child.d.ts +1 -0
- package/dist/workers/transform-child.js +118 -0
- package/dist/workers/transform-worker.js +87 -78
- package/package.json +14 -6
package/README.md
CHANGED
|
@@ -4,18 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
<img src="assets/logo.svg" alt="SuperFetch MCP Logo" width="300">
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/@j0hanz/superfetch) [](https://opensource.org/licenses/MIT) [](https://nodejs.org) [](https://www.typescriptlang.org) [](https://modelcontextprotocol.io)
|
|
8
8
|
|
|
9
|
-
[](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22superfetch%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fsuperfetch%40latest%22%2C%22--stdio%22%5D%7D) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%7B%22name%22%3A%22superfetch%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fsuperfetch%40latest%22%2C%22--stdio%22%5D%7D) [](https://cursor.com/install-mcp?name=superfetch&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovc3VwZXJmZXRjaEBsYXRlc3QiLCItLXN0ZGlvIl19)
|
|
10
10
|
|
|
11
|
-
Fetch and convert public web
|
|
11
|
+
Fetch and convert public web content to clean Markdown both readable by humans and optimized for LLM context.
|
|
12
12
|
|
|
13
13
|
## Overview
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
primary content, and converts it into clean Markdown. It runs either as a stdio
|
|
17
|
-
MCP server (for local clients) or as a Streamable HTTP MCP server with auth,
|
|
18
|
-
cache, and SSRF protections.
|
|
15
|
+
superFetch is a [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that fetches public web pages, extracts meaningful content using Mozilla's Readability algorithm, and converts the result into clean Markdown optimized for LLM context windows. It handles noise removal, caching, SSRF protection, async task execution, and supports both stdio and Streamable HTTP transports.
|
|
19
16
|
|
|
20
17
|
## Key Features
|
|
21
18
|
|
|
@@ -33,63 +30,93 @@ cache, and SSRF protections.
|
|
|
33
30
|
|
|
34
31
|
## Tech Stack
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
| Component | Technology |
|
|
34
|
+
| ------------------- | ----------------------------------- |
|
|
35
|
+
| Runtime | Node.js ≥ 24 |
|
|
36
|
+
| Language | TypeScript 5.9 |
|
|
37
|
+
| MCP SDK | `@modelcontextprotocol/sdk` ^1.26.0 |
|
|
38
|
+
| Content Extraction | `@mozilla/readability` ^0.6.0 |
|
|
39
|
+
| DOM Parsing | `linkedom` ^0.18.12 |
|
|
40
|
+
| Markdown Conversion | `node-html-markdown` ^2.0.0 |
|
|
41
|
+
| Schema Validation | `zod` ^4.3.6 |
|
|
42
|
+
| Package Manager | npm |
|
|
44
43
|
|
|
45
44
|
## Architecture
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
```text
|
|
47
|
+
URL → Validate → DNS Preflight → HTTP Fetch → Decompress
|
|
48
|
+
→ Truncate HTML → Readability Extract → Noise Removal
|
|
49
|
+
→ Markdown Convert → Cleanup Pipeline → Cache → Response
|
|
50
|
+
```
|
|
48
51
|
|
|
49
|
-
1.
|
|
50
|
-
2.
|
|
51
|
-
3.
|
|
52
|
-
4.
|
|
53
|
-
5.
|
|
54
|
-
6. Convert to Markdown, inject metadata, and return via MCP.
|
|
55
|
-
7. Cache the result and expose it as a resource or download.
|
|
52
|
+
1. **URL Validation** — Normalize, block private hosts, transform raw-content URLs (GitHub, GitLab, Bitbucket)
|
|
53
|
+
2. **Fetch** — HTTP request via `undici` with redirect following, DNS preflight SSRF checks, and size limits
|
|
54
|
+
3. **Transform** — Offloaded to worker threads: parse HTML with `linkedom`, extract with Readability, remove DOM noise, convert to Markdown
|
|
55
|
+
4. **Cleanup** — Multi-pass Markdown normalization (heading promotion, spacing, skip-link removal, TypeDoc comment stripping)
|
|
56
|
+
5. **Cache + Respond** — Store result, apply inline content limits, return structured content with optional resource links
|
|
56
57
|
|
|
57
58
|
## Repository Structure
|
|
58
59
|
|
|
59
60
|
```text
|
|
60
|
-
|
|
61
|
-
├── assets/
|
|
62
|
-
|
|
63
|
-
├──
|
|
64
|
-
│ ├──
|
|
65
|
-
│
|
|
66
|
-
|
|
67
|
-
│ ├──
|
|
68
|
-
│
|
|
69
|
-
|
|
70
|
-
├──
|
|
71
|
-
├──
|
|
61
|
+
superFetch/
|
|
62
|
+
├── assets/
|
|
63
|
+
│ └── logo.svg
|
|
64
|
+
├── scripts/
|
|
65
|
+
│ ├── tasks.mjs
|
|
66
|
+
│ └── validate-fetch.mjs
|
|
67
|
+
├── src/
|
|
68
|
+
│ ├── workers/
|
|
69
|
+
│ │ ├── transform-child.ts
|
|
70
|
+
│ │ └── transform-worker.ts
|
|
71
|
+
│ ├── cache.ts
|
|
72
|
+
│ ├── config.ts
|
|
73
|
+
│ ├── crypto.ts
|
|
74
|
+
│ ├── dom-noise-removal.ts
|
|
75
|
+
│ ├── errors.ts
|
|
76
|
+
│ ├── fetch.ts
|
|
77
|
+
│ ├── host-normalization.ts
|
|
78
|
+
│ ├── http-native.ts
|
|
79
|
+
│ ├── index.ts
|
|
80
|
+
│ ├── instructions.md
|
|
81
|
+
│ ├── ip-blocklist.ts
|
|
82
|
+
│ ├── json.ts
|
|
83
|
+
│ ├── language-detection.ts
|
|
84
|
+
│ ├── markdown-cleanup.ts
|
|
85
|
+
│ ├── mcp-validator.ts
|
|
86
|
+
│ ├── mcp.ts
|
|
87
|
+
│ ├── observability.ts
|
|
88
|
+
│ ├── resources.ts
|
|
89
|
+
│ ├── server-tuning.ts
|
|
90
|
+
│ ├── session.ts
|
|
91
|
+
│ ├── tasks.ts
|
|
92
|
+
│ ├── timer-utils.ts
|
|
93
|
+
│ ├── tools.ts
|
|
94
|
+
│ ├── transform-types.ts
|
|
95
|
+
│ ├── transform.ts
|
|
96
|
+
│ └── type-guards.ts
|
|
97
|
+
├── tests/
|
|
98
|
+
│ └── *.test.ts
|
|
72
99
|
├── package.json
|
|
73
|
-
|
|
100
|
+
├── tsconfig.json
|
|
101
|
+
└── AGENTS.md
|
|
74
102
|
```
|
|
75
103
|
|
|
76
104
|
## Requirements
|
|
77
105
|
|
|
78
|
-
- Node.js
|
|
79
|
-
- npm (uses package-lock.json)
|
|
106
|
+
- **Node.js** ≥ 24
|
|
80
107
|
|
|
81
|
-
## Quickstart
|
|
108
|
+
## Quickstart
|
|
82
109
|
|
|
83
110
|
```bash
|
|
84
111
|
npx -y @j0hanz/superfetch@latest --stdio
|
|
85
112
|
```
|
|
86
113
|
|
|
87
|
-
|
|
114
|
+
Add to your MCP client configuration:
|
|
88
115
|
|
|
89
116
|
```json
|
|
90
117
|
{
|
|
91
118
|
"mcpServers": {
|
|
92
|
-
"
|
|
119
|
+
"superfetch": {
|
|
93
120
|
"command": "npx",
|
|
94
121
|
"args": ["-y", "@j0hanz/superfetch@latest", "--stdio"]
|
|
95
122
|
}
|
|
@@ -99,20 +126,22 @@ Example MCP client configuration:
|
|
|
99
126
|
|
|
100
127
|
## Installation
|
|
101
128
|
|
|
102
|
-
### NPX (
|
|
129
|
+
### NPX (Recommended)
|
|
130
|
+
|
|
131
|
+
No installation required — runs directly:
|
|
103
132
|
|
|
104
133
|
```bash
|
|
105
134
|
npx -y @j0hanz/superfetch@latest --stdio
|
|
106
135
|
```
|
|
107
136
|
|
|
108
|
-
### Global
|
|
137
|
+
### Global Install
|
|
109
138
|
|
|
110
139
|
```bash
|
|
111
140
|
npm install -g @j0hanz/superfetch
|
|
112
141
|
superfetch --stdio
|
|
113
142
|
```
|
|
114
143
|
|
|
115
|
-
### From
|
|
144
|
+
### From Source
|
|
116
145
|
|
|
117
146
|
```bash
|
|
118
147
|
git clone https://github.com/j0hanz/super-fetch-mcp-server.git
|
|
@@ -124,105 +153,110 @@ node dist/index.js --stdio
|
|
|
124
153
|
|
|
125
154
|
## Configuration
|
|
126
155
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
|
155
|
-
|
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
| `
|
|
163
|
-
|
|
164
|
-
`
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
| `
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
|
181
|
-
|
|
|
182
|
-
| `
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
|
191
|
-
|
|
|
192
|
-
| `
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
|
200
|
-
|
|
|
201
|
-
|
|
|
202
|
-
|
|
|
203
|
-
|
|
|
204
|
-
|
|
|
205
|
-
|
|
|
206
|
-
|
|
|
207
|
-
|
|
|
156
|
+
### Runtime Modes
|
|
157
|
+
|
|
158
|
+
| Flag | Description |
|
|
159
|
+
| ----------- | ------------------------------------------- |
|
|
160
|
+
| `--stdio` | Run in stdio mode (for desktop MCP clients) |
|
|
161
|
+
| `--help` | Show usage help |
|
|
162
|
+
| `--version` | Print server version |
|
|
163
|
+
|
|
164
|
+
When no `--stdio` flag is passed, the server starts in **HTTP mode** (Streamable HTTP on port 3000 by default).
|
|
165
|
+
|
|
166
|
+
### Environment Variables
|
|
167
|
+
|
|
168
|
+
#### Core Settings
|
|
169
|
+
|
|
170
|
+
| Variable | Default | Description |
|
|
171
|
+
| ------------------ | -------------------------- | ------------------------------------------------------ |
|
|
172
|
+
| `HOST` | `127.0.0.1` | HTTP server bind address |
|
|
173
|
+
| `PORT` | `3000` | HTTP server port (1024–65535) |
|
|
174
|
+
| `LOG_LEVEL` | `info` | Log level: `debug`, `info`, `warn`, `error` |
|
|
175
|
+
| `FETCH_TIMEOUT_MS` | `15000` | HTTP fetch timeout in ms (1000–60000) |
|
|
176
|
+
| `CACHE_ENABLED` | `true` | Enable/disable in-memory content cache |
|
|
177
|
+
| `USER_AGENT` | `superFetch-MCP/{version}` | Custom User-Agent header |
|
|
178
|
+
| `ALLOW_REMOTE` | `false` | Allow remote connections in HTTP mode |
|
|
179
|
+
| `ALLOWED_HOSTS` | _(empty)_ | Comma-separated hostnames allowed to bypass block list |
|
|
180
|
+
|
|
181
|
+
#### Authentication (HTTP Mode)
|
|
182
|
+
|
|
183
|
+
| Variable | Default | Description |
|
|
184
|
+
| ------------------------- | --------- | --------------------------------------- |
|
|
185
|
+
| `ACCESS_TOKENS` | _(empty)_ | Comma-separated static bearer tokens |
|
|
186
|
+
| `API_KEY` | _(empty)_ | Single API key (added to static tokens) |
|
|
187
|
+
| `OAUTH_ISSUER_URL` | _(empty)_ | OAuth issuer URL (enables OAuth mode) |
|
|
188
|
+
| `OAUTH_AUTHORIZATION_URL` | _(empty)_ | OAuth authorization endpoint |
|
|
189
|
+
| `OAUTH_TOKEN_URL` | _(empty)_ | OAuth token endpoint |
|
|
190
|
+
| `OAUTH_INTROSPECTION_URL` | _(empty)_ | OAuth token introspection endpoint |
|
|
191
|
+
| `OAUTH_REVOCATION_URL` | _(empty)_ | OAuth token revocation endpoint |
|
|
192
|
+
| `OAUTH_REGISTRATION_URL` | _(empty)_ | OAuth dynamic client registration |
|
|
193
|
+
| `OAUTH_REQUIRED_SCOPES` | _(empty)_ | Required OAuth scopes |
|
|
194
|
+
| `OAUTH_CLIENT_ID` | _(empty)_ | OAuth client ID |
|
|
195
|
+
| `OAUTH_CLIENT_SECRET` | _(empty)_ | OAuth client secret |
|
|
196
|
+
|
|
197
|
+
#### Transform & Workers
|
|
198
|
+
|
|
199
|
+
| Variable | Default | Description |
|
|
200
|
+
| ------------------------------------------ | --------- | ----------------------------------------- |
|
|
201
|
+
| `TRANSFORM_WORKER_MODE` | `threads` | Worker mode: `threads` or `process` |
|
|
202
|
+
| `TRANSFORM_WORKER_MAX_OLD_GENERATION_MB` | _(unset)_ | V8 old generation heap limit per worker |
|
|
203
|
+
| `TRANSFORM_WORKER_MAX_YOUNG_GENERATION_MB` | _(unset)_ | V8 young generation heap limit per worker |
|
|
204
|
+
| `TRANSFORM_WORKER_CODE_RANGE_MB` | _(unset)_ | V8 code range limit per worker |
|
|
205
|
+
| `TRANSFORM_WORKER_STACK_MB` | _(unset)_ | Stack size limit per worker |
|
|
206
|
+
|
|
207
|
+
#### Content Tuning
|
|
208
|
+
|
|
209
|
+
| Variable | Default | Description |
|
|
210
|
+
| ---------------------------------- | ----------------- | ------------------------------------------------ |
|
|
211
|
+
| `SUPERFETCH_EXTRA_NOISE_TOKENS` | _(empty)_ | Additional CSS class/id tokens for noise removal |
|
|
212
|
+
| `SUPERFETCH_EXTRA_NOISE_SELECTORS` | _(empty)_ | Additional CSS selectors for noise removal |
|
|
213
|
+
| `MARKDOWN_HEADING_KEYWORDS` | _(built-in list)_ | Keywords triggering heading promotion |
|
|
214
|
+
| `SUPERFETCH_LOCALE` | _(system)_ | Locale for content processing |
|
|
215
|
+
|
|
216
|
+
#### Server Tuning
|
|
217
|
+
|
|
218
|
+
| Variable | Default | Description |
|
|
219
|
+
| ---------------------------------- | --------------- | ---------------------------------------- |
|
|
220
|
+
| `SERVER_MAX_CONNECTIONS` | `0` (unlimited) | Maximum concurrent HTTP connections |
|
|
221
|
+
| `SERVER_BLOCK_PRIVATE_CONNECTIONS` | `false` | Block connections from private IP ranges |
|
|
222
|
+
|
|
223
|
+
### Hardcoded Defaults
|
|
224
|
+
|
|
225
|
+
| Setting | Value |
|
|
226
|
+
| ------------------------ | ------------------------------- |
|
|
227
|
+
| Max HTML size | 10 MB |
|
|
228
|
+
| Max inline content chars | 0 (unlimited) |
|
|
229
|
+
| Fetch timeout | 15 s |
|
|
230
|
+
| Transform timeout | 30 s |
|
|
231
|
+
| Tool timeout | Fetch + Transform + 5 s padding |
|
|
232
|
+
| Max redirects | 5 |
|
|
233
|
+
| Cache TTL | 86400 s (24 h) |
|
|
234
|
+
| Cache max keys | 100 |
|
|
235
|
+
| Rate limit | 100 requests / 60 s |
|
|
236
|
+
| Max sessions | 200 |
|
|
237
|
+
| Session TTL | 30 min |
|
|
238
|
+
| Max URL length | 2048 chars |
|
|
239
|
+
| Worker pool max scale | 4 |
|
|
208
240
|
|
|
209
241
|
## Usage
|
|
210
242
|
|
|
211
|
-
### Stdio
|
|
243
|
+
### Stdio Mode
|
|
212
244
|
|
|
213
245
|
```bash
|
|
214
|
-
|
|
246
|
+
superfetch --stdio
|
|
215
247
|
```
|
|
216
248
|
|
|
217
|
-
|
|
249
|
+
The server communicates via JSON-RPC over stdin/stdout. All MCP clients that support stdio transport can connect directly.
|
|
250
|
+
|
|
251
|
+
### HTTP Mode
|
|
218
252
|
|
|
219
253
|
```bash
|
|
220
|
-
|
|
254
|
+
superfetch
|
|
255
|
+
# or
|
|
256
|
+
PORT=8080 HOST=0.0.0.0 ALLOW_REMOTE=true superfetch
|
|
221
257
|
```
|
|
222
258
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
Remote bindings require `ALLOW_REMOTE=true` and OAuth configuration.
|
|
259
|
+
The server starts a Streamable HTTP endpoint at `/mcp`. Authenticate with bearer tokens via the `ACCESS_TOKENS` or `API_KEY` environment variables.
|
|
226
260
|
|
|
227
261
|
## MCP Surface
|
|
228
262
|
|
|
@@ -230,80 +264,130 @@ Remote bindings require `ALLOW_REMOTE=true` and OAuth configuration.
|
|
|
230
264
|
|
|
231
265
|
#### `fetch-url`
|
|
232
266
|
|
|
233
|
-
Fetches a webpage and converts it to clean Markdown.
|
|
267
|
+
Fetches a webpage and converts it to clean Markdown format optimized for LLM context.
|
|
234
268
|
|
|
235
|
-
|
|
269
|
+
**Useful for:**
|
|
236
270
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
271
|
+
- Reading documentation, blog posts, or articles
|
|
272
|
+
- Extracting main content while removing navigation and ads
|
|
273
|
+
- Caching content to speed up repeated queries
|
|
240
274
|
|
|
241
|
-
|
|
275
|
+
**Limitations:**
|
|
242
276
|
|
|
243
|
-
-
|
|
244
|
-
- `inputUrl` (string, optional): original input URL
|
|
245
|
-
- `resolvedUrl` (string, optional): normalized or raw-content URL
|
|
246
|
-
- `title` (string, optional): page title
|
|
247
|
-
- `markdown` (string, optional): inline markdown (may be truncated)
|
|
248
|
-
- `error` (string, optional): error message on failure
|
|
277
|
+
- Does not execute complex client-side JavaScript interactions
|
|
249
278
|
|
|
250
|
-
|
|
279
|
+
##### Parameters
|
|
280
|
+
|
|
281
|
+
| Parameter | Type | Required | Default | Description |
|
|
282
|
+
| ------------------ | -------------- | -------- | ------- | ------------------------------------------------------------------ |
|
|
283
|
+
| `url` | `string` (URL) | Yes | — | The URL of the webpage to fetch (http/https, max 2048 chars) |
|
|
284
|
+
| `skipNoiseRemoval` | `boolean` | No | `false` | Preserve navigation, footers, and other elements normally filtered |
|
|
285
|
+
| `forceRefresh` | `boolean` | No | `false` | Bypass cache and fetch fresh content |
|
|
286
|
+
|
|
287
|
+
##### Returns
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"url": "https://example.com",
|
|
292
|
+
"resolvedUrl": "https://example.com",
|
|
293
|
+
"inputUrl": "https://example.com",
|
|
294
|
+
"title": "Example Domain",
|
|
295
|
+
"markdown": "# Example Domain\n\nThis domain is for use in illustrative examples...",
|
|
296
|
+
"truncated": false
|
|
297
|
+
}
|
|
298
|
+
```
|
|
251
299
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
300
|
+
| Field | Type | Description |
|
|
301
|
+
| ------------- | ---------- | ----------------------------------------------- |
|
|
302
|
+
| `url` | `string` | The canonical URL (pre-raw-transform) |
|
|
303
|
+
| `inputUrl` | `string` | The original URL provided by the caller |
|
|
304
|
+
| `resolvedUrl` | `string` | The normalized/transformed URL that was fetched |
|
|
305
|
+
| `title` | `string?` | Extracted page title |
|
|
306
|
+
| `markdown` | `string?` | Extracted content in Markdown format |
|
|
307
|
+
| `truncated` | `boolean?` | Whether inline markdown was truncated |
|
|
308
|
+
| `error` | `string?` | Error message if the request failed |
|
|
309
|
+
| `statusCode` | `number?` | HTTP status code for failed requests |
|
|
310
|
+
| `details` | `object?` | Additional error details |
|
|
257
311
|
|
|
258
|
-
|
|
312
|
+
##### Annotations
|
|
259
313
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
314
|
+
| Annotation | Value |
|
|
315
|
+
| ----------------- | ------- |
|
|
316
|
+
| `readOnlyHint` | `true` |
|
|
317
|
+
| `destructiveHint` | `false` |
|
|
318
|
+
| `idempotentHint` | `true` |
|
|
319
|
+
| `openWorldHint` | `true` |
|
|
320
|
+
|
|
321
|
+
##### Async Task Execution
|
|
322
|
+
|
|
323
|
+
The `fetch-url` tool supports optional async task execution. Include a `task` field in the tool call to run the fetch in the background:
|
|
324
|
+
|
|
325
|
+
```json
|
|
326
|
+
{
|
|
327
|
+
"method": "tools/call",
|
|
328
|
+
"params": {
|
|
329
|
+
"name": "fetch-url",
|
|
330
|
+
"arguments": { "url": "https://example.com" },
|
|
331
|
+
"task": { "ttl": 300 }
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Then poll `tasks/get` until the task status is `completed` or `failed`, and retrieve the result via `tasks/result`.
|
|
266
337
|
|
|
267
338
|
### Resources
|
|
268
339
|
|
|
269
|
-
| URI
|
|
270
|
-
|
|
|
271
|
-
| `
|
|
272
|
-
| `internal://
|
|
273
|
-
| `
|
|
340
|
+
| URI Pattern | MIME Type | Description |
|
|
341
|
+
| ------------------------------------------ | ------------------ | ------------------------------------------------ |
|
|
342
|
+
| `internal://instructions` | `text/markdown` | Server instructions and usage guidance |
|
|
343
|
+
| `internal://config` | `application/json` | Current runtime configuration (secrets redacted) |
|
|
344
|
+
| `superfetch://cache/{namespace}/{urlHash}` | `text/markdown` | Cached web content snapshots (subscribable) |
|
|
345
|
+
|
|
346
|
+
The `superfetch://cache/...` resource supports subscriptions — clients receive notifications when cached content is updated.
|
|
274
347
|
|
|
275
348
|
### Tasks
|
|
276
349
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
350
|
+
The server declares full MCP task support:
|
|
351
|
+
|
|
352
|
+
| Endpoint | Description |
|
|
353
|
+
| -------------- | ------------------------------------ |
|
|
354
|
+
| `tasks/list` | List tasks (scoped to session/owner) |
|
|
355
|
+
| `tasks/get` | Get task status by ID |
|
|
356
|
+
| `tasks/result` | Retrieve completed task result |
|
|
357
|
+
| `tasks/cancel` | Cancel an in-flight task |
|
|
280
358
|
|
|
281
359
|
## HTTP Mode Endpoints
|
|
282
360
|
|
|
283
|
-
| Method
|
|
284
|
-
|
|
|
285
|
-
| GET | `/health`
|
|
286
|
-
| POST | `/mcp`
|
|
287
|
-
| GET | `/mcp`
|
|
288
|
-
| DELETE | `/mcp`
|
|
289
|
-
| GET | `/mcp/downloads
|
|
361
|
+
| Method | Path | Auth | Description |
|
|
362
|
+
| -------- | ----------------------------------- | ---- | ---------------------------------------- |
|
|
363
|
+
| `GET` | `/health` | No | Health check with server stats |
|
|
364
|
+
| `POST` | `/mcp` | Yes | MCP JSON-RPC (Streamable HTTP) |
|
|
365
|
+
| `GET` | `/mcp` | Yes | SSE stream for server-initiated messages |
|
|
366
|
+
| `DELETE` | `/mcp` | Yes | Terminate MCP session |
|
|
367
|
+
| `GET` | `/mcp/downloads/{namespace}/{hash}` | Yes | Download cached content |
|
|
368
|
+
|
|
369
|
+
### Session Behavior
|
|
370
|
+
|
|
371
|
+
- Sessions are created on the first `POST /mcp` request with an `initialize` message
|
|
372
|
+
- Session ID is returned in the `mcp-session-id` response header
|
|
373
|
+
- Sessions expire after 30 minutes of inactivity (max 200 concurrent)
|
|
290
374
|
|
|
291
|
-
|
|
375
|
+
### Authentication
|
|
292
376
|
|
|
293
|
-
-
|
|
294
|
-
-
|
|
377
|
+
- **Static tokens**: Set `ACCESS_TOKENS` or `API_KEY` environment variables; pass as `Authorization: Bearer <token>`
|
|
378
|
+
- **OAuth**: Configure `OAUTH_*` environment variables to enable OAuth 2.0 token introspection
|
|
295
379
|
|
|
296
380
|
## Client Configuration Examples
|
|
297
381
|
|
|
298
382
|
<details>
|
|
299
|
-
<summary
|
|
383
|
+
<summary>VS Code / VS Code Insiders</summary>
|
|
300
384
|
|
|
301
|
-
Add to
|
|
385
|
+
Add to your VS Code settings (`.vscode/mcp.json` or User Settings):
|
|
302
386
|
|
|
303
387
|
```json
|
|
304
388
|
{
|
|
305
389
|
"servers": {
|
|
306
|
-
"
|
|
390
|
+
"superfetch": {
|
|
307
391
|
"command": "npx",
|
|
308
392
|
"args": ["-y", "@j0hanz/superfetch@latest", "--stdio"]
|
|
309
393
|
}
|
|
@@ -314,14 +398,14 @@ Add to .vscode/mcp.json:
|
|
|
314
398
|
</details>
|
|
315
399
|
|
|
316
400
|
<details>
|
|
317
|
-
<summary
|
|
401
|
+
<summary>Claude Desktop</summary>
|
|
318
402
|
|
|
319
|
-
Add to claude_desktop_config.json
|
|
403
|
+
Add to `claude_desktop_config.json`:
|
|
320
404
|
|
|
321
405
|
```json
|
|
322
406
|
{
|
|
323
407
|
"mcpServers": {
|
|
324
|
-
"
|
|
408
|
+
"superfetch": {
|
|
325
409
|
"command": "npx",
|
|
326
410
|
"args": ["-y", "@j0hanz/superfetch@latest", "--stdio"]
|
|
327
411
|
}
|
|
@@ -332,12 +416,16 @@ Add to claude_desktop_config.json:
|
|
|
332
416
|
</details>
|
|
333
417
|
|
|
334
418
|
<details>
|
|
335
|
-
<summary
|
|
419
|
+
<summary>Cursor</summary>
|
|
420
|
+
|
|
421
|
+
[](https://cursor.com/install-mcp?name=superfetch&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovc3VwZXJmZXRjaEBsYXRlc3QiLCItLXN0ZGlvIl19)
|
|
422
|
+
|
|
423
|
+
Or manually add to Cursor MCP settings:
|
|
336
424
|
|
|
337
425
|
```json
|
|
338
426
|
{
|
|
339
427
|
"mcpServers": {
|
|
340
|
-
"
|
|
428
|
+
"superfetch": {
|
|
341
429
|
"command": "npx",
|
|
342
430
|
"args": ["-y", "@j0hanz/superfetch@latest", "--stdio"]
|
|
343
431
|
}
|
|
@@ -348,12 +436,14 @@ Add to claude_desktop_config.json:
|
|
|
348
436
|
</details>
|
|
349
437
|
|
|
350
438
|
<details>
|
|
351
|
-
<summary
|
|
439
|
+
<summary>Windsurf</summary>
|
|
440
|
+
|
|
441
|
+
Add to your Windsurf MCP configuration:
|
|
352
442
|
|
|
353
443
|
```json
|
|
354
444
|
{
|
|
355
445
|
"mcpServers": {
|
|
356
|
-
"
|
|
446
|
+
"superfetch": {
|
|
357
447
|
"command": "npx",
|
|
358
448
|
"args": ["-y", "@j0hanz/superfetch@latest", "--stdio"]
|
|
359
449
|
}
|
|
@@ -363,58 +453,92 @@ Add to claude_desktop_config.json:
|
|
|
363
453
|
|
|
364
454
|
</details>
|
|
365
455
|
|
|
456
|
+
## Security
|
|
457
|
+
|
|
458
|
+
### SSRF Protection
|
|
459
|
+
|
|
460
|
+
superFetch blocks requests to private and internal network addresses:
|
|
461
|
+
|
|
462
|
+
- **Blocked hosts**: `localhost`, `127.0.0.0/8`, `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `169.254.0.0/16`, `100.64.0.0/10`
|
|
463
|
+
- **Blocked IPv6**: `::1`, `fc00::/7`, `fe80::/10`, IPv4-mapped private addresses (`::ffff:10.*`, etc.)
|
|
464
|
+
- **Cloud metadata**: `169.254.169.254` (AWS), `metadata.google.internal`, `metadata.azure.com`, `100.100.100.200` (Azure IMDS)
|
|
465
|
+
|
|
466
|
+
DNS preflight checks run on every redirect hop to prevent DNS rebinding attacks.
|
|
467
|
+
|
|
468
|
+
### Stdio Transport Safety
|
|
469
|
+
|
|
470
|
+
The server never writes non-protocol data to stdout. All logs and diagnostics go to stderr.
|
|
471
|
+
|
|
472
|
+
### Rate Limiting
|
|
473
|
+
|
|
474
|
+
HTTP mode enforces a rate limit of 100 requests per 60-second window per client.
|
|
475
|
+
|
|
476
|
+
### Content Safety
|
|
477
|
+
|
|
478
|
+
- HTML downloads are capped at 10 MB
|
|
479
|
+
- Worker threads run in isolation with configurable resource limits
|
|
480
|
+
- Auth tokens are stored in-memory only and compared using timing-safe equality
|
|
481
|
+
|
|
366
482
|
## Development Workflow
|
|
367
483
|
|
|
368
|
-
### Install
|
|
484
|
+
### Install Dependencies
|
|
369
485
|
|
|
370
486
|
```bash
|
|
371
487
|
npm install
|
|
372
488
|
```
|
|
373
489
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
|
379
|
-
|
|
|
380
|
-
|
|
|
381
|
-
|
|
|
382
|
-
|
|
|
383
|
-
|
|
|
384
|
-
|
|
|
385
|
-
|
|
|
386
|
-
|
|
|
387
|
-
|
|
|
388
|
-
|
|
|
389
|
-
| type-check | `tsc --noEmit` | Type checking. |
|
|
390
|
-
| type-check:diagnostics | `tsc --noEmit --extendedDiagnostics` | Type check diagnostics. |
|
|
391
|
-
| type-check:trace | `node -e "require('fs').rmSync('.ts-trace',{recursive:true,force:true})" && tsc --noEmit --generateTrace .ts-trace` | Generate TS trace. |
|
|
392
|
-
| lint | `eslint .` | Lint. |
|
|
393
|
-
| lint:fix | `eslint . --fix` | Lint and fix. |
|
|
394
|
-
| test | `npm run build --silent && node --test --experimental-transform-types` | Run tests (builds first). |
|
|
395
|
-
| test:coverage | `npm run build --silent && node --test --experimental-transform-types --experimental-test-coverage` | Test with coverage. |
|
|
396
|
-
| knip | `knip` | Dead code analysis. |
|
|
397
|
-
| knip:fix | `knip --fix` | Fix knip issues. |
|
|
398
|
-
| inspector | `npx @modelcontextprotocol/inspector` | MCP Inspector. |
|
|
399
|
-
| prepublishOnly | `npm run lint && npm run type-check && npm run build` | Prepublish checks. |
|
|
490
|
+
### Scripts
|
|
491
|
+
|
|
492
|
+
| Script | Command | Description |
|
|
493
|
+
| --------------- | ----------------------- | -------------------------------------------- |
|
|
494
|
+
| `dev` | `npm run dev` | TypeScript watch mode |
|
|
495
|
+
| `dev:run` | `npm run dev:run` | Run compiled output with watch + `.env` |
|
|
496
|
+
| `build` | `npm run build` | Clean, compile, copy assets, make executable |
|
|
497
|
+
| `start` | `npm start` | Run compiled server |
|
|
498
|
+
| `test` | `npm test` | Run test suite (Node.js native test runner) |
|
|
499
|
+
| `test:coverage` | `npm run test:coverage` | Run tests with coverage |
|
|
500
|
+
| `lint` | `npm run lint` | ESLint |
|
|
501
|
+
| `lint:fix` | `npm run lint:fix` | ESLint with auto-fix |
|
|
502
|
+
| `format` | `npm run format` | Prettier |
|
|
503
|
+
| `type-check` | `npm run type-check` | TypeScript type checking |
|
|
504
|
+
| `inspector` | `npm run inspector` | Build and launch MCP Inspector |
|
|
400
505
|
|
|
401
506
|
## Build and Release
|
|
402
507
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
508
|
+
```bash
|
|
509
|
+
npm run build # Clean → Compile → Copy Assets → chmod
|
|
510
|
+
npm run prepublishOnly # Lint → Type-Check → Build
|
|
511
|
+
npm publish # Publish to npm
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
The `prepare` script runs `npm run build` automatically on `npm install` from source.
|
|
408
515
|
|
|
409
516
|
## Troubleshooting
|
|
410
517
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
518
|
+
### MCP Inspector
|
|
519
|
+
|
|
520
|
+
Use the built-in inspector to test the server interactively:
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
npm run inspector
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
This builds the project and launches `@modelcontextprotocol/inspector` pointing to the compiled server.
|
|
527
|
+
|
|
528
|
+
### Common Issues
|
|
529
|
+
|
|
530
|
+
| Issue | Solution |
|
|
531
|
+
| ------------------------- | ------------------------------------------------------------------------------------- |
|
|
532
|
+
| `VALIDATION_ERROR` on URL | URL is blocked (private IP/localhost) or malformed. Do not retry. |
|
|
533
|
+
| `queue_full` error | Worker pool is saturated. Wait briefly, then retry or use async task mode. |
|
|
534
|
+
| Garbled output | Binary content (images, PDFs) cannot be converted. Ensure the URL serves HTML. |
|
|
535
|
+
| No output in stdio mode | Ensure `--stdio` flag is passed. Without it, the server starts in HTTP mode. |
|
|
536
|
+
| Auth errors in HTTP mode | Set `ACCESS_TOKENS` or `API_KEY` env var and pass as `Authorization: Bearer <token>`. |
|
|
537
|
+
|
|
538
|
+
### Stdout / Stderr Guidance
|
|
539
|
+
|
|
540
|
+
In stdio mode, **stdout** is reserved exclusively for MCP JSON-RPC messages. Logs and diagnostics are written to **stderr**. Never pipe stdout to a log file when using stdio transport.
|
|
541
|
+
|
|
542
|
+
## License
|
|
419
543
|
|
|
420
|
-
|
|
544
|
+
[MIT](https://opensource.org/licenses/MIT)
|