searchfetch 3.2.2 → 3.3.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 CHANGED
@@ -84,6 +84,13 @@ Template extraction supports `text`, `markdown`, `attribute`, and `html` formats
84
84
 
85
85
  Built-in templates live in `templates/*.json` and are shared by the Node.js and Python implementations.
86
86
 
87
+ **Available page templates** (auto-detected by URL or selectable by name):
88
+ `wikipedia`, `reddit`, `mdn-web-docs`, `gitlab`, `youtube`, `devto`, `go-pkg`, `javadoc`,
89
+ `github-repo`, `github-issue`, `npm-package`, `pypi-package`, `crates-package`,
90
+ `docker-hub`, `docs-rs`, `docs-page`
91
+
92
+ **`raw`** — special template that applies minimal filtering and returns full body content as markdown. Use when you need the complete page without template-specific extraction.
93
+
87
94
  ---
88
95
 
89
96
  ## Local Development
package/index.js CHANGED
@@ -328,7 +328,10 @@ async function fetchHtml(url, template, blockMedia) {
328
328
  timeout: 15000,
329
329
  });
330
330
  } catch (_navError) {
331
- // Allow partial rendering on timeout
331
+ // Allow partial rendering on timeout only
332
+ if (!_navError.message?.includes("timeout") && !_navError.message?.includes("Timeout")) {
333
+ throw _navError;
334
+ }
332
335
  }
333
336
 
334
337
  // Check HTTP status for access failures
