searchfetch 3.2.0 → 3.2.2
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/index.js +16 -4
- package/package.json +2 -2
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.
|
|
1022
|
+
const server = new McpServer({ name: "searchfetch", version: "3.2.2" });
|
|
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
|
|
1263
|
-
|
|
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.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "Fault-tolerant MCP Server for Stealth Web Search and Fetching",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"searchfetch": "
|
|
7
|
+
"searchfetch": "index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"index.js",
|