searchfetch 3.2.0 → 3.2.3

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.
Files changed (2) hide show
  1. package/index.js +16 -4
  2. package/package.json +13 -8
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // === IMPORTS =============================================================
4
- import { readdirSync, readFileSync } from "node:fs";
4
+ import { readdirSync, readFileSync, realpathSync } from "node:fs";
5
5
  import { dirname, join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -1019,7 +1019,7 @@ function resolveSearchTemplate(engine, query, region, safeSearch) {
1019
1019
 
1020
1020
  // === MCP SERVER & TOOLS ==================================================
1021
1021
 
1022
- const server = new McpServer({ name: "searchfetch", version: "3.2.0" });
1022
+ const server = new McpServer({ name: "searchfetch", version: "3.2.3" });
1023
1023
 
1024
1024
  // --- websearch tool ---
1025
1025
 
@@ -1224,6 +1224,7 @@ export {
1224
1224
  composeSections,
1225
1225
  composeSearchResults,
1226
1226
  genericFallback,
1227
+ isMainModule,
1227
1228
  BUILTIN_TEMPLATES,
1228
1229
  TEMPLATE_MAP,
1229
1230
  };
@@ -1248,6 +1249,15 @@ function redirectStartupOutputToStderr() {
1248
1249
  };
1249
1250
  }
1250
1251
 
1252
+ function isMainModule(argvPath = process.argv[1], modulePath = __filename) {
1253
+ if (!argvPath) return false;
1254
+ try {
1255
+ return realpathSync(argvPath) === realpathSync(modulePath);
1256
+ } catch {
1257
+ return false;
1258
+ }
1259
+ }
1260
+
1251
1261
  async function main() {
1252
1262
  process.on("SIGINT", cleanup);
1253
1263
  process.on("SIGTERM", cleanup);
@@ -1259,8 +1269,10 @@ async function main() {
1259
1269
  await server.connect(transport);
1260
1270
  }
1261
1271
 
1262
- // Guard: only start server when run directly, not when imported
1263
- const isMain = process.argv[1] === __filename;
1272
+ // Guard: only start server when run directly (including via npm bin symlink),
1273
+ // not when imported. Uses realpath so that `npx` / `node_modules/.bin`
1274
+ // symlinks resolve to the module file correctly.
1275
+ const isMain = isMainModule();
1264
1276
  if (isMain) {
1265
1277
  main().catch((_err) => {
1266
1278
  process.exit(1);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "searchfetch",
3
- "version": "3.2.0",
3
+ "version": "3.2.3",
4
4
  "description": "Fault-tolerant MCP Server for Stealth Web Search and Fetching",
5
5
  "type": "module",
6
6
  "bin": {
7
- "searchfetch": "./index.js"
7
+ "searchfetch": "index.js"
8
8
  },
9
9
  "files": [
10
10
  "index.js",
@@ -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"