@@ -377,7 +380,8 @@ async function fetchHtmlWithRetry(url, template, blockMedia) {
377
380
  attempt < FETCH_MAX_ATTEMPTS - 1 &&
378
381
  (err.message.includes("net::") ||
379
382
  err.message.includes("ERR_") ||
380
- err.message.includes("Navigation failed"))
383
+ err.message.includes("Navigation failed") ||
384
+ err.message.includes("navigating"))
381
385
  ) {
382
386
  await sleep(500);
383
387
  continue;
@@ -1019,7 +1023,7 @@ function resolveSearchTemplate(engine, query, region, safeSearch) {
1019
1023
 
1020
1024
  // === MCP SERVER & TOOLS ==================================================
1021
1025
 
1022
- const server = new McpServer({ name: "searchfetch", version: "3.2.2" });
1026
+ const server = new McpServer({ name: "searchfetch", version: "3.3.0" });
1023
1027
 
1024
1028
  // --- websearch tool ---
1025
1029
 
@@ -1114,7 +1118,11 @@ server.registerTool(
1114
1118
  .string()
1115
1119
  .default("auto")
1116
1120
  .describe(
1117
- "Template to use: 'auto' (auto-detect from URL), a built-in name, or inline JSON.",
1121
+ "Template to use: 'auto' (auto-detect from URL), a built-in page template name " +
1122
+ "(wikipedia, reddit, mdn-web-docs, gitlab, youtube, devto, go-pkg, javadoc, " +
1123
+ "github-repo, github-issue, npm-package, pypi-package, crates-package, " +
1124
+ "docker-hub, docs-rs, docs-page), 'raw' for minimal-filtering full-page output, " +
1125
+ "or inline JSON.",
1118
1126
  ),
1119
1127
  start_index: z.number().default(0).describe("Character offset for pagination. Default: 0."),
1120
1128
  max_length: z
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "searchfetch",
3
- "version": "3.2.2",
3
+ "version": "3.3.0",
4
4
  "description": "Fault-tolerant MCP Server for Stealth Web Search and Fetching",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,13 +23,15 @@
23
23
  "inspector-py": "npx @modelcontextprotocol/inspector uv run python ./server.py",
24
24
  "test": "npm run test:js && npm run test:py",
25
25
  "test:js": "node --test \"*.test.js\"",
26
- "test:py": "uv run pytest test_*.py -v",
26
+ "test:py": "uv run --extra dev pytest test_*.py -v",
27
27
  "lint": "npm run lint:js && npm run lint:py",
28
- "lint:js": "npx eslint \"*.js\"",
29
- "lint:py": "uv run ruff check server.py test_*.py",
30
- "format": "npx prettier --write \"*.js\" \"*.json\" \"*.md\" && uv run ruff format server.py test_*.py",
31
- "format:check": "npx prettier --check \"*.js\" \"*.json\" \"*.md\" && uv run ruff format --check server.py test_*.py",
32
- "e2e": "npm run test"
28
+ "lint:js": "npx eslint \"*.js\" \"scripts/*.mjs\"",
29
+ "lint:py": "uv run --extra dev ruff check server.py scripts/*.py test_*.py",
30
+ "format": "npx prettier --write \"*.js\" \"scripts/*.mjs\" \"*.json\" \"*.md\" && uv run --extra dev ruff format server.py scripts/*.py test_*.py",
31
+ "format:check": "npx prettier --check \"*.js\" \"scripts/*.mjs\" \"*.json\" \"*.md\" && uv run --extra dev ruff format --check server.py scripts/*.py test_*.py",
32
+ "e2e": "npm run e2e:node && npm run e2e:py",
33
+ "e2e:node": "node scripts/e2e-node.mjs",
34
+ "e2e:py": "uv run python scripts/e2e-python.py"
33
35
  },
34
36
  "dependencies": {
35
37
  "@modelcontextprotocol/sdk": "^1.29.0",
@@ -39,6 +41,9 @@
39
41
  "turndown": "^7.2.4",
40
42
  "zod": "^4.4.3"
41
43
  },
44
+ "overrides": {
45
+ "encoding-sniffer": "1.0.2"
46
+ },
42
47
  "devDependencies": {
43
48
  "eslint": "^10.6.0",
44
49
  "prettier": "^3.9.4"
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "devto",
3
+ "description": "DEV Community article — title, author, and content",
4
+ "order": 20,
5
+ "url_patterns": [
6
+ "^https?://dev\\.to/[^/]+/[^/]+"
7
+ ],
8
+ "remove": [
9
+ "script",
10
+ "style",
11
+ "svg",
12
+ "img",
13
+ "nav",
14
+ "footer",
15
+ ".sidebar",
16
+ ".crayons-layout__sidebar-left",
17
+ ".crayons-layout__sidebar-right",
18
+ ".crayons-article-actions",
19
+ ".reaction-button",
20
+ ".crayons-btn",
21
+ ".spec__tags",
22
+ ".article-engagement-bar",
23
+ ".comments-container"
24
+ ],
25
+ "sections": [
26
+ {
27
+ "name": "Title",
28
+ "selector": "h1",
29
+ "format": "text",
30
+ "required": true
31
+ },
32
+ {
33
+ "name": "Author",
34
+ "selector": ".crayons-article__header__meta a, a.crayons-avatar",
35
+ "format": "text",
36
+ "required": false
37
+ },
38
+ {
39
+ "name": "Content",
40
+ "selector": "#article-body, .crayons-article__body, article.crayons-article",
41
+ "format": "markdown",
42
+ "required": true
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "gitlab",
3
+ "description": "GitLab project — description, file listing, and README",
4
+ "order": 12,
5
+ "url_patterns": [
6
+ "^https?://gitlab\\.com/[^/]+/[^/]+/?$",
7
+ "^https?://gitlab\\.com/[^/]+/[^/]+/-/tree/[^/]+/?$"
8
+ ],
9
+ "remove": [
10
+ "script",
11
+ "style",
12
+ "svg",
13
+ "nav",
14
+ "footer",
15
+ "header",
16
+ ".navbar-gitlab",
17
+ ".nav-sidebar",
18
+ ".issuable-list",
19
+ ".super-sidebar",
20
+ "aside"
21
+ ],
22
+ "sections": [
23
+ {
24
+ "name": "Title",
25
+ "selector": "h1",
26
+ "format": "text",
27
+ "required": true
28
+ },
29
+ {
30
+ "name": "Description",
31
+ "selector": "meta[name='description']",
32
+ "format": "attribute",
33
+ "attribute": "content",
34
+ "required": false
35
+ },
36
+ {
37
+ "name": "Files",
38
+ "selector": "table[data-qa-selector='file_tree_table'], .tree-table",
39
+ "format": "markdown",
40
+ "required": false
41
+ },
42
+ {
43
+ "name": "README",
44
+ "selector": ".readme-holder .md, .file-content .md, .readme-holder",
45
+ "format": "markdown",
46
+ "required": false
47
+ }
48
+ ]
49
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "go-pkg",
3
+ "description": "Go package documentation on pkg.go.dev — name, overview, and docs",
4
+ "order": 22,
5
+ "url_patterns": [
6
+ "^https?://pkg\\.go\\.dev/[^/]+/?$",
7
+ "^https?://pkg\\.go\\.dev/[^/]+/[^/]+/?$",
8
+ "^https?://pkg\\.go\\.dev/[^/]+/[^/]+/[^/]+/?$"
9
+ ],
10
+ "remove": [
11
+ "script",
12
+ "style",
13
+ "svg",
14
+ "nav",
15
+ "footer",
16
+ ".go-Header",
17
+ ".go-SiteHeader",
18
+ ".go-Footer",
19
+ ".UnitMeta",
20
+ ".UnitMeta-repo",
21
+ ".UnitFiles",
22
+ ".JumpDrawer",
23
+ ".go-Main-nav",
24
+ ".go-Main-headerSubmenu",
25
+ ".Site-header",
26
+ ".UnitHeader-version",
27
+ ".UnitHeader-breadcrumb",
28
+ ".UnitHeader-details"
29
+ ],
30
+ "sections": [
31
+ {
32
+ "name": "Title",
33
+ "selector": "h1",
34
+ "format": "text",
35
+ "required": true
36
+ },
37
+ {
38
+ "name": "Overview",
39
+ "selector": ".Documentation-overview, .Overview",
40
+ "format": "markdown",
41
+ "required": false
42
+ },
43
+ {
44
+ "name": "Documentation",
45
+ "selector": ".Documentation-content, .Documentation, #documentation",
46
+ "format": "markdown",
47
+ "required": false
48
+ }
49
+ ]
50
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "javadoc",
3
+ "description": "Java SE API documentation — class/method details",
4
+ "order": 8.5,
5
+ "url_patterns": [
6
+ "^https?://docs\\.oracle\\.com/.*/docs/api/.*"
7
+ ],
8
+ "remove": [
9
+ "script",
10
+ "style",
11
+ "svg",
12
+ "nav",
13
+ "footer",
14
+ "header",
15
+ ".topNav",
16
+ ".bottomNav",
17
+ ".subNav",
18
+ ".navListSearch",
19
+ ".skipNav",
20
+ ".searchTag",
21
+ ".searchTagResult",
22
+ ".useSummary",
23
+ ".inheritedList",
24
+ ".details",
25
+ ".memberSummary",
26
+ ".colFirst",
27
+ ".colLast"
28
+ ],
29
+ "sections": [
30
+ {
31
+ "name": "Title",
32
+ "selector": ".header h2, h2.title, h2:first-of-type",
33
+ "format": "text",
34
+ "required": false
35
+ },
36
+ {
37
+ "name": "Content",
38
+ "selector": "[role='main'], .document, .rst-content, article, .content, .markdown-body, .prose, main, .contentContainer",
39
+ "format": "markdown",
40
+ "required": true
41
+ }
42
+ ]
43
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "mdn-web-docs",
3
+ "description": "MDN Web Docs article — title and main content",
4
+ "order": 15,
5
+ "url_patterns": [
6
+ "^https?://developer\\.mozilla\\.org/.*"
7
+ ],
8
+ "remove": [
9
+ "script",
10
+ "style",
11
+ "svg",
12
+ "nav",
13
+ "footer",
14
+ "header",
15
+ ".sidebar",
16
+ ".toc",
17
+ ".interactive",
18
+ ".playground",
19
+ ".bc-data",
20
+ ".prev-next",
21
+ ".notecard",
22
+ ".language-menu",
23
+ ".breadcrumbs-container"
24
+ ],
25
+ "sections": [
26
+ {
27
+ "name": "Title",
28
+ "selector": "h1",
29
+ "format": "text",
30
+ "required": true
31
+ },
32
+ {
33
+ "name": "Content",
34
+ "selector": "#content, article, main, .main-page-content",
35
+ "format": "markdown",
36
+ "required": true
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "raw",
3
+ "description": "Raw page content — minimal filtering, full body as markdown (use when you need the complete page without template extraction)",
4
+ "order": 999,
5
+ "remove": [],
6
+ "sections": [
7
+ {
8
+ "name": "Content",
9
+ "selector": "body",
10
+ "format": "markdown",
11
+ "required": false
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "reddit",
3
+ "description": "Reddit post — title, content, and comments",
4
+ "order": 13,
5
+ "url_patterns": [
6
+ "^https?://(?:www\\.|old\\.)?reddit\\.com/r/[^/]+/comments/[^/]+"
7
+ ],
8
+ "remove": [
9
+ "script",
10
+ "style",
11
+ "svg",
12
+ "img",
13
+ "nav",
14
+ "footer",
15
+ "header",
16
+ ".promoted-post",
17
+ "shreddit-ad-post",
18
+ ".side",
19
+ ".sidebar",
20
+ ".footer-parent",
21
+ "#header",
22
+ ".sr-header-area",
23
+ ".menuarea",
24
+ ".linkinfo",
25
+ ".panestack-title",
26
+ ".report-button",
27
+ "shreddit-join-button",
28
+ "#overlayScrollContainer",
29
+ "#right-sidebar-container",
30
+ "#left-sidebar-container"
31
+ ],
32
+ "sections": [
33
+ {
34
+ "name": "Subreddit",
35
+ "selector": "a[href*='/r/'], shreddit-post a[href*='/r/']",
36
+ "format": "text",
37
+ "required": false
38
+ },
39
+ {
40
+ "name": "Title",
41
+ "selector": "h1, shreddit-post [slot='title']",
42
+ "format": "text",
43
+ "required": true
44
+ },
45
+ {
46
+ "name": "Author",
47
+ "selector": "a[href*='/user/'], shreddit-post a[href*='/user/'], [slot='authorName']",
48
+ "format": "text",
49
+ "required": false
50
+ },
51
+ {
52
+ "name": "Link",
53
+ "selector": "a[slot='external-anchor'], a.outbound-link, a[data-testid='outbound-link']",
54
+ "format": "attribute",
55
+ "attribute": "href",
56
+ "required": false
57
+ },
58
+ {
59
+ "name": "Content",
60
+ "selector": "[slot='text-body'], .text-body, .expando, .usertext-body .md",
61
+ "format": "markdown",
62
+ "required": false
63
+ }
64
+ ]
65
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "wikipedia",
3
+ "description": "Wikipedia article — title and main content",
4
+ "order": 11,
5
+ "url_patterns": [
6
+ "^https?://[a-z]{2,4}\\.wikipedia\\.org/wiki/[^:]+$"
7
+ ],
8
+ "remove": [
9
+ "script",
10
+ "style",
11
+ "svg",
12
+ "nav",
13
+ "footer",
14
+ ".mw-editsection",
15
+ ".reflist",
16
+ ".navbox",
17
+ ".sisterproject",
18
+ ".metadata",
19
+ ".sidebar",
20
+ ".infobox",
21
+ "#toc",
22
+ ".mw-jump-link",
23
+ ".printfooter",
24
+ ".catlinks",
25
+ ".mw-authority-control",
26
+ ".shortdescription",
27
+ ".mw-indicators",
28
+ ".page-actions",
29
+ ".mw-page-title-namespace",
30
+ ".mw-heading-subtitle"
31
+ ],
32
+ "sections": [
33
+ {
34
+ "name": "Title",
35
+ "selector": "#firstHeading, h1",
36
+ "format": "text",
37
+ "required": true
38
+ },
39
+ {
40
+ "name": "Content",
41
+ "selector": "#mw-content-text .mw-parser-output",
42
+ "format": "markdown",
43
+ "required": true
44
+ }
45
+ ]
46
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "youtube",
3
+ "description": "YouTube video — title, channel, description",
4
+ "order": 30,
5
+ "url_patterns": [
6
+ "^https?://(?:www\\.)?(?:youtube\\.com/watch\\?v=|youtu\\.be/).+"
7
+ ],
8
+ "remove": [
9
+ "script",
10
+ "style",
11
+ "svg",
12
+ "img",
13
+ "nav",
14
+ "header",
15
+ "ytd-guide-renderer",
16
+ "ytd-mini-guide-renderer",
17
+ "#comments",
18
+ "#related",
19
+ "ytd-comments",
20
+ "ytd-live-chat-frame",
21
+ ".ytp-ad-module"
22
+ ],
23
+ "sections": [
24
+ {
25
+ "name": "Title",
26
+ "selector": "meta[name='title']",
27
+ "format": "attribute",
28
+ "attribute": "content",
29
+ "required": true
30
+ },
31
+ {
32
+ "name": "Channel",
33
+ "selector": "#owner a, ytd-video-owner-renderer a, #channel-name a",
34
+ "format": "text",
35
+ "required": false
36
+ },
37
+ {
38
+ "name": "Description",
39
+ "selector": "#description-inline-expander, ytd-text-inline-expander, #info-container",
40
+ "format": "markdown",
41
+ "required": false
42
+ }
43
+ ]
44
+ }